[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201203030846.51669-1-pmalani@chromium.org>
Date: Wed, 2 Dec 2020 19:08:47 -0800
From: Prashant Malani <pmalani@...omium.org>
To: linux-usb@...r.kernel.org, gregkh@...uxfoundation.org,
heikki.krogerus@...ux.intel.com
Cc: bleung@...omium.org, Prashant Malani <pmalani@...omium.org>,
Jonathan Corbet <corbet@....net>,
linux-doc@...r.kernel.org (open list:DOCUMENTATION),
linux-kernel@...r.kernel.org (open list)
Subject: [PATCH] usb: typec: Add bus type for plug alt modes
Add the Type C bus for plug alternate modes which are being
registered via the Type C connector class. This ensures that udev events
get generated when plug alternate modes are registered (and not just for
partner/port alternate modes), even though the Type C bus doesn't link
plug alternate mode devices to alternate mode drivers.
Update the Type C bus documentation to mention that there
are alternate mode devices for plugs as well.
Signed-off-by: Prashant Malani <pmalani@...omium.org>
Cc: Heikki Krogerus <heikki.krogerus@...ux.intel.com>
---
Documentation/driver-api/usb/typec_bus.rst | 6 +++---
drivers/usb/typec/class.c | 8 ++++++--
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/Documentation/driver-api/usb/typec_bus.rst b/Documentation/driver-api/usb/typec_bus.rst
index 21c890ae17e5..7874d2f37d9f 100644
--- a/Documentation/driver-api/usb/typec_bus.rst
+++ b/Documentation/driver-api/usb/typec_bus.rst
@@ -15,9 +15,9 @@ modes by using the SVID and the mode number.
:ref:`USB Type-C Connector Class <typec>` provides a device for every alternate
mode a port supports, and separate device for every alternate mode the partner
-supports. The drivers for the alternate modes are bound to the partner alternate
-mode devices, and the port alternate mode devices must be handled by the port
-drivers.
+or cable plug supports. The drivers for the alternate modes are bound to the
+partner alternate mode devices, and the port alternate mode devices must be
+handled by the port drivers.
When a new partner alternate mode device is registered, it is linked to the
alternate mode device of the port that the partner is attached to, that has
diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
index 35eec707cb51..74061a699f16 100644
--- a/drivers/usb/typec/class.c
+++ b/drivers/usb/typec/class.c
@@ -478,8 +478,12 @@ typec_register_altmode(struct device *parent,
if (!is_port)
typec_altmode_set_partner(alt);
- /* The partners are bind to drivers */
- if (is_typec_partner(parent))
+ /*
+ * The partners are bind to drivers.
+ * Also set the bus field for plug alt modes so that the udev event occurs on device
+ * registration.
+ */
+ if (is_typec_partner(parent) || is_typec_plug(parent))
alt->adev.dev.bus = &typec_bus;
ret = device_register(&alt->adev.dev);
--
2.29.2.454.gaff20da3a2-goog
Powered by blists - more mailing lists