diff mbox series

[4/4] usb: typec: tipd: Move tps6598x_disconnect error path to its own label

Message ID 20221114174449.34634-4-sven@svenpeter.dev (mailing list archive)
State Accepted
Commit 53a256ea9596ec78a9f5dd51f2b49c2355b15d6e
Headers show
Series [1/4] usb: typec: tipd: Cleanup resources if devm_tps6598_psy_register fails | expand

Commit Message

Sven Peter Nov. 14, 2022, 5:44 p.m. UTC
While the code currently correctly calls tps6598x_disconnect before jumping
to the error cleanup label it's inconsistent compared to all the other cleanup
actions and prone to introduce bugs if any more resources are added.

Signed-off-by: Sven Peter <sven@svenpeter.dev>
---
 drivers/usb/typec/tipd/core.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Heikki Krogerus Nov. 16, 2022, 12:30 p.m. UTC | #1
On Mon, Nov 14, 2022 at 06:44:49PM +0100, Sven Peter wrote:
> While the code currently correctly calls tps6598x_disconnect before jumping
> to the error cleanup label it's inconsistent compared to all the other cleanup
> actions and prone to introduce bugs if any more resources are added.
> 
> Signed-off-by: Sven Peter <sven@svenpeter.dev>

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
>  drivers/usb/typec/tipd/core.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
> index c35501a92b4d..22ff212e05e6 100644
> --- a/drivers/usb/typec/tipd/core.c
> +++ b/drivers/usb/typec/tipd/core.c
> @@ -850,16 +850,16 @@ static int tps6598x_probe(struct i2c_client *client)
>  					irq_handler,
>  					IRQF_SHARED | IRQF_ONESHOT,
>  					dev_name(&client->dev), tps);
> -	if (ret) {
> -		tps6598x_disconnect(tps, 0);
> -		goto err_unregister_port;
> -	}
> +	if (ret)
> +		goto err_disconnect;
>  
>  	i2c_set_clientdata(client, tps);
>  	fwnode_handle_put(fwnode);
>  
>  	return 0;
>  
> +err_disconnect:
> +	tps6598x_disconnect(tps, 0);
>  err_unregister_port:
>  	typec_unregister_port(tps->port);
>  err_role_put:

thanks,
diff mbox series

Patch

diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
index c35501a92b4d..22ff212e05e6 100644
--- a/drivers/usb/typec/tipd/core.c
+++ b/drivers/usb/typec/tipd/core.c
@@ -850,16 +850,16 @@  static int tps6598x_probe(struct i2c_client *client)
 					irq_handler,
 					IRQF_SHARED | IRQF_ONESHOT,
 					dev_name(&client->dev), tps);
-	if (ret) {
-		tps6598x_disconnect(tps, 0);
-		goto err_unregister_port;
-	}
+	if (ret)
+		goto err_disconnect;
 
 	i2c_set_clientdata(client, tps);
 	fwnode_handle_put(fwnode);
 
 	return 0;
 
+err_disconnect:
+	tps6598x_disconnect(tps, 0);
 err_unregister_port:
 	typec_unregister_port(tps->port);
 err_role_put: