Skip to contentSkip to conversation

usb: typec: fusb302: Use common error handling code in fusb302_probe()

PATCH In review Markus Elfring 2 participants 2 messages Mar 1, 2024 – Mar 12, 2024

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

PATCH 1/1 usb: typec: fusb302: Use common error handling code in fusb302_probe()

From: Markus Elfring <[email protected]>
Date: Fri, 1 Mar 2024 17:00:23 +0100

Add a label so that a bit of exception handling can be better reused at the end of this function implementation.

---
 drivers/usb/typec/tcpm/fusb302.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/typec/tcpm/fusb302.c +2 -2
index ef18a448b740..e1e030da1dec 100644
@@ -1741,10 +1741,9 @@ static int fusb302_probe(struct i2c_client *client)
 
 	chip->tcpm_port = tcpm_register_port(&client->dev, &chip->tcpc_dev);
 	if (IS_ERR(chip->tcpm_port)) {
-		fwnode_handle_put(chip->tcpc_dev.fwnode);
 		ret = dev_err_probe(dev, PTR_ERR(chip->tcpm_port),
 				    "cannot register tcpm port\n");
-		goto destroy_workqueue;
+		goto put_fwnode;
 	}
 
 	ret = request_irq(chip->gpio_int_n_irq, fusb302_irq_intn,
@@ -1761,6 +1760,7 @@ static int fusb302_probe(struct i2c_client *client)
 
 tcpm_unregister_port:
 	tcpm_unregister_port(chip->tcpm_port);
+put_fwnode:
 	fwnode_handle_put(chip->tcpc_dev.fwnode);
 destroy_workqueue:
 	fusb302_debugfs_exit(chip);

--
2.44.0

maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 1 Mar 2024 17:00:23 +0100

Add a label so that a bit of exception handling can be better reused at the end of this function implementation.

Quoted 30 lines
---
 drivers/usb/typec/tcpm/fusb302.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/typec/tcpm/fusb302.c +2 -3
index ef18a448b740..e1e030da1dec 100644
@@ -1741,10 +1741,9 @@ static int fusb302_probe(struct i2c_client *client)
 
 	chip->tcpm_port = tcpm_register_port(&client->dev, &chip->tcpc_dev);
 	if (IS_ERR(chip->tcpm_port)) {
-		fwnode_handle_put(chip->tcpc_dev.fwnode);
 		ret = dev_err_probe(dev, PTR_ERR(chip->tcpm_port),
 				    "cannot register tcpm port\n");
-		goto destroy_workqueue;
+		goto put_fwnode;
 	}
 
 	ret = request_irq(chip->gpio_int_n_irq, fusb302_irq_intn,
@@ -1761,6 +1760,7 @@ static int fusb302_probe(struct i2c_client *client)
 
 tcpm_unregister_port:
 	tcpm_unregister_port(chip->tcpm_port);
+put_fwnode:
 	fwnode_handle_put(chip->tcpc_dev.fwnode);
 destroy_workqueue:
 	fusb302_debugfs_exit(chip);
--

2.44.0

Signature · 1 line
heikki