Skip to contentSkip to conversation

In absence of braces, port and NULL are missed

PATCH In review Roel Kluin 4 participants 4 messages Oct 13, 2013 – Oct 14, 2013

Subsystems (2)
lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

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
index 93b697a..4cf71c0 100644
@@ -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
#1 lore raw

[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
---
 drivers/tty/serial/vt8500_serial.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/tty/serial/vt8500_serial.c +3 -2
index 93b697a..4cf71c0 100644
@@ -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
Acked-by
#2 lore raw
Quoted 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 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 28 lines · Roel Kluin
---
  drivers/tty/serial/vt8500_serial.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
drivers/tty/serial/vt8500_serial.c +3 -2
index 93b697a..4cf71c0 100644
@@ -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

Acked-by Tony Prisk
#3 lore raw
In reply to Mark Rutland

Hi 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 */