diff mbox series

[v2,05/11] usb: typec: ucsi: simplify partner's PD caps registration

Message ID 20240329-qcom-ucsi-fixes-v2-5-0f5d37ed04db@linaro.org
State New
Headers show
Series usb: typec: ucsi: fix several issues manifesting on Qualcomm platforms | expand

Commit Message

Dmitry Baryshkov March 29, 2024, 6:15 a.m. UTC
In a way similar to the previous commit, move
typec_partner_set_usb_power_delivery() to be called after reading the PD
caps. This also removes calls to
usb_power_delivery_unregister_capabilities() from the error path. Keep
all capabilities registered until they are cleared by
ucsi_unregister_partner_pdos().

Fixes: b04e1747fbcc ("usb: typec: ucsi: Register USB Power Delivery Capabilities")
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
 drivers/usb/typec/ucsi/ucsi.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

Comments

Heikki Krogerus April 2, 2024, 10:40 a.m. UTC | #1
On Fri, Mar 29, 2024 at 08:15:37AM +0200, Dmitry Baryshkov wrote:
> In a way similar to the previous commit, move
> typec_partner_set_usb_power_delivery() to be called after reading the PD
> caps. This also removes calls to
> usb_power_delivery_unregister_capabilities() from the error path. Keep
> all capabilities registered until they are cleared by
> ucsi_unregister_partner_pdos().
> 
> Fixes: b04e1747fbcc ("usb: typec: ucsi: Register USB Power Delivery Capabilities")
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

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

> ---
>  drivers/usb/typec/ucsi/ucsi.c | 14 +-------------
>  1 file changed, 1 insertion(+), 13 deletions(-)
> 
> diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
> index d1a45ce7f660..35366b1a3d78 100644
> --- a/drivers/usb/typec/ucsi/ucsi.c
> +++ b/drivers/usb/typec/ucsi/ucsi.c
> @@ -826,12 +826,6 @@ static int ucsi_register_partner_pdos(struct ucsi_connector *con)
>  			return PTR_ERR(cap);
>  
>  		con->partner_source_caps = cap;
> -
> -		ret = typec_partner_set_usb_power_delivery(con->partner, con->partner_pd);
> -		if (ret) {
> -			usb_power_delivery_unregister_capabilities(con->partner_source_caps);
> -			return ret;
> -		}
>  	}
>  
>  	ret = ucsi_get_pdos(con, TYPEC_SINK, 1, caps.pdo);
> @@ -846,15 +840,9 @@ static int ucsi_register_partner_pdos(struct ucsi_connector *con)
>  			return PTR_ERR(cap);
>  
>  		con->partner_sink_caps = cap;
> -
> -		ret = typec_partner_set_usb_power_delivery(con->partner, con->partner_pd);
> -		if (ret) {
> -			usb_power_delivery_unregister_capabilities(con->partner_sink_caps);
> -			return ret;
> -		}
>  	}
>  
> -	return 0;
> +	return typec_partner_set_usb_power_delivery(con->partner, con->partner_pd);
>  }
>  
>  static void ucsi_unregister_partner_pdos(struct ucsi_connector *con)
> 
> -- 
> 2.39.2
diff mbox series

Patch

diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
index d1a45ce7f660..35366b1a3d78 100644
--- a/drivers/usb/typec/ucsi/ucsi.c
+++ b/drivers/usb/typec/ucsi/ucsi.c
@@ -826,12 +826,6 @@  static int ucsi_register_partner_pdos(struct ucsi_connector *con)
 			return PTR_ERR(cap);
 
 		con->partner_source_caps = cap;
-
-		ret = typec_partner_set_usb_power_delivery(con->partner, con->partner_pd);
-		if (ret) {
-			usb_power_delivery_unregister_capabilities(con->partner_source_caps);
-			return ret;
-		}
 	}
 
 	ret = ucsi_get_pdos(con, TYPEC_SINK, 1, caps.pdo);
@@ -846,15 +840,9 @@  static int ucsi_register_partner_pdos(struct ucsi_connector *con)
 			return PTR_ERR(cap);
 
 		con->partner_sink_caps = cap;
-
-		ret = typec_partner_set_usb_power_delivery(con->partner, con->partner_pd);
-		if (ret) {
-			usb_power_delivery_unregister_capabilities(con->partner_sink_caps);
-			return ret;
-		}
 	}
 
-	return 0;
+	return typec_partner_set_usb_power_delivery(con->partner, con->partner_pd);
 }
 
 static void ucsi_unregister_partner_pdos(struct ucsi_connector *con)