tty/serial/ioc3: Adjustments for three function implementations
Subsystems (2)
cover tty/serial/ioc3: Adjustments for three function implementations
From: Markus Elfring <[email protected]>
Date: Sat, 9 Dec 2017 19:00:19 +0100
Three update suggestions were taken into account
from static source code analysis.
Markus Elfring (3):
Delete error messages for a failed memory allocation in ioc3uart_probe() Improve size determinations in ioc3uart_probe()
Adjust two function calls together with a variable assignment
drivers/tty/serial/ioc3_serial.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-)
Signature · 1 line
2.15.1
PATCH 1/3 serial: ioc3: Delete error messages for a failed memory allocation in ioc3uart_probe()
From: Markus Elfring <[email protected]>
Date: Sat, 9 Dec 2017 18:34:36 +0100
Omit extra messages for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
--- drivers/tty/serial/ioc3_serial.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/tty/serial/ioc3_serial.c +2 -6
@@ -2017,11 +2017,9 @@ ioc3uart_probe(struct ioc3_submodule *is, struct ioc3_driver_data *idd)DPRINT_CONFIG (("%s (0x%p, 0x%p)\n" , __func__, is, idd)); card_ptr =kzalloc (sizeof (struct ioc3_card ),GFP_KERNEL ); -if (!card_ptr) { -printk (KERN_WARNING "ioc3_attach_one" -": unable to get memory for the IOC3\n" ); +if (!card_ptr)return -ENOMEM ; - } + idd->data[is->id] = card_ptr; Submodule_slot = is->id;
@@ -2038,8 +2036,6 @@ ioc3uart_probe(struct ioc3_submodule *is, struct ioc3_driver_data *idd)for (phys_port =0 ; phys_port <PORTS_PER_CARD ; phys_port++) { port =kzalloc (sizeof (struct ioc3_port ),GFP_KERNEL );if (!port) { -printk (KERN_WARNING -"IOC3 serial memory not available for port\n" ); ret = -ENOMEM ; goto out4; }
Signature · 1 line
2.15.1
PATCH 2/3 serial: ioc3: Improve size determinations in ioc3uart_probe()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 9 Dec 2017 18:38:13 +0100
Replace the specification of two data structures by pointer dereferences 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/ioc3_serial.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/serial/ioc3_serial.c +2 -2
@@ -2016,7 +2016,7 @@ ioc3uart_probe(struct ioc3_submodule *is, struct ioc3_driver_data *idd)DPRINT_CONFIG (("%s (0x%p, 0x%p)\n" , __func__, is, idd)); - card_ptr =kzalloc (sizeof (struct ioc3_card ),GFP_KERNEL ); + card_ptr =kzalloc (sizeof (*card_ptr),GFP_KERNEL );if (!card_ptr)return -ENOMEM ;
@@ -2034,7 +2034,7 @@ ioc3uart_probe(struct ioc3_submodule *is, struct ioc3_driver_data *idd)/* Create port structures for each port */ for (phys_port =0 ; phys_port <PORTS_PER_CARD ; phys_port++) { - port =kzalloc (sizeof (struct ioc3_port ),GFP_KERNEL ); + port =kzalloc (sizeof (*port),GFP_KERNEL );if (!port) { ret = -ENOMEM ; goto out4;
Signature · 1 line
2.15.1
PATCH 3/3 serial: ioc3: Adjust two function calls together with a variable assignment
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 9 Dec 2017 18:48:57 +0100
The script "checkpatch.pl" pointed information out like the following.
ERROR: do not use assignment in if condition
Thus fix the affected source code places.
--- drivers/tty/serial/ioc3_serial.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/tty/serial/ioc3_serial.c +5 -5
@@ -1540,8 +1540,8 @@ ioc3uart_intr_one(struct ioc3_submodule *is,* hasn't been delivered to the cpu yet anyway, even * though we see it as asserted when we read the sio_ir. */ -if ((sio_ir =PENDING (card_ptr, idd)) - & hooks->intr_rx_high) { + sio_ir =PENDING (card_ptr, idd); +if (sio_ir & hooks->intr_rx_high) {if (port->ip_flags &READ_ABORTED ) { rx_high_rd_aborted++; }
@@ -2162,10 +2162,10 @@ static struct ioc3_submodule ioc3uart_ops = {*/ static int __init ioc3uart_init (void ) { -int ret; -/* register with serial core */ -if ((ret =uart_register_driver (&ioc3_uart)) <0 ) { +int ret =uart_register_driver (&ioc3_uart); + +if (ret <0 ) {printk (KERN_WARNING "%s: Couldn't register IOC3 uart serial driver\n" , __func__);
Signature · 1 line
2.15.1