Commit 285e76fc authored by Cosmin Tanislav's avatar Cosmin Tanislav Committed by Greg Kroah-Hartman

serial: max310x: use regmap methods for SPI batch operations

The SPI batch read/write operations can be implemented as simple
regmap raw read and write, which will also try to do a gather
write just as it is done here.

Use the regmap raw read and write methods.
Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: default avatarCosmin Tanislav <cosmin.tanislav@analog.com>
Link: https://lore.kernel.org/r/20220605144659.4169853-2-demonsingur@gmail.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 484923ad
...@@ -259,8 +259,6 @@ struct max310x_one { ...@@ -259,8 +259,6 @@ struct max310x_one {
struct work_struct md_work; struct work_struct md_work;
struct work_struct rs_work; struct work_struct rs_work;
u8 wr_header;
u8 rd_header;
u8 rx_buf[MAX310X_FIFO_SIZE]; u8 rx_buf[MAX310X_FIFO_SIZE];
}; };
#define to_max310x_port(_port) \ #define to_max310x_port(_port) \
...@@ -623,32 +621,18 @@ static u32 max310x_set_ref_clk(struct device *dev, struct max310x_port *s, ...@@ -623,32 +621,18 @@ static u32 max310x_set_ref_clk(struct device *dev, struct max310x_port *s,
static void max310x_batch_write(struct uart_port *port, u8 *txbuf, unsigned int len) static void max310x_batch_write(struct uart_port *port, u8 *txbuf, unsigned int len)
{ {
struct max310x_one *one = to_max310x_port(port); struct max310x_port *s = dev_get_drvdata(port->dev);
struct spi_transfer xfer[] = { u8 reg = port->iobase + MAX310X_THR_REG;
{
.tx_buf = &one->wr_header, regmap_raw_write(s->regmap, reg, txbuf, len);
.len = sizeof(one->wr_header),
}, {
.tx_buf = txbuf,
.len = len,
}
};
spi_sync_transfer(to_spi_device(port->dev), xfer, ARRAY_SIZE(xfer));
} }
static void max310x_batch_read(struct uart_port *port, u8 *rxbuf, unsigned int len) static void max310x_batch_read(struct uart_port *port, u8 *rxbuf, unsigned int len)
{ {
struct max310x_one *one = to_max310x_port(port); struct max310x_port *s = dev_get_drvdata(port->dev);
struct spi_transfer xfer[] = { u8 reg = port->iobase + MAX310X_RHR_REG;
{
.tx_buf = &one->rd_header, regmap_raw_read(s->regmap, reg, rxbuf, len);
.len = sizeof(one->rd_header),
}, {
.rx_buf = rxbuf,
.len = len,
}
};
spi_sync_transfer(to_spi_device(port->dev), xfer, ARRAY_SIZE(xfer));
} }
static void max310x_handle_rx(struct uart_port *port, unsigned int rxlen) static void max310x_handle_rx(struct uart_port *port, unsigned int rxlen)
...@@ -1368,10 +1352,6 @@ static int max310x_probe(struct device *dev, const struct max310x_devtype *devty ...@@ -1368,10 +1352,6 @@ static int max310x_probe(struct device *dev, const struct max310x_devtype *devty
INIT_WORK(&s->p[i].md_work, max310x_md_proc); INIT_WORK(&s->p[i].md_work, max310x_md_proc);
/* Initialize queue for changing RS485 mode */ /* Initialize queue for changing RS485 mode */
INIT_WORK(&s->p[i].rs_work, max310x_rs_proc); INIT_WORK(&s->p[i].rs_work, max310x_rs_proc);
/* Initialize SPI-transfer buffers */
s->p[i].wr_header = (s->p[i].port.iobase + MAX310X_THR_REG) |
MAX310X_WRITE_BIT;
s->p[i].rd_header = (s->p[i].port.iobase + MAX310X_RHR_REG);
/* Register port */ /* Register port */
ret = uart_add_one_port(&max310x_uart, &s->p[i].port); ret = uart_add_one_port(&max310x_uart, &s->p[i].port);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment