In absence of braces, port and NULL are missed
Subsystems (2)
PATCH 1/1 In absence of braces, port and NULL are missed
--- drivers/tty/serial/vt8500_serial.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/tty/serial/vt8500_serial.c +3 -2
@@ -561,12 +561,13 @@ static int vt8500_serial_probe(struct platform_device *pdev)if (!mmres || !irqres)return -ENODEV ; -if (np) +if (np) { port =of_alias_get_id (np,"serial" );if (port >=VT8500_MAX_PORTS ) port =-1 ; -else + }else { port =-1 ; + }if (port <0 ) {/* calculate the port id */
Signature · 6 lines
1.8.1.2 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
[Adding Tony Prisk and linux-serial]
Hi Roel,
While this looks like a good fix, the commit message is a bit confusing. How about something like the message between the scissor lines below:
---->8----
[PATCH] serial: vt8500: add missing braces
Due to missing braces on an if statement, port will always be assigned -1 regardless of any alias entries in the dt, which was clearly not the intended behaviour.
This patch adds the missing braces, fixing the issue. ---->8----
Also, while this is device tree related, you should Cc the driver maintainer when submitting driver changes.
Cheers,
Mark.
Quoted 33 lines · Roel Kluin
Signed-off-by Roel Kluin <[email protected]>--- drivers/tty/serial/vt8500_serial.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/tty/serial/vt8500_serial.c +3
-2@@ -561,12 +561,13 @@ static int vt8500_serial_probe(struct platform_device *pdev)if (!mmres || !irqres)return -ENODEV ; -if (np) +if (np) { port =of_alias_get_id (np,"serial" );if (port >=VT8500_MAX_PORTS ) port =-1 ; -else + }else { port =-1 ; + }if (port <0 ) {/* calculate the port id */ Signature · 6 lines
1.8.1.2 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Tony Prisk
Acked-byQuoted 52 lines · Mark Rutland
[Adding Tony Prisk and linux-serial]
Hi Roel,
While this looks like a good fix, the commit message is a bit confusing. How about something like the message between the scissor lines below:
---->8----
[PATCH] serial: vt8500: add missing bracesDue to missing braces on an if statement, port will always be assigned -1 regardless of any alias entries in the dt, which was clearly not the intended behaviour.
This patch adds the missing braces, fixing the issue. ---->8----
Also, while this is device tree related, you should Cc the driver maintainer when submitting driver changes.
Cheers,
Mark.Quoted 28 lines · Roel Kluin
Signed-off-by Roel Kluin <[email protected]>--- drivers/tty/serial/vt8500_serial.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/tty/serial/vt8500_serial.c +3
-2@@ -561,12 +561,13 @@ static int vt8500_serial_probe(struct platform_device *pdev)if (!mmres || !irqres)return -ENODEV ; -if (np) +if (np) { port =of_alias_get_id (np,"serial" );if (port >=VT8500_MAX_PORTS ) port =-1 ; -else + }else { port =-1 ; + }if (port <0 ) {/* calculate the port id */ Signature · 1 line
1.8.1.2
Quoted 5 lines
Quoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Nice find and thanks for the fix.
Regards
Tony P
Roel Kluin
Acked-by Tony PriskHi Mark,
Quoted 1 line · Mark Rutland
While this looks like a good fix, the commit message is a bit confusing.
I like your suggestion, however I feel the commit message fails to appreciate the error path this patch addresses as well, so I adapted your suggested commit message to the following:
---
[PATCH] serial: vt8500: add missing braces
Due to missing braces on an if statement, in presence of a device_node a port was always assigned -1, regardless of any alias entries in the device tree. Conversely, if device_node was NULL, an unitialized port ended up being used.
This patch adds the missing braces, fixing the issues.
(quoted diff) +0 -0
b/drivers/tty/serial/vt8500_serial.c
index 93b697a..4cf71c0 100644
drivers/tty/serial/vt8500_serial.c +0 -0
@@ -561,12 +561,13 @@ static int vt8500_serial_probe(struct
platform_device *pdev)
if (!mmres || !irqres)
return -ENODEV;
- if (np)
+ if (np) {
port = of_alias_get_id(np, "serial"); if (port >= VT8500_MAX_PORTS)
port = -1;
- else
+ } else {
port = -1;
+ }
if (port < 0) {
/* calculate the port id */