tty/serial/pch_uart: Adjustments for four function implementations
Subsystems (2)
cover tty/serial/pch_uart: Adjustments for four function implementations
From: Markus Elfring <[email protected]>
Date: Fri, 8 Dec 2017 19:03:45 +0100
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (4):
Delete an error message for a failed memory allocation in dma_handle_tx() Use kcalloc() in dma_handle_tx()
Delete an unnecessary return statement in two functions Improve a size determination in pch_uart_init_port()
drivers/tty/serial/pch_uart.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
Signature · 1 line
2.15.1
PATCH 1/4 serial: pch_uart: Delete an error message for a failed memory allocation in dma_handle_tx()
From: Markus Elfring <[email protected]>
Date: Fri, 8 Dec 2017 18:28:20 +0100
Omit an extra message for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
--- drivers/tty/serial/pch_uart.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/tty/serial/pch_uart.c +1 -3
@@ -992,10 +992,8 @@ static unsigned int dma_handle_tx(struct eg20t_port *priv) priv->tx_dma_use =1 ; priv->sg_tx_p =kzalloc (sizeof (struct scatterlist )*num,GFP_ATOMIC ); -if (!priv->sg_tx_p) { -dev_err (priv->port.dev,"%s:kzalloc Failed\n" , __func__); +if (!priv->sg_tx_p)return 0 ; - }sg_init_table (priv->sg_tx_p, num);/* Initialize SG table */ sg = priv->sg_tx_p;
Signature · 1 line
2.15.1
PATCH 2/4 serial: pch_uart: Use kcalloc() in dma_handle_tx()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 8 Dec 2017 18:38:15 +0100
* A multiplication for the size determination of a memory allocation indicated that an array data structure should be processed. Thus use the corresponding function "kcalloc".
This issue was detected by using the Coccinelle software.
* Replace the specification of a data structure by a pointer dereference to make the corresponding size determination a bit safer according to the Linux coding style convention.
--- drivers/tty/serial/pch_uart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/pch_uart.c +1 -1
@@ -991,7 +991,7 @@ static unsigned int dma_handle_tx(struct eg20t_port *priv) priv->tx_dma_use =1 ; - priv->sg_tx_p =kzalloc (sizeof (struct scatterlist )*num,GFP_ATOMIC ); + priv->sg_tx_p =kcalloc (num,sizeof (*priv->sg_tx_p),GFP_ATOMIC );if (!priv->sg_tx_p)return 0 ;
Signature · 1 line
2.15.1
PATCH 3/4 serial: pch_uart: Delete an unnecessary return statement in two functions
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 8 Dec 2017 18:48:10 +0100
The script "checkpatch.pl" pointed information out like the following.
WARNING: void function return statements are not generally useful
Thus remove such a statement in the affected functions.
--- drivers/tty/serial/pch_uart.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/tty/serial/pch_uart.c +1 -3
@@ -693,8 +693,6 @@ static void pch_free_dma(struct uart_port *port) priv->rx_buf_virt =NULL ; priv->rx_buf_dma =0 ; } - -return ; }static bool filter (struct dma_chan *chan,void *slave)
@@ -1861,8 +1859,8 @@ static void pch_uart_pci_remove(struct pci_dev *pdev)pch_uart_exit_port (priv);pci_disable_device (pdev);kfree (priv); -return ; } +#ifdef CONFIG_PM static int pch_uart_pci_suspend (struct pci_dev *pdev,pm_message_t state) {
Signature · 1 line
2.15.1
PATCH 4/4 serial: pch_uart: Improve a size determination in pch_uart_init_port()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 8 Dec 2017 18:53:21 +0100
Replace the specification of a data structure by a pointer dereference as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention.
This issue was detected by using the Coccinelle software.
--- drivers/tty/serial/pch_uart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/pch_uart.c +1 -1
@@ -1747,7 +1747,7 @@ static struct eg20t_port *pch_uart_init_port(struct pci_dev *pdev, board = &drv_dat[id->driver_data]; port_type = board->port_type; - priv =kzalloc (sizeof (struct eg20t_port ),GFP_KERNEL ); + priv =kzalloc (sizeof (*priv),GFP_KERNEL );if (priv =NULL ) goto init_port_alloc_err;
Signature · 1 line
2.15.1