diff mbox

[PATCH/RFC,06/11] usb: common: roles: Allow if the parent dev_name matches

Message ID 1524039005-30618-7-git-send-email-yoshihiro.shimoda.uh@renesas.com (mailing list archive)
State New, archived
Headers show

Commit Message

Yoshihiro Shimoda April 18, 2018, 8:10 a.m. UTC
THis patch adds a condition in __switch_match() to allow if
the parent dev_name matches. Otherwise, OF environment cannot match
the usb role switch devices because the usb role switch framework
adds the names of a new child device as the parent dev_name with
"-role-switch".

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/usb/common/roles.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/drivers/usb/common/roles.c b/drivers/usb/common/roles.c
index cc1c55a..381259c 100644
--- a/drivers/usb/common/roles.c
+++ b/drivers/usb/common/roles.c
@@ -88,7 +88,13 @@  enum usb_role usb_role_switch_get_role(struct usb_role_switch *sw)
 
 static int __switch_match(struct device *dev, const void *name)
 {
-	return !strcmp((const char *)name, dev_name(dev));
+	int ret = !strcmp((const char *)name, dev_name(dev));
+
+	/* If doesn't match, this also checks the parent dev_name */
+	if (!ret && dev->parent)
+		ret = !strcmp((const char *)name, dev_name(dev->parent));
+
+	return ret;
 }
 
 static void *usb_role_switch_match(struct device_connection *con, int ep,