[RFC PATCH 33/57] drivers: usb: Use class_find_device_by_name() helper

From: Suzuki K Poulose
Date: Mon Jun 03 2019 - 11:57:36 EST


Use the new class_find_device_by_name() helper.

Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
Cc: Heikki Krogerus <heikki.krogerus@xxxxxxxxxxxxxxx>
Cc: linux-usb@xxxxxxxxxxxxxxx
Signed-off-by: Suzuki K Poulose <suzuki.poulose@xxxxxxx>
---
drivers/usb/roles/class.c | 8 +-------
drivers/usb/typec/class.c | 8 +-------
2 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c
index f45d8df..3dc78cb 100644
--- a/drivers/usb/roles/class.c
+++ b/drivers/usb/roles/class.c
@@ -90,11 +90,6 @@ static int switch_fwnode_match(struct device *dev, const void *fwnode)
return dev_fwnode(dev) == fwnode;
}

-static int switch_name_match(struct device *dev, const void *name)
-{
- return !strcmp((const char *)name, dev_name(dev));
-}
-
static void *usb_role_switch_match(struct device_connection *con, int ep,
void *data)
{
@@ -107,8 +102,7 @@ static void *usb_role_switch_match(struct device_connection *con, int ep,
dev = class_find_device(role_class, NULL, con->fwnode,
switch_fwnode_match);
} else {
- dev = class_find_device(role_class, NULL, con->endpoint[ep],
- switch_name_match);
+ dev = class_find_device_by_name(role_class, NULL, con->endpoint[ep]);
}

return dev ? to_role_switch(dev) : ERR_PTR(-EPROBE_DEFER);
diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
index 2eb6238..c11cc5f 100644
--- a/drivers/usb/typec/class.c
+++ b/drivers/usb/typec/class.c
@@ -210,11 +210,6 @@ static int typec_port_fwnode_match(struct device *dev, const void *fwnode)
return dev_fwnode(dev) == fwnode;
}

-static int typec_port_name_match(struct device *dev, const void *name)
-{
- return !strcmp((const char *)name, dev_name(dev));
-}
-
static void *typec_port_match(struct device_connection *con, int ep, void *data)
{
struct device *dev;
@@ -227,8 +222,7 @@ static void *typec_port_match(struct device_connection *con, int ep, void *data)
return class_find_device(typec_class, NULL, con->fwnode,
typec_port_fwnode_match);

- dev = class_find_device(typec_class, NULL, con->endpoint[ep],
- typec_port_name_match);
+ dev = class_find_device_by_name(typec_class, NULL, con->endpoint[ep]);

return dev ? dev : ERR_PTR(-EPROBE_DEFER);
}
--
2.7.4