Add a helper to match the device name

Cc: Alessandro Zummo <[email protected]>
Cc: Alexander Aring <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Alexandre Belloni <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Dan Murphy <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Harald Freudenberger <[email protected]>
Cc: Heikki Krogerus <[email protected]>
Cc: Heiko Carstens <[email protected]>
Cc: Jacek Anaszewski <[email protected]>
Cc: Lee Jones <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: Martin Schwidefsky <[email protected]>
Cc: Maxime Coquelin <[email protected]>
Cc: Pavel Machek <[email protected]>
Cc: Peter Oberparleiter <[email protected]>
Cc: "Rafael J. Wysocki" <[email protected]>
Cc: Stefan Schmidt <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: "Rafael J. Wysocki" <[email protected]>
Signed-off-by: Suzuki K Poulose <[email protected]>
---
 drivers/base/core.c    | 6 ++++++
 include/linux/device.h | 1 +
 2 files changed, 7 insertions(+)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index 597095b..5724f93 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -3352,3 +3352,9 @@ int device_match_acpi_dev(struct device *dev, const void 
*adev)
        return ACPI_COMPANION(dev) == adev;
 }
 EXPORT_SYMBOL(device_match_acpi_dev);
+
+int device_match_name(struct device *dev, const void *name)
+{
+       return sysfs_streq(dev_name(dev), name);
+}
+EXPORT_SYMBOL_GPL(device_match_name);
diff --git a/include/linux/device.h b/include/linux/device.h
index a03b50d..74dd9c6 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -167,6 +167,7 @@ int device_match_of_node(struct device *dev, const void 
*np);
 int device_match_fwnode(struct device *dev, const void *fwnode);
 int device_match_devt(struct device *dev, const void *pdevt);
 int device_match_acpi_dev(struct device *dev, const void *adev);
+int device_match_name(struct device *dev, const void *name);
 
 int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data,
                     int (*fn)(struct device *dev, void *data));
-- 
2.7.4

Reply via email to