Commit 00ce7c6e authored by Bartosz Golaszewski's avatar Bartosz Golaszewski Committed by Greg Kroah-Hartman

tty: serial: qcom-geni-serial: improve the to_dev_port() macro

The member we want to resolve in struct qcom_geni_serial_port is called
uport so we don't need an additional redundant parameter in this macro.

While at it: turn the macro into a static inline function.
Signed-off-by: default avatarBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Reviewed-by: default avatarKonrad Dybcio <konrad.dybcio@linaro.org>
Link: https://lore.kernel.org/r/20221229155030.418800-6-brgl@bgdev.plSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 6cde11db
...@@ -133,8 +133,10 @@ static const struct uart_ops qcom_geni_uart_pops; ...@@ -133,8 +133,10 @@ static const struct uart_ops qcom_geni_uart_pops;
static struct uart_driver qcom_geni_console_driver; static struct uart_driver qcom_geni_console_driver;
static struct uart_driver qcom_geni_uart_driver; static struct uart_driver qcom_geni_uart_driver;
#define to_dev_port(ptr, member) \ static inline struct qcom_geni_serial_port *to_dev_port(struct uart_port *uport)
container_of(ptr, struct qcom_geni_serial_port, member) {
return container_of(uport, struct qcom_geni_serial_port, uport);
}
static struct qcom_geni_serial_port qcom_geni_uart_ports[GENI_UART_PORTS] = { static struct qcom_geni_serial_port qcom_geni_uart_ports[GENI_UART_PORTS] = {
[0] = { [0] = {
...@@ -175,7 +177,7 @@ static struct qcom_geni_serial_port qcom_geni_console_port = { ...@@ -175,7 +177,7 @@ static struct qcom_geni_serial_port qcom_geni_console_port = {
static int qcom_geni_serial_request_port(struct uart_port *uport) static int qcom_geni_serial_request_port(struct uart_port *uport)
{ {
struct platform_device *pdev = to_platform_device(uport->dev); struct platform_device *pdev = to_platform_device(uport->dev);
struct qcom_geni_serial_port *port = to_dev_port(uport, uport); struct qcom_geni_serial_port *port = to_dev_port(uport);
uport->membase = devm_platform_ioremap_resource(pdev, 0); uport->membase = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(uport->membase)) if (IS_ERR(uport->membase))
...@@ -212,7 +214,7 @@ static void qcom_geni_serial_set_mctrl(struct uart_port *uport, ...@@ -212,7 +214,7 @@ static void qcom_geni_serial_set_mctrl(struct uart_port *uport,
unsigned int mctrl) unsigned int mctrl)
{ {
u32 uart_manual_rfr = 0; u32 uart_manual_rfr = 0;
struct qcom_geni_serial_port *port = to_dev_port(uport, uport); struct qcom_geni_serial_port *port = to_dev_port(uport);
if (uart_console(uport)) if (uart_console(uport))
return; return;
...@@ -253,7 +255,7 @@ static bool qcom_geni_serial_poll_bit(struct uart_port *uport, ...@@ -253,7 +255,7 @@ static bool qcom_geni_serial_poll_bit(struct uart_port *uport,
struct qcom_geni_private_data *private_data = uport->private_data; struct qcom_geni_private_data *private_data = uport->private_data;
if (private_data->drv) { if (private_data->drv) {
port = to_dev_port(uport, uport); port = to_dev_port(uport);
baud = port->baud; baud = port->baud;
if (!baud) if (!baud)
baud = 115200; baud = 115200;
...@@ -506,7 +508,7 @@ static int handle_rx_console(struct uart_port *uport, u32 bytes, bool drop) ...@@ -506,7 +508,7 @@ static int handle_rx_console(struct uart_port *uport, u32 bytes, bool drop)
u32 i; u32 i;
unsigned char buf[sizeof(u32)]; unsigned char buf[sizeof(u32)];
struct tty_port *tport; struct tty_port *tport;
struct qcom_geni_serial_port *port = to_dev_port(uport, uport); struct qcom_geni_serial_port *port = to_dev_port(uport);
tport = &uport->state->port; tport = &uport->state->port;
for (i = 0; i < bytes; ) { for (i = 0; i < bytes; ) {
...@@ -549,7 +551,7 @@ static int handle_rx_console(struct uart_port *uport, u32 bytes, bool drop) ...@@ -549,7 +551,7 @@ static int handle_rx_console(struct uart_port *uport, u32 bytes, bool drop)
static int handle_rx_uart(struct uart_port *uport, u32 bytes, bool drop) static int handle_rx_uart(struct uart_port *uport, u32 bytes, bool drop)
{ {
struct tty_port *tport; struct tty_port *tport;
struct qcom_geni_serial_port *port = to_dev_port(uport, uport); struct qcom_geni_serial_port *port = to_dev_port(uport);
u32 num_bytes_pw = port->tx_fifo_width / BITS_PER_BYTE; u32 num_bytes_pw = port->tx_fifo_width / BITS_PER_BYTE;
u32 words = ALIGN(bytes, num_bytes_pw) / num_bytes_pw; u32 words = ALIGN(bytes, num_bytes_pw) / num_bytes_pw;
int ret; int ret;
...@@ -598,7 +600,7 @@ static void qcom_geni_serial_stop_tx(struct uart_port *uport) ...@@ -598,7 +600,7 @@ static void qcom_geni_serial_stop_tx(struct uart_port *uport)
{ {
u32 irq_en; u32 irq_en;
u32 status; u32 status;
struct qcom_geni_serial_port *port = to_dev_port(uport, uport); struct qcom_geni_serial_port *port = to_dev_port(uport);
irq_en = readl(uport->membase + SE_GENI_M_IRQ_EN); irq_en = readl(uport->membase + SE_GENI_M_IRQ_EN);
irq_en &= ~(M_CMD_DONE_EN | M_TX_FIFO_WATERMARK_EN); irq_en &= ~(M_CMD_DONE_EN | M_TX_FIFO_WATERMARK_EN);
...@@ -627,7 +629,7 @@ static void qcom_geni_serial_handle_rx(struct uart_port *uport, bool drop) ...@@ -627,7 +629,7 @@ static void qcom_geni_serial_handle_rx(struct uart_port *uport, bool drop)
u32 last_word_byte_cnt; u32 last_word_byte_cnt;
u32 last_word_partial; u32 last_word_partial;
u32 total_bytes; u32 total_bytes;
struct qcom_geni_serial_port *port = to_dev_port(uport, uport); struct qcom_geni_serial_port *port = to_dev_port(uport);
status = readl(uport->membase + SE_GENI_RX_FIFO_STATUS); status = readl(uport->membase + SE_GENI_RX_FIFO_STATUS);
word_cnt = status & RX_FIFO_WC_MSK; word_cnt = status & RX_FIFO_WC_MSK;
...@@ -649,7 +651,7 @@ static void qcom_geni_serial_stop_rx(struct uart_port *uport) ...@@ -649,7 +651,7 @@ static void qcom_geni_serial_stop_rx(struct uart_port *uport)
{ {
u32 irq_en; u32 irq_en;
u32 status; u32 status;
struct qcom_geni_serial_port *port = to_dev_port(uport, uport); struct qcom_geni_serial_port *port = to_dev_port(uport);
u32 s_irq_status; u32 s_irq_status;
irq_en = readl(uport->membase + SE_GENI_S_IRQ_EN); irq_en = readl(uport->membase + SE_GENI_S_IRQ_EN);
...@@ -687,7 +689,7 @@ static void qcom_geni_serial_start_rx(struct uart_port *uport) ...@@ -687,7 +689,7 @@ static void qcom_geni_serial_start_rx(struct uart_port *uport)
{ {
u32 irq_en; u32 irq_en;
u32 status; u32 status;
struct qcom_geni_serial_port *port = to_dev_port(uport, uport); struct qcom_geni_serial_port *port = to_dev_port(uport);
status = readl(uport->membase + SE_GENI_STATUS); status = readl(uport->membase + SE_GENI_STATUS);
if (status & S_GENI_CMD_ACTIVE) if (status & S_GENI_CMD_ACTIVE)
...@@ -707,7 +709,7 @@ static void qcom_geni_serial_start_rx(struct uart_port *uport) ...@@ -707,7 +709,7 @@ static void qcom_geni_serial_start_rx(struct uart_port *uport)
static void qcom_geni_serial_handle_tx(struct uart_port *uport, bool done, static void qcom_geni_serial_handle_tx(struct uart_port *uport, bool done,
bool active) bool active)
{ {
struct qcom_geni_serial_port *port = to_dev_port(uport, uport); struct qcom_geni_serial_port *port = to_dev_port(uport);
struct circ_buf *xmit = &uport->state->xmit; struct circ_buf *xmit = &uport->state->xmit;
size_t avail; size_t avail;
size_t remaining; size_t remaining;
...@@ -803,7 +805,7 @@ static irqreturn_t qcom_geni_serial_isr(int isr, void *dev) ...@@ -803,7 +805,7 @@ static irqreturn_t qcom_geni_serial_isr(int isr, void *dev)
struct uart_port *uport = dev; struct uart_port *uport = dev;
bool drop_rx = false; bool drop_rx = false;
struct tty_port *tport = &uport->state->port; struct tty_port *tport = &uport->state->port;
struct qcom_geni_serial_port *port = to_dev_port(uport, uport); struct qcom_geni_serial_port *port = to_dev_port(uport);
if (uport->suspended) if (uport->suspended)
return IRQ_NONE; return IRQ_NONE;
...@@ -871,7 +873,7 @@ static void qcom_geni_serial_shutdown(struct uart_port *uport) ...@@ -871,7 +873,7 @@ static void qcom_geni_serial_shutdown(struct uart_port *uport)
static int qcom_geni_serial_port_setup(struct uart_port *uport) static int qcom_geni_serial_port_setup(struct uart_port *uport)
{ {
struct qcom_geni_serial_port *port = to_dev_port(uport, uport); struct qcom_geni_serial_port *port = to_dev_port(uport);
u32 rxstale = DEFAULT_BITS_PER_CHAR * STALE_TIMEOUT; u32 rxstale = DEFAULT_BITS_PER_CHAR * STALE_TIMEOUT;
u32 proto; u32 proto;
u32 pin_swap; u32 pin_swap;
...@@ -920,7 +922,7 @@ static int qcom_geni_serial_port_setup(struct uart_port *uport) ...@@ -920,7 +922,7 @@ static int qcom_geni_serial_port_setup(struct uart_port *uport)
static int qcom_geni_serial_startup(struct uart_port *uport) static int qcom_geni_serial_startup(struct uart_port *uport)
{ {
int ret; int ret;
struct qcom_geni_serial_port *port = to_dev_port(uport, uport); struct qcom_geni_serial_port *port = to_dev_port(uport);
if (!port->setup) { if (!port->setup) {
ret = qcom_geni_serial_port_setup(uport); ret = qcom_geni_serial_port_setup(uport);
...@@ -1006,7 +1008,7 @@ static void qcom_geni_serial_set_termios(struct uart_port *uport, ...@@ -1006,7 +1008,7 @@ static void qcom_geni_serial_set_termios(struct uart_port *uport,
u32 stop_bit_len; u32 stop_bit_len;
unsigned int clk_div; unsigned int clk_div;
u32 ser_clk_cfg; u32 ser_clk_cfg;
struct qcom_geni_serial_port *port = to_dev_port(uport, uport); struct qcom_geni_serial_port *port = to_dev_port(uport);
unsigned long clk_rate; unsigned long clk_rate;
u32 ver, sampling_rate; u32 ver, sampling_rate;
unsigned int avg_bw_core; unsigned int avg_bw_core;
...@@ -1291,7 +1293,7 @@ static struct uart_driver qcom_geni_uart_driver = { ...@@ -1291,7 +1293,7 @@ static struct uart_driver qcom_geni_uart_driver = {
static void qcom_geni_serial_pm(struct uart_port *uport, static void qcom_geni_serial_pm(struct uart_port *uport,
unsigned int new_state, unsigned int old_state) unsigned int new_state, unsigned int old_state)
{ {
struct qcom_geni_serial_port *port = to_dev_port(uport, uport); struct qcom_geni_serial_port *port = to_dev_port(uport);
/* If we've never been called, treat it as off */ /* If we've never been called, treat it as off */
if (old_state == UART_PM_STATE_UNDEFINED) if (old_state == UART_PM_STATE_UNDEFINED)
......
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