tty/serial/ifx6x60: Adjustments for five function implementations
Subsystems (2)
cover tty/serial/ifx6x60: Adjustments for five function implementations
From: Markus Elfring <[email protected]>
Date: Sat, 9 Dec 2017 20:03:45 +0100
Three update suggestions were taken into account
from static source code analysis.
Markus Elfring (3):
Delete an error message for a failed memory allocation in ifx_spi_spi_probe() Improve a size determination in ifx_spi_spi_probe()
Add some spaces for better code readability
drivers/tty/serial/ifx6x60.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-)
Signature · 1 line
2.15.1
PATCH 1/3 serial: ifx6x60: Delete an error message for a failed memory allocation in ifx_spi_spi_probe()
From: Markus Elfring <[email protected]>
Date: Sat, 9 Dec 2017 19:20:37 +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/ifx6x60.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/tty/serial/ifx6x60.c +2 -3
@@ -1006,10 +1006,9 @@ static int ifx_spi_spi_probe(struct spi_device *spi)/* initialize structure to hold our device variables */ ifx_dev =kzalloc (sizeof (struct ifx_spi_device ),GFP_KERNEL ); -if (!ifx_dev) { -dev_err (&spi->dev,"spi device allocation failed" ); +if (!ifx_dev)return -ENOMEM ; - } + saved_ifx_dev = ifx_dev; ifx_dev->spi_dev = spi;clear_bit (IFX_SPI_STATE_IO_IN_PROGRESS , &ifx_dev->flags);
Signature · 1 line
2.15.1
PATCH 2/3 serial: ifx6x60: Improve a size determination in ifx_spi_spi_probe()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 9 Dec 2017 19:22:50 +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/ifx6x60.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/ifx6x60.c +1 -1
@@ -1005,7 +1005,7 @@ static int ifx_spi_spi_probe(struct spi_device *spi) }/* initialize structure to hold our device variables */ - ifx_dev =kzalloc (sizeof (struct ifx_spi_device ),GFP_KERNEL ); + ifx_dev =kzalloc (sizeof (*ifx_dev),GFP_KERNEL );if (!ifx_dev)return -ENOMEM ;
Signature · 1 line
2.15.1
PATCH 3/3 serial: ifx6x60: Add some spaces for better code readability
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 9 Dec 2017 19:55:31 +0100
Use space characters at some source code places according to the Linux coding style convention.
--- drivers/tty/serial/ifx6x60.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/tty/serial/ifx6x60.c +7 -7
@@ -248,8 +248,8 @@ static void mrdy_assert(struct ifx_spi_device *ifx_dev)if (!val) {if (!test_and_set_bit (IFX_SPI_STATE_TIMER_PENDING , &ifx_dev->flags)) { -mod_timer (&ifx_dev->spi_timer,jiffies +IFX_SPI_TIMEOUT_SEC *HZ ); - +mod_timer (&ifx_dev->spi_timer, + jiffies +IFX_SPI_TIMEOUT_SEC *HZ ); } }ifx_spi_power_state_set (ifx_dev,IFX_SPI_POWER_DATA_PENDING );
@@ -378,7 +378,7 @@ static int ifx_spi_decode_spi_header(unsigned char *buffer, int *length,u16 *in_buffer = (u16 *)buffer; h1 = *in_buffer; - h2 = *(in_buffer+1 ); + h2 = *(in_buffer +1 );if (h1 =0 && h2 =0 ) { *received_cts =0 ;
@@ -410,7 +410,7 @@ static void ifx_spi_setup_spi_header(unsigned char *txbuffer, int tx_count, unsigned char more) { *(u16 *)(txbuffer) = tx_count; - *(u16 *)(txbuffer+2 ) =IFX_SPI_PAYLOAD_SIZE ; + *(u16 *)(txbuffer +2 ) =IFX_SPI_PAYLOAD_SIZE ; txbuffer[1 ] |= (more <<IFX_SPI_MORE_BIT ) &IFX_SPI_MORE_MASK ; }
@@ -467,8 +467,8 @@ static int ifx_spi_prepare_tx_buffer(struct ifx_spi_device *ifx_dev)/* have data and info for header -- set up SPI header in buffer */ /* spi header needs payload size, not entire buffer size */ ifx_spi_setup_spi_header (ifx_dev->tx_buffer, - tx_count-IFX_SPI_HEADER_OVERHEAD , - ifx_dev->spi_more); + tx_count -IFX_SPI_HEADER_OVERHEAD , + ifx_dev->spi_more);/* swap actual data in the buffer */ ifx_dev->swap_buf ((ifx_dev->tx_buffer), tx_count, &ifx_dev->tx_buffer[IFX_SPI_TRANSFER_SIZE ]);
@@ -1163,7 +1163,7 @@ static int ifx_spi_spi_probe(struct spi_device *spi) ret =request_irq (gpio_to_irq (ifx_dev->gpio.reset_out), ifx_spi_reset_interrupt, -IRQF_TRIGGER_RISING |IRQF_TRIGGER_FALLING ,DRVNAME , +IRQF_TRIGGER_RISING |IRQF_TRIGGER_FALLING ,DRVNAME , ifx_dev);if (ret) { dev_err(&spi->dev, "Unable to get irq %x\n",
Signature · 1 line
2.15.1