Commit a1efa7f6 authored by Jiri Slaby (SUSE)'s avatar Jiri Slaby (SUSE) Committed by Greg Kroah-Hartman
Browse files

serial: 8250: invert conditions in RSA functions



The code can short-return in case something does not hold. So invert the
conditions and return in those cases immediately. This makes the code
flow more natural and less nested.

Signed-off-by: default avatar"Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Reviewed-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20250611100319.186924-11-jirislaby@kernel.org


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 33d9ca5d
Loading
Loading
Loading
Loading
+34 −25
Original line number Diff line number Diff line
@@ -743,7 +743,9 @@ static int __enable_rsa(struct uart_8250_port *up)
 */
static void enable_rsa(struct uart_8250_port *up)
{
	if (up->port.type == PORT_RSA) {
	if (up->port.type != PORT_RSA)
		return;

	if (up->port.uartclk != SERIAL_RSA_BAUD_BASE * 16) {
		uart_port_lock_irq(&up->port);
		__enable_rsa(up);
@@ -752,7 +754,6 @@ static void enable_rsa(struct uart_8250_port *up)
	if (up->port.uartclk == SERIAL_RSA_BAUD_BASE * 16)
		serial_out(up, UART_RSA_FRR, 0);
}
}

/*
 * Attempts to turn off the RSA FIFO and resets the RSA board back to 115kbps compat mode. It is
@@ -764,10 +765,13 @@ static void disable_rsa(struct uart_8250_port *up)
	unsigned char mode;
	int result;

	if (up->port.type == PORT_RSA &&
	    up->port.uartclk == SERIAL_RSA_BAUD_BASE * 16) {
		uart_port_lock_irq(&up->port);
	if (up->port.type != PORT_RSA)
		return;

	if (up->port.uartclk != SERIAL_RSA_BAUD_BASE * 16)
		return;

	uart_port_lock_irq(&up->port);
	mode = serial_in(up, UART_RSA_MSR);
	result = !(mode & UART_RSA_MSR_FIFO);

@@ -781,19 +785,24 @@ static void disable_rsa(struct uart_8250_port *up)
		up->port.uartclk = SERIAL_RSA_BAUD_BASE_LO * 16;
	uart_port_unlock_irq(&up->port);
}
}

static void rsa_autoconfig(struct uart_8250_port *up)
{
	/* Only probe for RSA ports if we got the region. */
	if (up->port.type == PORT_16550A && up->probe & UART_PROBE_RSA &&
	    __enable_rsa(up))
	if (up->port.type != PORT_16550A)
		return;
	if (!(up->probe & UART_PROBE_RSA))
		return;

	if (__enable_rsa(up))
		up->port.type = PORT_RSA;
}

static void rsa_reset(struct uart_8250_port *up)
{
	if (up->port.type == PORT_RSA)
	if (up->port.type != PORT_RSA)
		return;

	serial_out(up, UART_RSA_FRR, 0);
}
#else