diff mbox series

[v2,3/6] usb: typec: ucsi: Only assign the identity structure if the PPM supports it

Message ID 20240816135859.3499351-4-heikki.krogerus@linux.intel.com
State New
Headers show
Series usb: typec: ucsi: Minor improvements | expand

Commit Message

Heikki Krogerus Aug. 16, 2024, 1:58 p.m. UTC
This will make sure that the identity sysfs attribute files
are kept hidden if the UCSI interface doesn't support
reading the USB Power Delivery messages.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---
 drivers/usb/typec/ucsi/ucsi.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Abhishek Pandit-Subedi Aug. 19, 2024, 12:04 a.m. UTC | #1
On Fri, Aug 16, 2024 at 6:59 AM Heikki Krogerus
<heikki.krogerus@linux.intel.com> wrote:
>
> This will make sure that the identity sysfs attribute files
> are kept hidden if the UCSI interface doesn't support
> reading the USB Power Delivery messages.
>
> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
>  drivers/usb/typec/ucsi/ucsi.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
> index 96ef099a6f84..1f6e3f0d25c1 100644
> --- a/drivers/usb/typec/ucsi/ucsi.c
> +++ b/drivers/usb/typec/ucsi/ucsi.c
> @@ -979,7 +979,8 @@ static int ucsi_register_cable(struct ucsi_connector *con)
>                 break;
>         }
>
> -       desc.identity = &con->cable_identity;
> +       if (con->ucsi->cap.features & UCSI_CAP_GET_PD_MESSAGE)
> +               desc.identity = &con->cable_identity;
>         desc.active = !!(UCSI_CABLE_PROP_FLAG_ACTIVE_CABLE &
>                          con->cable_prop.flags);
>         desc.pd_revision = UCSI_CABLE_PROP_FLAG_PD_MAJOR_REV_AS_BCD(
> @@ -1058,7 +1059,8 @@ static int ucsi_register_partner(struct ucsi_connector *con)
>         if (pwr_opmode == UCSI_CONSTAT_PWR_OPMODE_PD)
>                 ucsi_register_device_pdos(con);
>
> -       desc.identity = &con->partner_identity;
> +       if (con->ucsi->cap.features & UCSI_CAP_GET_PD_MESSAGE)
> +               desc.identity = &con->partner_identity;
>         desc.usb_pd = pwr_opmode == UCSI_CONSTAT_PWR_OPMODE_PD;
>         desc.pd_revision = UCSI_CONCAP_FLAG_PARTNER_PD_MAJOR_REV_AS_BCD(con->cap.flags);
>
> --
> 2.43.0
>
>

Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
diff mbox series

Patch

diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
index 96ef099a6f84..1f6e3f0d25c1 100644
--- a/drivers/usb/typec/ucsi/ucsi.c
+++ b/drivers/usb/typec/ucsi/ucsi.c
@@ -979,7 +979,8 @@  static int ucsi_register_cable(struct ucsi_connector *con)
 		break;
 	}
 
-	desc.identity = &con->cable_identity;
+	if (con->ucsi->cap.features & UCSI_CAP_GET_PD_MESSAGE)
+		desc.identity = &con->cable_identity;
 	desc.active = !!(UCSI_CABLE_PROP_FLAG_ACTIVE_CABLE &
 			 con->cable_prop.flags);
 	desc.pd_revision = UCSI_CABLE_PROP_FLAG_PD_MAJOR_REV_AS_BCD(
@@ -1058,7 +1059,8 @@  static int ucsi_register_partner(struct ucsi_connector *con)
 	if (pwr_opmode == UCSI_CONSTAT_PWR_OPMODE_PD)
 		ucsi_register_device_pdos(con);
 
-	desc.identity = &con->partner_identity;
+	if (con->ucsi->cap.features & UCSI_CAP_GET_PD_MESSAGE)
+		desc.identity = &con->partner_identity;
 	desc.usb_pd = pwr_opmode == UCSI_CONSTAT_PWR_OPMODE_PD;
 	desc.pd_revision = UCSI_CONCAP_FLAG_PARTNER_PD_MAJOR_REV_AS_BCD(con->cap.flags);