usb: typec: ucsi: add update_connector callback
authorDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Thu, 11 Apr 2024 04:49:56 +0000 (07:49 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 Apr 2024 14:47:24 +0000 (16:47 +0200)
Add a callback to allow glue drivers to update the connector before
registering corresponding power supply and Type-C port. In particular
this is useful if glue drivers want to touch the connector's Type-C
capabilities structure.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20240411-ucsi-orient-aware-v2-4-d4b1cb22a33f@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/typec/ucsi/ucsi.c
drivers/usb/typec/ucsi/ucsi.h

index 4d8910992a574d708e77ee4e19814572d4154df7..b8d56a443531f462b42a2d1338c23731c1bfaf37 100644 (file)
@@ -1561,6 +1561,9 @@ static int ucsi_register_port(struct ucsi *ucsi, struct ucsi_connector *con)
        cap->driver_data = con;
        cap->ops = &ucsi_ops;
 
+       if (ucsi->ops->update_connector)
+               ucsi->ops->update_connector(con);
+
        ret = ucsi_register_port_psy(con);
        if (ret)
                goto out;
index 3e1241e38f3c43c57d99d76d641b28dda7bfac19..c4d103db9d0f857a4b3ee327c5f93fbe17f38926 100644 (file)
@@ -60,6 +60,7 @@ struct dentry;
  * @sync_write: Blocking write operation
  * @async_write: Non-blocking write operation
  * @update_altmodes: Squashes duplicate DP altmodes
+ * @update_connector: Update connector capabilities before registering
  * @connector_status: Updates connector status, called holding connector lock
  *
  * Read and write routines for UCSI interface. @sync_write must wait for the
@@ -75,6 +76,7 @@ struct ucsi_operations {
                           const void *val, size_t val_len);
        bool (*update_altmodes)(struct ucsi *ucsi, struct ucsi_altmode *orig,
                                struct ucsi_altmode *updated);
+       void (*update_connector)(struct ucsi_connector *con);
        void (*connector_status)(struct ucsi_connector *con);
 };