[PATCH 09/10] serial: max310x: move variables to while() scope
From: Hugo Villeneuve
Date: Fri Apr 17 2026 - 10:55:45 EST
From: Hugo Villeneuve <hvilleneuve@xxxxxxxxxxxx>
txlen, to_send and tail variables are only used within the while() loop.
Move them to that scope to keep them closer to their usage and improve
readability.
Signed-off-by: Hugo Villeneuve <hvilleneuve@xxxxxxxxxxxx>
---
drivers/tty/serial/max310x.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c
index b4449b68cfeee07d1d6d3206cf58f72fac00044e..748306d1a9329694e90ec4f096dd00e39d457fda 100644
--- a/drivers/tty/serial/max310x.c
+++ b/drivers/tty/serial/max310x.c
@@ -761,8 +761,6 @@ static void max310x_handle_rx(struct uart_port *port, unsigned int rxlen)
static void max310x_handle_tx(struct uart_port *port)
{
struct tty_port *tport = &port->state->port;
- unsigned int txlen, to_send;
- unsigned char *tail;
if (unlikely(port->x_char)) {
max310x_port_write(port, MAX310X_THR_REG, port->x_char);
@@ -779,6 +777,9 @@ static void max310x_handle_tx(struct uart_port *port)
* We could do that in one SPI transaction, but meh.
*/
while (!kfifo_is_empty(&tport->xmit_fifo)) {
+ unsigned int txlen, to_send;
+ unsigned char *tail;
+
/* Limit to space available in TX FIFO */
txlen = max310x_port_read(port, MAX310X_TXFIFOLVL_REG);
txlen = port->fifosize - txlen;
--
2.47.3