* [PATCH 0/3] tty/serial/ioc4: Adjustments for four function implementations
@ 2017-12-08 21:50 ` SF Markus Elfring
0 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2017-12-08 21:50 UTC (permalink / raw)
To: linux-serial, Greg Kroah-Hartman, Jiri Slaby, Pat Gefre
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 8 Dec 2017 22:47:43 +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 two functions
Improve four size determinations
Adjust three function calls together with a variable assignment
drivers/tty/serial/ioc4_serial.c | 33 ++++++++++++++-------------------
1 file changed, 14 insertions(+), 19 deletions(-)
--
2.15.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 0/3] tty/serial/ioc4: Adjustments for four function implementations
@ 2017-12-08 21:50 ` SF Markus Elfring
0 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2017-12-08 21:50 UTC (permalink / raw)
To: linux-serial, Greg Kroah-Hartman, Jiri Slaby, Pat Gefre
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 8 Dec 2017 22:47:43 +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 two functions
Improve four size determinations
Adjust three function calls together with a variable assignment
drivers/tty/serial/ioc4_serial.c | 33 ++++++++++++++-------------------
1 file changed, 14 insertions(+), 19 deletions(-)
--
2.15.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/3] serial: ioc4: Delete error messages for a failed memory allocation in two functions
2017-12-08 21:50 ` SF Markus Elfring
@ 2017-12-08 21:51 ` SF Markus Elfring
-1 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2017-12-08 21:51 UTC (permalink / raw)
To: linux-serial, Greg Kroah-Hartman, Jiri Slaby, Pat Gefre
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 8 Dec 2017 22:15:53 +0100
Omit extra messages for a memory allocation failure in these functions.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/tty/serial/ioc4_serial.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c
index db5b979e5a0c..9524a6d3e1d8 100644
--- a/drivers/tty/serial/ioc4_serial.c
+++ b/drivers/tty/serial/ioc4_serial.c
@@ -1076,11 +1076,9 @@ static inline int ioc4_attach_local(struct ioc4_driver_data *idd)
for (port_number = 0; port_number < IOC4_NUM_SERIAL_PORTS;
port_number++) {
port = kzalloc(sizeof(struct ioc4_port), GFP_KERNEL);
- if (!port) {
- printk(KERN_WARNING
- "IOC4 serial memory not available for port\n");
+ if (!port)
goto free;
- }
+
spin_lock_init(&port->ip_lock);
/* we need to remember the previous ones, to point back to
@@ -2815,8 +2813,6 @@ ioc4_serial_attach_one(struct ioc4_driver_data *idd)
control = kzalloc(sizeof(struct ioc4_control), GFP_KERNEL);
if (!control) {
- printk(KERN_WARNING "ioc4_attach_one"
- ": unable to get memory for the IOC4\n");
ret = -ENOMEM;
goto out2;
}
@@ -2825,9 +2821,6 @@ ioc4_serial_attach_one(struct ioc4_driver_data *idd)
/* Allocate the soft structure */
soft = kzalloc(sizeof(struct ioc4_soft), GFP_KERNEL);
if (!soft) {
- printk(KERN_WARNING
- "ioc4 (%p): unable to get memory for the soft struct\n",
- (void *)idd->idd_pdev);
ret = -ENOMEM;
goto out3;
}
--
2.15.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 1/3] serial: ioc4: Delete error messages for a failed memory allocation in two functions
@ 2017-12-08 21:51 ` SF Markus Elfring
0 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2017-12-08 21:51 UTC (permalink / raw)
To: linux-serial, Greg Kroah-Hartman, Jiri Slaby, Pat Gefre
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 8 Dec 2017 22:15:53 +0100
Omit extra messages for a memory allocation failure in these functions.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/tty/serial/ioc4_serial.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c
index db5b979e5a0c..9524a6d3e1d8 100644
--- a/drivers/tty/serial/ioc4_serial.c
+++ b/drivers/tty/serial/ioc4_serial.c
@@ -1076,11 +1076,9 @@ static inline int ioc4_attach_local(struct ioc4_driver_data *idd)
for (port_number = 0; port_number < IOC4_NUM_SERIAL_PORTS;
port_number++) {
port = kzalloc(sizeof(struct ioc4_port), GFP_KERNEL);
- if (!port) {
- printk(KERN_WARNING
- "IOC4 serial memory not available for port\n");
+ if (!port)
goto free;
- }
+
spin_lock_init(&port->ip_lock);
/* we need to remember the previous ones, to point back to
@@ -2815,8 +2813,6 @@ ioc4_serial_attach_one(struct ioc4_driver_data *idd)
control = kzalloc(sizeof(struct ioc4_control), GFP_KERNEL);
if (!control) {
- printk(KERN_WARNING "ioc4_attach_one"
- ": unable to get memory for the IOC4\n");
ret = -ENOMEM;
goto out2;
}
@@ -2825,9 +2821,6 @@ ioc4_serial_attach_one(struct ioc4_driver_data *idd)
/* Allocate the soft structure */
soft = kzalloc(sizeof(struct ioc4_soft), GFP_KERNEL);
if (!soft) {
- printk(KERN_WARNING
- "ioc4 (%p): unable to get memory for the soft struct\n",
- (void *)idd->idd_pdev);
ret = -ENOMEM;
goto out3;
}
--
2.15.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/3] serial: ioc4: Improve four size determinations
2017-12-08 21:50 ` SF Markus Elfring
@ 2017-12-08 21:52 ` SF Markus Elfring
-1 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2017-12-08 21:52 UTC (permalink / raw)
To: linux-serial, Greg Kroah-Hartman, Jiri Slaby, Pat Gefre
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 8 Dec 2017 22:22:25 +0100
Replace the specification of 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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/tty/serial/ioc4_serial.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c
index 9524a6d3e1d8..6981ad2ca1b7 100644
--- a/drivers/tty/serial/ioc4_serial.c
+++ b/drivers/tty/serial/ioc4_serial.c
@@ -1075,7 +1075,7 @@ static inline int ioc4_attach_local(struct ioc4_driver_data *idd)
/* Create port structures for each port */
for (port_number = 0; port_number < IOC4_NUM_SERIAL_PORTS;
port_number++) {
- port = kzalloc(sizeof(struct ioc4_port), GFP_KERNEL);
+ port = kzalloc(sizeof(*port), GFP_KERNEL);
if (!port)
goto free;
@@ -2797,7 +2797,7 @@ ioc4_serial_attach_one(struct ioc4_driver_data *idd)
ret = -ENODEV;
goto out1;
}
- serial = ioremap(tmp_addr1, sizeof(struct ioc4_serial));
+ serial = ioremap(tmp_addr1, sizeof(*serial));
if (!serial) {
printk(KERN_WARNING
"ioc4 (%p) : unable to remap ioc4 serial register\n",
@@ -2810,8 +2810,7 @@ ioc4_serial_attach_one(struct ioc4_driver_data *idd)
(void *)serial));
/* Get memory for the new card */
- control = kzalloc(sizeof(struct ioc4_control), GFP_KERNEL);
-
+ control = kzalloc(sizeof(*control), GFP_KERNEL);
if (!control) {
ret = -ENOMEM;
goto out2;
@@ -2819,7 +2818,7 @@ ioc4_serial_attach_one(struct ioc4_driver_data *idd)
idd->idd_serial_data = control;
/* Allocate the soft structure */
- soft = kzalloc(sizeof(struct ioc4_soft), GFP_KERNEL);
+ soft = kzalloc(sizeof(*soft), GFP_KERNEL);
if (!soft) {
ret = -ENOMEM;
goto out3;
--
2.15.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/3] serial: ioc4: Improve four size determinations
@ 2017-12-08 21:52 ` SF Markus Elfring
0 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2017-12-08 21:52 UTC (permalink / raw)
To: linux-serial, Greg Kroah-Hartman, Jiri Slaby, Pat Gefre
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 8 Dec 2017 22:22:25 +0100
Replace the specification of 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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/tty/serial/ioc4_serial.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c
index 9524a6d3e1d8..6981ad2ca1b7 100644
--- a/drivers/tty/serial/ioc4_serial.c
+++ b/drivers/tty/serial/ioc4_serial.c
@@ -1075,7 +1075,7 @@ static inline int ioc4_attach_local(struct ioc4_driver_data *idd)
/* Create port structures for each port */
for (port_number = 0; port_number < IOC4_NUM_SERIAL_PORTS;
port_number++) {
- port = kzalloc(sizeof(struct ioc4_port), GFP_KERNEL);
+ port = kzalloc(sizeof(*port), GFP_KERNEL);
if (!port)
goto free;
@@ -2797,7 +2797,7 @@ ioc4_serial_attach_one(struct ioc4_driver_data *idd)
ret = -ENODEV;
goto out1;
}
- serial = ioremap(tmp_addr1, sizeof(struct ioc4_serial));
+ serial = ioremap(tmp_addr1, sizeof(*serial));
if (!serial) {
printk(KERN_WARNING
"ioc4 (%p) : unable to remap ioc4 serial register\n",
@@ -2810,8 +2810,7 @@ ioc4_serial_attach_one(struct ioc4_driver_data *idd)
(void *)serial));
/* Get memory for the new card */
- control = kzalloc(sizeof(struct ioc4_control), GFP_KERNEL);
-
+ control = kzalloc(sizeof(*control), GFP_KERNEL);
if (!control) {
ret = -ENOMEM;
goto out2;
@@ -2819,7 +2818,7 @@ ioc4_serial_attach_one(struct ioc4_driver_data *idd)
idd->idd_serial_data = control;
/* Allocate the soft structure */
- soft = kzalloc(sizeof(struct ioc4_soft), GFP_KERNEL);
+ soft = kzalloc(sizeof(*soft), GFP_KERNEL);
if (!soft) {
ret = -ENOMEM;
goto out3;
--
2.15.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/3] serial: ioc4: Adjust three function calls together with a variable assignment
2017-12-08 21:50 ` SF Markus Elfring
@ 2017-12-08 21:53 ` SF Markus Elfring
-1 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2017-12-08 21:53 UTC (permalink / raw)
To: linux-serial, Greg Kroah-Hartman, Jiri Slaby, Pat Gefre
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 8 Dec 2017 22:40:31 +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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/tty/serial/ioc4_serial.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c
index 6981ad2ca1b7..ba95a4cb8130 100644
--- a/drivers/tty/serial/ioc4_serial.c
+++ b/drivers/tty/serial/ioc4_serial.c
@@ -1945,7 +1945,8 @@ static void handle_intr(void *arg, uint32_t sio_ir)
* 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(port)) & hooks->intr_rx_high) {
+ sio_ir = PENDING(port);
+ if (sio_ir & hooks->intr_rx_high) {
if ((port->ip_flags & READ_ABORTED) == 0) {
port->ip_ienb &= ~hooks->intr_rx_high;
port->ip_flags |= INPUT_HIGH;
@@ -2902,16 +2903,18 @@ static struct ioc4_submodule ioc4_serial_submodule = {
*/
static int __init ioc4_serial_init(void)
{
- int ret;
-
/* register with serial core */
- if ((ret = uart_register_driver(&ioc4_uart_rs232)) < 0) {
+ int ret = uart_register_driver(&ioc4_uart_rs232);
+
+ if (ret < 0) {
printk(KERN_WARNING
"%s: Couldn't register rs232 IOC4 serial driver\n",
__func__);
goto out;
}
- if ((ret = uart_register_driver(&ioc4_uart_rs422)) < 0) {
+
+ ret = uart_register_driver(&ioc4_uart_rs422);
+ if (ret < 0) {
printk(KERN_WARNING
"%s: Couldn't register rs422 IOC4 serial driver\n",
__func__);
--
2.15.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/3] serial: ioc4: Adjust three function calls together with a variable assignment
@ 2017-12-08 21:53 ` SF Markus Elfring
0 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2017-12-08 21:53 UTC (permalink / raw)
To: linux-serial, Greg Kroah-Hartman, Jiri Slaby, Pat Gefre
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 8 Dec 2017 22:40:31 +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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/tty/serial/ioc4_serial.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c
index 6981ad2ca1b7..ba95a4cb8130 100644
--- a/drivers/tty/serial/ioc4_serial.c
+++ b/drivers/tty/serial/ioc4_serial.c
@@ -1945,7 +1945,8 @@ static void handle_intr(void *arg, uint32_t sio_ir)
* 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(port)) & hooks->intr_rx_high) {
+ sio_ir = PENDING(port);
+ if (sio_ir & hooks->intr_rx_high) {
if ((port->ip_flags & READ_ABORTED) = 0) {
port->ip_ienb &= ~hooks->intr_rx_high;
port->ip_flags |= INPUT_HIGH;
@@ -2902,16 +2903,18 @@ static struct ioc4_submodule ioc4_serial_submodule = {
*/
static int __init ioc4_serial_init(void)
{
- int ret;
-
/* register with serial core */
- if ((ret = uart_register_driver(&ioc4_uart_rs232)) < 0) {
+ int ret = uart_register_driver(&ioc4_uart_rs232);
+
+ if (ret < 0) {
printk(KERN_WARNING
"%s: Couldn't register rs232 IOC4 serial driver\n",
__func__);
goto out;
}
- if ((ret = uart_register_driver(&ioc4_uart_rs422)) < 0) {
+
+ ret = uart_register_driver(&ioc4_uart_rs422);
+ if (ret < 0) {
printk(KERN_WARNING
"%s: Couldn't register rs422 IOC4 serial driver\n",
__func__);
--
2.15.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2017-12-08 21:53 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-08 21:50 [PATCH 0/3] tty/serial/ioc4: Adjustments for four function implementations SF Markus Elfring
2017-12-08 21:50 ` SF Markus Elfring
2017-12-08 21:51 ` [PATCH 1/3] serial: ioc4: Delete error messages for a failed memory allocation in two functions SF Markus Elfring
2017-12-08 21:51 ` SF Markus Elfring
2017-12-08 21:52 ` [PATCH 2/3] serial: ioc4: Improve four size determinations SF Markus Elfring
2017-12-08 21:52 ` SF Markus Elfring
2017-12-08 21:53 ` [PATCH 3/3] serial: ioc4: Adjust three function calls together with a variable assignment SF Markus Elfring
2017-12-08 21:53 ` SF Markus Elfring
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.