Skip to content

Commit f031d76

Browse files
hvilleneuvedoogregkh
authored andcommitted
serial: sc16is7xx: refactor FIFO access functions to increase commonality
Simplify FIFO access functions by avoiding to declare a struct sc16is7xx_port *s variable within each function. This is mainly done to have more commonality between the max310x and sc16is7xx drivers. Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com> Link: https://lore.kernel.org/r/20231221231823.2327894-15-hugo@hugovil.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e54837d commit f031d76

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

drivers/tty/serial/sc16is7xx.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -379,17 +379,15 @@ static void sc16is7xx_port_write(struct uart_port *port, u8 reg, u8 val)
379379
regmap_write(one->regmap, reg, val);
380380
}
381381

382-
static void sc16is7xx_fifo_read(struct uart_port *port, unsigned int rxlen)
382+
static void sc16is7xx_fifo_read(struct uart_port *port, u8 *rxbuf, unsigned int rxlen)
383383
{
384-
struct sc16is7xx_port *s = dev_get_drvdata(port->dev);
385384
struct sc16is7xx_one *one = to_sc16is7xx_one(port, port);
386385

387-
regmap_noinc_read(one->regmap, SC16IS7XX_RHR_REG, s->buf, rxlen);
386+
regmap_noinc_read(one->regmap, SC16IS7XX_RHR_REG, rxbuf, rxlen);
388387
}
389388

390-
static void sc16is7xx_fifo_write(struct uart_port *port, u8 to_send)
389+
static void sc16is7xx_fifo_write(struct uart_port *port, u8 *txbuf, u8 to_send)
391390
{
392-
struct sc16is7xx_port *s = dev_get_drvdata(port->dev);
393391
struct sc16is7xx_one *one = to_sc16is7xx_one(port, port);
394392

395393
/*
@@ -399,7 +397,7 @@ static void sc16is7xx_fifo_write(struct uart_port *port, u8 to_send)
399397
if (unlikely(!to_send))
400398
return;
401399

402-
regmap_noinc_write(one->regmap, SC16IS7XX_THR_REG, s->buf, to_send);
400+
regmap_noinc_write(one->regmap, SC16IS7XX_THR_REG, txbuf, to_send);
403401
}
404402

405403
static void sc16is7xx_port_update(struct uart_port *port, u8 reg,
@@ -575,7 +573,7 @@ static void sc16is7xx_handle_rx(struct uart_port *port, unsigned int rxlen,
575573
s->buf[0] = sc16is7xx_port_read(port, SC16IS7XX_RHR_REG);
576574
bytes_read = 1;
577575
} else {
578-
sc16is7xx_fifo_read(port, rxlen);
576+
sc16is7xx_fifo_read(port, s->buf, rxlen);
579577
bytes_read = rxlen;
580578
}
581579

@@ -664,7 +662,7 @@ static void sc16is7xx_handle_tx(struct uart_port *port)
664662
uart_xmit_advance(port, 1);
665663
}
666664

667-
sc16is7xx_fifo_write(port, to_send);
665+
sc16is7xx_fifo_write(port, s->buf, to_send);
668666
}
669667

670668
uart_port_lock_irqsave(port, &flags);

0 commit comments

Comments
 (0)