Commit 90574a5b authored by Ilpo Järvinen's avatar Ilpo Järvinen Committed by Greg Kroah-Hartman
Browse files

serial: 8250: handle __start_tx() call in start_tx()



As either start_tx_rs485() or start_tx() calls __start_tx() as the last
line of their logic, it makes sense to just move that call into
start_tx(). When start_tx_rs485() wants to defer tx using timer, return
false so start_tx() can return based on it.

Reorganize em485 code in serial8250_start_tx() so that the return can be
shared for the cases where tx start is deferred.

Signed-off-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20220607084154.8172-2-ilpo.jarvinen@linux.intel.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 767cc668
Loading
Loading
Loading
Loading
+10 −11
Original line number Diff line number Diff line
@@ -1610,7 +1610,8 @@ void serial8250_em485_start_tx(struct uart_8250_port *up)
}
EXPORT_SYMBOL_GPL(serial8250_em485_start_tx);

static inline void start_tx_rs485(struct uart_port *port)
/* Returns false, if start_tx_timer was setup to defer TX start */
static bool start_tx_rs485(struct uart_port *port)
{
	struct uart_8250_port *up = up_to_u8250p(port);
	struct uart_8250_em485 *em485 = up->em485;
@@ -1638,11 +1639,11 @@ static inline void start_tx_rs485(struct uart_port *port)
			em485->active_timer = &em485->start_tx_timer;
			start_hrtimer_ms(&em485->start_tx_timer,
					 up->port.rs485.delay_rts_before_send);
			return;
			return false;
		}
	}

	__start_tx(port);
	return true;
}

static enum hrtimer_restart serial8250_em485_handle_start_tx(struct hrtimer *t)
@@ -1672,13 +1673,11 @@ static void serial8250_start_tx(struct uart_port *port)

	serial8250_rpm_get_tx(up);

	if (em485 &&
	    em485->active_timer == &em485->start_tx_timer)
	if (em485) {
		if ((em485->active_timer == &em485->start_tx_timer) ||
		    !start_tx_rs485(port))
			return;

	if (em485)
		start_tx_rs485(port);
	else
	}
	__start_tx(port);
}