Skip to contentSkip to conversation

usb: typec: Add class for plug alt mode device

PATCH In review Prashant Malani 3 participants 3 messages Dec 10, 2020 – Dec 11, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 usb: typec: Add class for plug alt mode device

Add the Type C class for plug alternate mode devices which are being registered by the Type C connector class. This ensures that udev events get generated when the plug alt modes are registered.

---

Changes in v2:
- Changed code to set the class member instead of bus.
- Removed the alteration to typec_bus.rst since it's not longer required.
- Updated the commit message and subject to reflect the change in code.

v1: https://lore.kernel.org/linux-usb/[email protected]/

 drivers/usb/typec/class.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/usb/typec/class.c +4 -0
index 35eec707cb51..29d05b45cc9d 100644
@@ -482,6 +482,10 @@ typec_register_altmode(struct device *parent,
 	if (is_typec_partner(parent))
 		alt->adev.dev.bus = &typec_bus;
 
+	/* Plug alt modes need a class to generate udev events. */
+	if (is_typec_plug(parent))
+		alt->adev.dev.class = typec_class;
+
 	ret = device_register(&alt->adev.dev);
 	if (ret) {
 		dev_err(parent, "failed to register alternate mode (%d)\n",
Signature · 1 line
2.29.2.576.ga3fc446d84-goog
Reviewed-by on v2 1/1
#1 lore raw

Hi Prashant,

Quoted 6 lines · Prashant Malani

Add the Type C class for plug alternate mode devices which are being registered by the Type C connector class. This ensures that udev events get generated when the plug alt modes are registered.

Quoted 31 lines

---

Changes in v2:
- Changed code to set the class member instead of bus.
- Removed the alteration to typec_bus.rst since it's not longer required.
- Updated the commit message and subject to reflect the change in code.

v1: https://lore.kernel.org/linux-usb/[email protected]/

 drivers/usb/typec/class.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/usb/typec/class.c +4 -0
index 35eec707cb51..29d05b45cc9d 100644
@@ -482,6 +482,10 @@ typec_register_altmode(struct device *parent,
 	if (is_typec_partner(parent))
 		alt->adev.dev.bus = &typec_bus;
 
+	/* Plug alt modes need a class to generate udev events. */
+	if (is_typec_plug(parent))
+		alt->adev.dev.class = typec_class;
+
 	ret = device_register(&alt->adev.dev);
 	if (ret) {
 		dev_err(parent, "failed to register alternate mode (%d)\n",
Signature · 1 line
2.29.2.576.ga3fc446d84-goog
Signature · 7 lines
Benson Leung
Staff Software Engineer
Chrome OS Kernel
Google Inc.
[email protected]
Chromium OS Project
[email protected]
maintainer Reviewed-by on v2 1/1
#2 lore raw
In reply to Prashant Malani
Quoted 6 lines · Prashant Malani

Add the Type C class for plug alternate mode devices which are being registered by the Type C connector class. This ensures that udev events get generated when the plug alt modes are registered.

Quoted 30 lines

---

Changes in v2:
- Changed code to set the class member instead of bus.
- Removed the alteration to typec_bus.rst since it's not longer required.
- Updated the commit message and subject to reflect the change in code.

v1: https://lore.kernel.org/linux-usb/[email protected]/

 drivers/usb/typec/class.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/usb/typec/class.c +4 -0
index 35eec707cb51..29d05b45cc9d 100644
@@ -482,6 +482,10 @@ typec_register_altmode(struct device *parent,
 	if (is_typec_partner(parent))
 		alt->adev.dev.bus = &typec_bus;
 
+	/* Plug alt modes need a class to generate udev events. */
+	if (is_typec_plug(parent))
+		alt->adev.dev.class = typec_class;
+
 	ret = device_register(&alt->adev.dev);
 	if (ret) {
 		dev_err(parent, "failed to register alternate mode (%d)\n",
Signature · 1 line
2.29.2.576.ga3fc446d84-goog

thanks,

Signature · 1 line
heikki