Skip to content

Commit 3e63cff

Browse files
0xB0Dgregkh
authored andcommitted
usb: roles: Switch on role-switch uevent reporting
Right now we don't report to user-space a role switch when doing a usb_role_switch_set_role() despite having registered the uevent callbacks. This patch switches on the notifications allowing user-space to see role-switch change notifications and subsequently determine the current controller data-role. example: PFX=/devices/platform/soc/78d9000.usb/ci_hdrc.0 root@somebox# udevadm monitor -p KERNEL[49.894994] change $PFX/usb_role/ci_hdrc.0-role-switch (usb_role) ACTION=change DEVPATH=$PFX/usb_role/ci_hdrc.0-role-switch SUBSYSTEM=usb_role DEVTYPE=usb_role_switch USB_ROLE_SWITCH=ci_hdrc.0-role-switch SEQNUM=2432 Cc: Heikki Krogerus <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: Chunfeng Yun <[email protected]> Cc: Suzuki K Poulose <[email protected]> Cc: Alexandre Belloni <[email protected]> Cc: Wen Yang <[email protected]> Cc: chenqiwu <[email protected]> Cc: [email protected] Signed-off-by: Bryan O'Donoghue <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent b919e07 commit 3e63cff

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/usb/roles/class.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ int usb_role_switch_set_role(struct usb_role_switch *sw, enum usb_role role)
4949
mutex_lock(&sw->lock);
5050

5151
ret = sw->set(sw, role);
52-
if (!ret)
52+
if (!ret) {
5353
sw->role = role;
54+
kobject_uevent(&sw->dev.kobj, KOBJ_CHANGE);
55+
}
5456

5557
mutex_unlock(&sw->lock);
5658

0 commit comments

Comments
 (0)