Add a helper to match the device name

Cc: Alessandro Zummo <a.zu...@towertech.it>
Cc: Alexander Aring <alex.ar...@gmail.com>
Cc: Alexander Shishkin <alexander.shish...@linux.intel.com>
Cc: Alexandre Belloni <alexandre.bell...@bootlin.com>
Cc: Arnd Bergmann <a...@arndb.de>
Cc: Dan Murphy <dmur...@ti.com>
Cc: Greg Kroah-Hartman <gre...@linuxfoundation.org>
Cc: Harald Freudenberger <fre...@linux.ibm.com>
Cc: Heikki Krogerus <heikki.kroge...@linux.intel.com>
Cc: Heiko Carstens <heiko.carst...@de.ibm.com>
Cc: Jacek Anaszewski <jacek.anaszew...@gmail.com>
Cc: Lee Jones <lee.jo...@linaro.org>
Cc: linux-l...@vger.kernel.org
Cc: linux-...@vger.kernel.org
Cc: linux-...@vger.kernel.org
Cc: linux-w...@vger.kernel.org
Cc: Martin Schwidefsky <schwidef...@de.ibm.com>
Cc: Maxime Coquelin <mcoquelin.st...@gmail.com>
Cc: Pavel Machek <pa...@ucw.cz>
Cc: Peter Oberparleiter <ober...@linux.ibm.com>
Cc: "Rafael J. Wysocki" <raf...@kernel.org>
Cc: Stefan Schmidt <ste...@datenfreihafen.org>
Cc: Greg Kroah-Hartman <gre...@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael.j.wyso...@intel.com>
Signed-off-by: Suzuki K Poulose <suzuki.poul...@arm.com>
---
 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