]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
usb: typec: ucsi: Only assign the identity structure if the PPM supports it
authorHeikki Krogerus <heikki.krogerus@linux.intel.com>
Fri, 16 Aug 2024 13:58:56 +0000 (16:58 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 23 Aug 2024 10:47:38 +0000 (18:47 +0800)
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>
Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
Link: https://lore.kernel.org/r/20240816135859.3499351-4-heikki.krogerus@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/typec/ucsi/ucsi.c

index 250bd20f2cd9a96b55ff2813a688c9a6b1fce205..4c128c2342f3b0f557ae25fcc8380d58b4458c7b 100644 (file)
@@ -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);