serial: uartps:
Subsystems (2)
v2 cover serial: uartps:
Hi,
This patchset is fixing several issues reported by checkpatch but also major number handling for multiple allocated ports. For more information please look at the first patch which describes more details.
When this patchset is applied driver only reports one checkpatch warning which should be fixed via console.h first.include/linux/console.h:147: void (*write)(struct console *, const char *, unsigned);
WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
+ unsigned n)
Thanks,
Michal
v1
https://lkml.org/lkml/2019/6/10/186
https://lkml.org/lkml/2019/6/10/187
Changes in v2:
- Fix typo in subject line
- Swap patches compare to previous series
- Add Fixes tag
- Split patch from v1
- Fixes second S_IRUGO usage
- Add Fixes tag
- Split patch from v1
- Add Fixes tag
- Split patch from v1
- Add Fixes tag
- Split patch from v1
- Add Fixes tag
- Split patch from v1
- Add Fixes tag
Nava kishore Manne (5):
serial: uartps: Use octal permission for module_param()
serial: uartps: Fix multiple line dereference
serial: uartps: Fix long line over 80 chars
serial: uartps: Do not add a trailing semicolon to macro
serial: uartps: Remove useless return from cdns_uart_poll_put_char
Shubhrajyoti Datta (1):
serial: uartps: Use the same dynamic major number for all ports
drivers/tty/serial/xilinx_uartps.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
Signature · 1 line
2.17.1
PATCH v2 1/6 serial: uartps: Use the same dynamic major number for all ports
From: Shubhrajyoti Datta <[email protected]>
Let kernel to find out major number dynamically for the first device and then reuse it for other instances.
This fixes the issue that each uart is registered with a different major number.
After the patch:
crw------- 1 root root 253, 0 Jun 10 08:31 /dev/ttyPS0 crw--w---- 1 root root 253, 1 Jan 1 1970 /dev/ttyPS1
---
Changes in v2:
- Fix typo in subject line
- Swap patches compare to previous series
- Add Fixes tag
drivers/tty/serial/xilinx_uartps.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/tty/serial/xilinx_uartps.c +3 -2
@@ -29,12 +29,12 @@#define CDNS_UART_TTY_NAME "ttyPS"#define CDNS_UART_NAME "xuartps" -#define CDNS_UART_MAJOR 0/* use dynamic node allocation */ #define CDNS_UART_FIFO_SIZE 64/* FIFO size */ #define CDNS_UART_REGISTER_SPACE 0x1000/* Rx Trigger level */ static int rx_trigger_level =56 ; +static int uartps_major;module_param (rx_trigger_level, uint,S_IRUGO );MODULE_PARM_DESC (rx_trigger_level,"Rx trigger level, 1-63 bytes" );
@@ -1517,7 +1517,7 @@ static int cdns_uart_probe(struct platform_device *pdev) cdns_uart_uart_driver->owner =THIS_MODULE ; cdns_uart_uart_driver->driver_name = driver_name; cdns_uart_uart_driver->dev_name =CDNS_UART_TTY_NAME ; - cdns_uart_uart_driver->major =CDNS_UART_MAJOR ; + cdns_uart_uart_driver->major = uartps_major; cdns_uart_uart_driver->minor = cdns_uart_data->id; cdns_uart_uart_driver->nr =1 ;
@@ -1546,6 +1546,7 @@ static int cdns_uart_probe(struct platform_device *pdev) goto err_out_id; } + uartps_major = cdns_uart_uart_driver->tty_driver->major; cdns_uart_data->cdns_uart_driver = cdns_uart_uart_driver;/*
Signature · 1 line
2.17.1
PATCH v2 2/6 serial: uartps: Use octal permission for module_param()
In reply to Michal SimekFrom: Nava kishore Manne <[email protected]>
Octal permission is preffered compare to symbolic one.
This patch fixes checkpatch warnings:
Symbolic permissions 'S_IRUGO' are not preferred. Consider using octal permissions '0444'.
---
Changes in v2:
- Split patch from v1
- Fixes second S_IRUGO usage
- Add Fixes tag
drivers/tty/serial/xilinx_uartps.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/serial/xilinx_uartps.c +2 -2
@@ -35,12 +35,12 @@/* Rx Trigger level */ static int rx_trigger_level =56 ;static int uartps_major; -module_param (rx_trigger_level, uint,S_IRUGO ); +module_param (rx_trigger_level, uint,0444 );MODULE_PARM_DESC (rx_trigger_level,"Rx trigger level, 1-63 bytes" );/* Rx Timeout */ static int rx_timeout =10 ; -module_param (rx_timeout, uint,S_IRUGO ); +module_param (rx_timeout, uint,0444 );MODULE_PARM_DESC (rx_timeout,"Rx timeout, 1-255" );/* Register offsets for the UART. */
Signature · 1 line
2.17.1
PATCH v2 3/6 serial: uartps: Fix multiple line dereference
In reply to Michal SimekFrom: Nava kishore Manne <[email protected]>
Trivial patch which fixes this checkpatch warning:
WARNING: Avoid multiple line dereference - prefer 'port->state->xmit.tail'
+ port->state->xmit.buf[port->state->xmit.
+ tail], port->membase + CDNS_UART_FIFO);
---
Changes in v2:
- Split patch from v1
- Add Fixes tag
drivers/tty/serial/xilinx_uartps.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/serial/xilinx_uartps.c +2 -2
@@ -319,8 +319,8 @@ static void cdns_uart_handle_tx(void *dev_id)* register. */ writel ( - port->state->xmit.buf[port->state->xmit. - tail], port->membase +CDNS_UART_FIFO ); + port->state->xmit.buf[port->state->xmit.tail], + port->membase +CDNS_UART_FIFO ); port->icount.tx++;
Signature · 1 line
2.17.1
Re: [PATCH v2 3/6] serial: uartps: Fix multiple line dereference
Quoted 24 lines · Michal Simek
From: Nava kishore Manne <[email protected]>
Trivial patch which fixes this checkpatch warning:
WARNING: Avoid multiple line dereference - prefer 'port->state->xmit.tail'(quoted diff) +2
-0+ port->state->xmit.buf[port->state->xmit. + tail], port->membase + CDNS_UART_FIFO);Fixes c8dbdc842d30 ("serial: xuartps: Rewrite the interrupt handling logic")Signed-off-by Nava kishore Manne <[email protected]>Signed-off-by Michal Simek <[email protected]>---
Changes in v2:
- Split patch from v1
- Add Fixes tagdrivers/tty/serial/xilinx_uartps.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/tty/serial/xilinx_uartps.c +0
-0
drivers/tty/serial/xilinx_uartps.c static void cdns_uart_handle_tx(void *dev_id) · line 325
Quoted 9 lines
drivers/tty/serial/xilinx_uartps.c +2
-2@@ -319,8 +319,8 @@ static void cdns_uart_handle_tx(void *dev_id)* register. */ writel ( - port->state->xmit.buf[port->state->xmit. - tail], port->membase +CDNS_UART_FIFO ); + port->state->xmit.buf[port->state->xmit.tail], + port->membase +CDNS_UART_FIFO ); port->icount.tx++;
Another way to rewrite this is to use a temporary for port->state->xmit and also return early on empty to avoid unnecessary indentation.
Using a temporary can also reduce object size a bit by removing unnecessary dereferences: (defconfig x86-64)
$ size drivers/tty/serial/xilinx_uartps.o* text data bss dec hex filename 26578 4632 320 31530 7b2a drivers/tty/serial/xilinx_uartps.o.new 26642 4632 320 31594 7b6a drivers/tty/serial/xilinx_uartps.o.old
i.e.:
--- drivers/tty/serial/xilinx_uartps.c | 54 ++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 29 deletions(-)
drivers/tty/serial/xilinx_uartps.c +25 -29
@@ -305,40 +305,36 @@ static void cdns_uart_handle_rx(void *dev_id, unsigned int isrstatus)static void cdns_uart_handle_tx (void *dev_id) {struct uart_port *port = (struct uart_port *)dev_id; +struct circ_buf *xmit = &port->state->xmit;unsigned int numbytes; -if (uart_circ_empty (&port->state->xmit)) { +if (uart_circ_empty (xmit)) {writel (CDNS_UART_IXR_TXEMPTY , port->membase +CDNS_UART_IDR ); - }else { - numbytes = port->fifosize; -while (numbytes && !uart_circ_empty (&port->state->xmit) && - !(readl (port->membase +CDNS_UART_SR ) &CDNS_UART_SR_TXFULL )) { -/* -* Get the data from the UART circular buffer -* and write it to the cdns_uart's TX_FIFO -* register. -*/ -writel ( - port->state->xmit.buf[port->state->xmit. - tail], port->membase +CDNS_UART_FIFO ); - - port->icount.tx++; - -/* -* Adjust the tail of the UART buffer and wrap -* the buffer if it reaches limit. -*/ - port->state->xmit.tail = - (port->state->xmit.tail +1 ) & - (UART_XMIT_SIZE -1 ); - - numbytes--; - } +return ; + } + + numbytes = port->fifosize; +while (numbytes && !uart_circ_empty (xmit) && + !(readl (port->membase +CDNS_UART_SR ) &CDNS_UART_SR_TXFULL )) { +/* +* Get the data from the UART circular buffer and write it +* to the cdns_uart's TX_FIFO register. +*/ +writel (xmit->buf[xmit->tail], port->membase +CDNS_UART_FIFO ); + + port->icount.tx++; + +/* +* Adjust the tail of the UART buffer and wrap the buffer +* if it reaches limit. +*/ + xmit->tail = (xmit->tail +1 ) & (UART_XMIT_SIZE -1 ); -if (uart_circ_chars_pending ( - &port->state->xmit) <WAKEUP_CHARS ) -uart_write_wakeup (port); + numbytes--; } + +if (uart_circ_chars_pending (xmit) <WAKEUP_CHARS ) +uart_write_wakeup (port); }/**
PATCH v2 4/6 serial: uartps: Fix long line over 80 chars
In reply to Michal SimekFrom: Nava kishore Manne <[email protected]>
Trivial patch which fixes one checkpatch warning:
WARNING: line over 80 characters
+ !(readl(port->membase + CDNS_UART_SR)
& CDNS_UART_SR_TXFULL)) {---
Changes in v2:
- Split patch from v1
- Add Fixes tag
drivers/tty/serial/xilinx_uartps.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/tty/serial/xilinx_uartps.c +2 -1
@@ -312,7 +312,8 @@ static void cdns_uart_handle_tx(void *dev_id) }else { numbytes = port->fifosize;while (numbytes && !uart_circ_empty (&port->state->xmit) && - !(readl (port->membase +CDNS_UART_SR ) &CDNS_UART_SR_TXFULL )) { + !(readl (port->membase +CDNS_UART_SR ) & +CDNS_UART_SR_TXFULL )) {/* * Get the data from the UART circular buffer * and write it to the cdns_uart's TX_FIFO
Signature · 1 line
2.17.1
PATCH v2 5/6 serial: uartps: Do not add a trailing semicolon to macro
In reply to Michal SimekFrom: Nava kishore Manne <[email protected]>
This patch fixes this checkpatch warning:
WARNING: macros should not use a trailing semicolon +#define to_cdns_uart(_nb) container_of(_nb, struct cdns_uart, \
+ clk_rate_change_nb);
---
Changes in v2:
- Split patch from v1
- Add Fixes tag
Origin patch which introduce this semicolon was c4b0510cc1571ff44e1 ("tty: xuartps: Dynamically adjust to input frequency changes")
--- drivers/tty/serial/xilinx_uartps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/xilinx_uartps.c +1 -1
@@ -199,7 +199,7 @@ struct cdns_platform_data {u32 quirks; };#define to_cdns_uart (_nb) container_of(_nb, struct cdns_uart, \ - clk_rate_change_nb); + clk_rate_change_nb)/** * cdns_uart_handle_rx - Handle the received bytes along with Rx errors.
Signature · 1 line
2.17.1
Re: [PATCH v2 5/6] serial: uartps: Do not add a trailing semicolon to macro
drivers/tty/serial/xilinx_uartps.c
Quoted 7 lines · Michal Simek
From: Nava kishore Manne <[email protected]>
This patch fixes this checkpatch warning:
WARNING: macros should not use a trailing semicolon(quoted diff) +2
-0+#define to_cdns_uart(_nb) container_of(_nb, struct cdns_uart, \ + clk_rate_change_nb);drivers/tty/serial/xilinx_uartps.c +0
-0
[]
drivers/tty/serial/xilinx_uartps.c struct cdns_platform_data { · line 205
Quoted 9 lines
drivers/tty/serial/xilinx_uartps.c +1
-1@@ -199,7 +199,7 @@ struct cdns_platform_data {u32 quirks; };#define to_cdns_uart (_nb) container_of(_nb, struct cdns_uart, \ - clk_rate_change_nb); + clk_rate_change_nb)/** * cdns_uart_handle_rx - Handle the received bytes along with Rx errors.
trivia:
Perhaps this is easier for humans to read with the macro on two lines like:
#define to_cdns_uart(_nb) \
container_of(_nb, struct cdns_uart, clk_rate_change_nb)
or just ignore the 80 column limit
#define to_cdns_uart(_nb) container_of(_nb, struct cdns_uart, clk_rate_change_nb)
or because the macro is only used in one place,
just get rid of it and use container_of directly.
--- drivers/tty/serial/xilinx_uartps.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/tty/serial/xilinx_uartps.c +3 -3
@@ -195,11 +195,10 @@ struct cdns_uart {u32 quirks;bool cts_override; }; +struct cdns_platform_data {u32 quirks; }; -#define to_cdns_uart (_nb) container_of(_nb, struct cdns_uart, \ - clk_rate_change_nb);/** * cdns_uart_handle_rx - Handle the received bytes along with Rx errors.
@@ -489,8 +488,9 @@ static int cdns_uart_clk_notifier_cb(struct notifier_block *nb,int locked =0 ;struct clk_notifier_data *ndata = data;unsigned long flags =0 ; -struct cdns_uart *cdns_uart =to_cdns_uart (nb); +struct cdns_uart *cdns_uart; + cdns_uart = container_of(nb, struct cdns_uart, clk_rate_change_nb); port = cdns_uart->port;if (port->suspended)return NOTIFY_OK ;
PATCH v2 6/6 serial: uartps: Remove useless return from cdns_uart_poll_put_char
In reply to Michal SimekFrom: Nava kishore Manne <[email protected]>
There is no reason to call return at the end of function which should return void.
The patch is also remove one checkpatch warning:
WARNING: void function return statements are not generally useful
+ return;
+}
---
Changes in v2:
- Split patch from v1
- Add Fixes tag
drivers/tty/serial/xilinx_uartps.c | 2 -- 1 file changed, 2 deletions(-)
drivers/tty/serial/xilinx_uartps.c +0 -2
@@ -1074,8 +1074,6 @@ static void cdns_uart_poll_put_char(struct uart_port *port, unsigned char c)cpu_relax (); spin_unlock_irqrestore(&port->lock, flags); - - return; }#endif
Signature · 1 line
2.17.1