[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20220816040527.GA1108868@roeck-us.net>
Date: Mon, 15 Aug 2022 21:05:27 -0700
From: Guenter Roeck <linux@...ck-us.net>
To: Badhri Jagan Sridharan <badhri@...gle.com>
Cc: Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org,
Kyle Tso <kyletso@...gle.com>, stable@...r.kernel.org
Subject: Re: [PATCH v1] usb: typec: tcpm: Return ENOTSUPP for power supply
prop writes
On Mon, Aug 15, 2022 at 08:33:55PM -0700, Badhri Jagan Sridharan wrote:
> When the port does not support USB PD, prevent transition to PD
> only states when power supply property is written. In this case,
> TCPM transitions to SNK_NEGOTIATE_CAPABILITIES
> which should not be the case given that the port is not pd_capable.
>
> [ 84.308251] state change SNK_READY -> SNK_NEGOTIATE_CAPABILITIES [rev3 NONE_AMS]
> [ 84.308335] Setting usb_comm capable false
> [ 84.323367] set_auto_vbus_discharge_threshold mode:3 pps_active:n vbus:5000 ret:0
> [ 84.323376] state change SNK_NEGOTIATE_CAPABILITIES -> SNK_WAIT_CAPABILITIES [rev3 NONE_AMS]
>
> Signed-off-by: Badhri Jagan Sridharan <badhri@...gle.com>
Reviewed-by: Guenter Roeck <linux@...ck-us.net>
> ---
> drivers/usb/typec/tcpm/tcpm.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index ea5a917c51b1..904c7b4ce2f0 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -6320,6 +6320,13 @@ static int tcpm_psy_set_prop(struct power_supply *psy,
> struct tcpm_port *port = power_supply_get_drvdata(psy);
> int ret;
>
> + /*
> + * All the properties below are related to USB PD. The check needs to be
> + * property specific when a non-pd related property is added.
> + */
> + if (!port->pd_supported)
> + return -EOPNOTSUPP;
> +
> switch (psp) {
> case POWER_SUPPLY_PROP_ONLINE:
> ret = tcpm_psy_set_online(port, val);
> --
> 2.37.1.595.g718a3a8f04-goog
>
Powered by blists - more mailing lists