Skip to contentSkip to conversation

usb: typec: anx7411: Fix wrong pointer passed to PTR_ERR()

PATCH New Yang Yingliang 1 participant 3 messages Jul 21, 2022

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

PATCH 1/3 usb: typec: anx7411: Fix wrong pointer passed to PTR_ERR()

It should be 'ctx->typec.amode[i]' passed to PTR_ERR() when typec_partner_register_altmode() failed.

Fixes fe6d8a9c8e64 ("usb: typec: anx7411: Add Analogix PD ANX7411 support")
---
 drivers/usb/typec/anx7411.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/typec/anx7411.c +3 -1
index b990376991f8..1ffab17a9b17 100644
@@ -549,6 +549,7 @@ static int anx7411_typec_register_altmode(struct anx7411_data *ctx,
 {
 	struct device *dev = &ctx->spi_client->dev;
 	struct typec_altmode_desc desc;
+	int err;
 	int i;
 
 	desc.svid = svid;
@@ -569,8 +570,9 @@ static int anx7411_typec_register_altmode(struct anx7411_data *ctx,
 							     &desc);
 	if (IS_ERR(ctx->typec.amode[i])) {
 		dev_err(dev, "failed to register altmode\n");
+		err = PTR_ERR(ctx->typec.amode[i]);
 		ctx->typec.amode[i] = NULL;
-		return PTR_ERR(ctx->typec.amode);
+		return err;
 	}
 
 	return 0;
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/3 usb: typec: anx7411: Fix return value check in anx7411_register_i2c_dummy_clients()

If i2c_new_dummy_device() fails, it never return NULL pointer, replace NULL test with IS_ERR() to fix it.

Fixes fe6d8a9c8e64 ("usb: typec: anx7411: Add Analogix PD ANX7411 support")
---
 drivers/usb/typec/anx7411.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/typec/anx7411.c +1 -1
index 1ffab17a9b17..4816f5d24ac3 100644
@@ -999,7 +999,7 @@ static int anx7411_register_i2c_dummy_clients(struct anx7411_data *ctx,
 			spi_addr = anx7411_i2c_addr[i].spi_address >> 1;
 			ctx->spi_client = i2c_new_dummy_device(client->adapter,
 							       spi_addr);
-			if (ctx->spi_client)
+			if (!IS_ERR(ctx->spi_client))
 				return 0;
 		}
 	}
Signature · 1 line
2.25.1
#2 lore raw

PATCH 3/3 usb: typec: anx7411: Fix error return code in anx7411_i2c_probe()

In reply to Yang Yingliang

Add mising error return code when failed to get interrupt or failed to register psy.

Fixes fe6d8a9c8e64 ("usb: typec: anx7411: Add Analogix PD ANX7411 support")
---
 drivers/usb/typec/anx7411.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/typec/anx7411.c +3 -1
index 4816f5d24ac3..c4041fd52be9 100644
@@ -1483,12 +1483,14 @@ static int anx7411_i2c_probe(struct i2c_client *client,
 
 	if (!plat->intp_irq) {
 		dev_err(dev, "fail to get interrupt IRQ\n");
+		ret = -EINVAL;
 		goto free_typec_port;
 	}
 
 	plat->dev = dev;
 	plat->psy_online = ANX7411_PSY_OFFLINE;
-	if (anx7411_psy_register(plat)) {
+	ret = anx7411_psy_register(plat);
+	if (ret) {
 		dev_err(dev, "register psy\n");
 		goto free_typec_port;
 	}
Signature · 1 line
2.25.1