2024-03-11 17:23:20

by Kyle Tso

[permalink] [raw]
Subject: [PATCH v1] usb: typec: tcpm: Update PD of Type-C port upon pd_set

The PD of Type-C port needs to be updated in pd_set. Unlink the Type-C
port device to the old PD before linking it to a new one.

Fixes: cd099cde4ed2 ("usb: typec: tcpm: Support multiple capabilities")
Cc: [email protected]
Signed-off-by: Kyle Tso <[email protected]>
---
drivers/usb/typec/tcpm/tcpm.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index 3d505614bff1..896f594b9328 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -6907,7 +6907,9 @@ static int tcpm_pd_set(struct typec_port *p, struct usb_power_delivery *pd)

port->port_source_caps = data->source_cap;
port->port_sink_caps = data->sink_cap;
+ typec_port_set_usb_power_delivery(p, NULL);
port->selected_pd = pd;
+ typec_port_set_usb_power_delivery(p, port->selected_pd);
unlock:
mutex_unlock(&port->lock);
return ret;
--
2.44.0.278.ge034bb2e1d-goog



2024-03-12 12:56:53

by Heikki Krogerus

[permalink] [raw]
Subject: Re: [PATCH v1] usb: typec: tcpm: Update PD of Type-C port upon pd_set

On Tue, Mar 12, 2024 at 01:23:06AM +0800, Kyle Tso wrote:
> The PD of Type-C port needs to be updated in pd_set. Unlink the Type-C
> port device to the old PD before linking it to a new one.
>
> Fixes: cd099cde4ed2 ("usb: typec: tcpm: Support multiple capabilities")
> Cc: [email protected]
> Signed-off-by: Kyle Tso <[email protected]>

Acked-by: Heikki Krogerus <[email protected]>

> ---
> drivers/usb/typec/tcpm/tcpm.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index 3d505614bff1..896f594b9328 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -6907,7 +6907,9 @@ static int tcpm_pd_set(struct typec_port *p, struct usb_power_delivery *pd)
>
> port->port_source_caps = data->source_cap;
> port->port_sink_caps = data->sink_cap;
> + typec_port_set_usb_power_delivery(p, NULL);
> port->selected_pd = pd;
> + typec_port_set_usb_power_delivery(p, port->selected_pd);
> unlock:
> mutex_unlock(&port->lock);
> return ret;
> --
> 2.44.0.278.ge034bb2e1d-goog

--
heikki