Commit c275e006 authored by Hugo Villeneuve's avatar Hugo Villeneuve Committed by Zhao Yipeng
Browse files

serial: sc16is7xx: refactor FIFO access functions to increase commonality

mainline inclusion
from mainline-v6.8-rc1
commit f031d763dcb0b4dbd4bbf1d4324f7ca91761d3b1
category: feature
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IAOXYG
CVE: CVE-2024-44951

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f031d763dcb0b4dbd4bbf1d4324f7ca91761d3b1



--------------------------------

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: default avatarHugo Villeneuve <hvilleneuve@dimonoff.com>
Link: https://lore.kernel.org/r/20231221231823.2327894-15-hugo@hugovil.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarZhao Yipeng <zhaoyipeng5@huawei.com>
parent 9d0af12b
Loading
Loading
Loading
Loading
+6 −8
Original line number Diff line number Diff line
@@ -378,17 +378,15 @@ static void sc16is7xx_port_write(struct uart_port *port, u8 reg, u8 val)
	regmap_write(one->regmap, reg, val);
}

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

	regmap_noinc_read(one->regmap, SC16IS7XX_RHR_REG, s->buf, rxlen);
	regmap_noinc_read(one->regmap, SC16IS7XX_RHR_REG, rxbuf, rxlen);
}

static void sc16is7xx_fifo_write(struct uart_port *port, u8 to_send)
static void sc16is7xx_fifo_write(struct uart_port *port, u8 *txbuf, u8 to_send)
{
	struct sc16is7xx_port *s = dev_get_drvdata(port->dev);
	struct sc16is7xx_one *one = to_sc16is7xx_one(port, port);

	/*
@@ -398,7 +396,7 @@ static void sc16is7xx_fifo_write(struct uart_port *port, u8 to_send)
	if (unlikely(!to_send))
		return;

	regmap_noinc_write(one->regmap, SC16IS7XX_THR_REG, s->buf, to_send);
	regmap_noinc_write(one->regmap, SC16IS7XX_THR_REG, txbuf, to_send);
}

static void sc16is7xx_port_update(struct uart_port *port, u8 reg,
@@ -595,7 +593,7 @@ static void sc16is7xx_handle_rx(struct uart_port *port, unsigned int rxlen,
			s->buf[0] = sc16is7xx_port_read(port, SC16IS7XX_RHR_REG);
			bytes_read = 1;
		} else {
			sc16is7xx_fifo_read(port, rxlen);
			sc16is7xx_fifo_read(port, s->buf, rxlen);
			bytes_read = rxlen;
		}

@@ -684,7 +682,7 @@ static void sc16is7xx_handle_tx(struct uart_port *port)
			uart_xmit_advance(port, 1);
		}

		sc16is7xx_fifo_write(port, to_send);
		sc16is7xx_fifo_write(port, s->buf, to_send);
	}

	uart_port_lock_irqsave(port, &flags);