Skip to contentSkip to conversation

usb: typec: stusb160x: fix an IS_ERR() vs NULL check in probe

PATCH Applied Dan Carpenter 4 participants 6 messages Oct 23, 2020 – Oct 28, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 usb: typec: stusb160x: fix an IS_ERR() vs NULL check in probe

The typec_register_port() function doesn't return error pointers, it returns error pointers.

Fixes da0cb6310094 ("usb: typec: add support for STUSB160x Type-C controller family")
---
 drivers/usb/typec/stusb160x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/typec/stusb160x.c +2 -2
index ce0bd7b3ad88..f7369e371dd4 100644
@@ -729,8 +729,8 @@ static int stusb160x_probe(struct i2c_client *client)
 	}
 
 	chip->port = typec_register_port(chip->dev, &chip->capability);
-	if (!chip->port) {
-		ret = -ENODEV;
+	if (IS_ERR(chip->port)) {
+		ret = PTR_ERR(chip->port);
 		goto all_reg_disable;
 	}
 
Signature · 1 line
2.28.0
#1 lore raw

PATCH v2 1/2 usb: typec: stusb160x: fix an IS_ERR() vs NULL check in probe

The typec_register_port() function doesn't return NULL, it returns error pointers.

Fixes da0cb6310094 ("usb: typec: add support for STUSB160x Type-C controller family")

---
v2: Fix a typo in the commit message. s/return error pointers/return NULL/.
Thanks, Walter!

 drivers/usb/typec/stusb160x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/typec/stusb160x.c +2 -2
index ce0bd7b3ad88..f7369e371dd4 100644
@@ -729,8 +729,8 @@ static int stusb160x_probe(struct i2c_client *client)
 	}
 
 	chip->port = typec_register_port(chip->dev, &chip->capability);
-	if (!chip->port) {
-		ret = -ENODEV;
+	if (IS_ERR(chip->port)) {
+		ret = PTR_ERR(chip->port);
 		goto all_reg_disable;
 	}
 
Signature · 1 line
2.28.0
maintainer Reviewed-by on v2 1/2
#2 lore raw
Quoted 5 lines · Dan Carpenter

The typec_register_port() function doesn't return NULL, it returns error pointers.

Fixes da0cb6310094 ("usb: typec: add support for STUSB160x Type-C controller family")

Ah, sorry. You had already fixed the commit message.

Quoted 24 lines

---
v2: Fix a typo in the commit message. s/return error pointers/return NULL/.
Thanks, Walter!

 drivers/usb/typec/stusb160x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/typec/stusb160x.c +2 -2
index ce0bd7b3ad88..f7369e371dd4 100644
@@ -729,8 +729,8 @@ static int stusb160x_probe(struct i2c_client *client)
 	}
 
 	chip->port = typec_register_port(chip->dev, &chip->capability);
-	if (!chip->port) {
-		ret = -ENODEV;
+	if (IS_ERR(chip->port)) {
+		ret = PTR_ERR(chip->port);
 		goto all_reg_disable;
 	}
 
Signature · 1 line
2.28.0

thanks,

Signature · 1 line
heikki
Reviewed-by on v2 1/2
#3 lore raw
In reply to Dan Carpenter

Hi Dan,

Thanks for the patch!

Quoted 5 lines · Dan Carpenter

The typec_register_port() function doesn't return NULL, it returns error pointers.

Fixes da0cb6310094 ("usb: typec: add support for STUSB160x Type-C controller family")
Quoted 23 lines

---
v2: Fix a typo in the commit message. s/return error pointers/return NULL/.
Thanks, Walter!

  drivers/usb/typec/stusb160x.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/typec/stusb160x.c +2 -2
index ce0bd7b3ad88..f7369e371dd4 100644
@@ -729,8 +729,8 @@ static int stusb160x_probe(struct i2c_client *client)
  	}
 
  	chip->port = typec_register_port(chip->dev, &chip->capability);
-	if (!chip->port) {
-		ret = -ENODEV;
+	if (IS_ERR(chip->port)) {
+		ret = PTR_ERR(chip->port);
  		goto all_reg_disable;
  	}
 
#4 lore raw
In reply to Dan Carpenter

Hello!

Quoted 1 line · Dan Carpenter

The typec_register_port() function doesn't return error pointers, it

s/error/NULL/, maybe? :-)

Quoted 13 lines

returns error pointers.

Fixes da0cb6310094 ("usb: typec: add support for STUSB160x Type-C controller family")
---
 drivers/usb/typec/stusb160x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/typec/stusb160x.c +0 -0
index ce0bd7b3ad88..f7369e371dd4 100644

drivers/usb/typec/stusb160x.c static int stusb160x_probe(struct i2c_client *client) · line 736

Quoted 10 lines
drivers/usb/typec/stusb160x.c +2 -2
@@ -729,8 +729,8 @@ static int stusb160x_probe(struct i2c_client *client)
 	}
 
 	chip->port = typec_register_port(chip->dev, &chip->capability);
-	if (!chip->port) {
-		ret = -ENODEV;
+	if (IS_ERR(chip->port)) {
+		ret = PTR_ERR(chip->port);
 		goto all_reg_disable;
 	}
 

MBR, Sergei

maintainer Reviewed-by on v1 1/2
#5 lore raw
In reply to Dan Carpenter
Quoted 5 lines · Dan Carpenter

The typec_register_port() function doesn't return error pointers, it returns error pointers.

Fixes da0cb6310094 ("usb: typec: add support for STUSB160x Type-C controller family")

You do need to fix the commit message like Sergei pointed out. Otherwise, FWIW:

Quoted 21 lines
---
 drivers/usb/typec/stusb160x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/typec/stusb160x.c +2 -2
index ce0bd7b3ad88..f7369e371dd4 100644
@@ -729,8 +729,8 @@ static int stusb160x_probe(struct i2c_client *client)
 	}
 
 	chip->port = typec_register_port(chip->dev, &chip->capability);
-	if (!chip->port) {
-		ret = -ENODEV;
+	if (IS_ERR(chip->port)) {
+		ret = PTR_ERR(chip->port);
 		goto all_reg_disable;
 	}
 
Signature · 1 line
2.28.0

thanks,

Signature · 1 line
heikki