@@ -342,30 +342,6 @@ struct device *bus_find_device(struct bus_type *bus,
}
EXPORT_SYMBOL_GPL(bus_find_device);
-static int match_name(struct device *dev, void *data)
-{
- const char *name = data;
-
- return sysfs_streq(name, dev_name(dev));
-}
-
-/**
- * bus_find_device_by_name - device iterator for locating a particular device of a specific name
- * @bus: bus type
- * @start: Device to begin with
- * @name: name of the device to match
- *
- * This is similar to the bus_find_device() function above, but it handles
- * searching by a name automatically, no need to write another strcmp matching
- * function.
- */
-struct device *bus_find_device_by_name(struct bus_type *bus,
- struct device *start, const char *name)
-{
- return bus_find_device(bus, start, (void *)name, match_name);
-}
-EXPORT_SYMBOL_GPL(bus_find_device_by_name);
-
/**
* subsys_find_device_by_id - find a device with a specific enumeration number
* @subsys: subsystem
@@ -3352,3 +3352,9 @@ int device_match_devt(struct device *dev, void *pdevt)
return dev->devt == *(dev_t *)pdevt;
}
EXPORT_SYMBOL_GPL(device_match_devt);
+
+int device_match_name(struct device *dev, void *name)
+{
+ return sysfs_streq(dev_name(dev), name);
+}
+EXPORT_SYMBOL_GPL(device_match_name);
@@ -167,15 +167,30 @@ int device_match_of_node(struct device *dev, void *np);
int device_match_acpi_dev(struct device *dev, void *adev);
int device_match_fwnode(struct device *dev, void *fwnode);
int device_match_devt(struct device *dev, void *pdevt);
+int device_match_name(struct device *dev, void *name);
int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data,
int (*fn)(struct device *dev, void *data));
struct device *bus_find_device(struct bus_type *bus, struct device *start,
void *data,
int (*match)(struct device *dev, void *data));
-struct device *bus_find_device_by_name(struct bus_type *bus,
- struct device *start,
- const char *name);
+
+/**
+ * bus_find_device_by_name - device iterator for locating a particular device
+ * of a specific name.
+ * @bus: bus type
+ * @start: Device to begin with
+ * @name: name of the device to match
+ *
+ * This is similar to the bus_find_device() function, but it handles
+ * searching by a name automatically.
+ */
+static inline struct device *bus_find_device_by_name(struct bus_type *bus,
+ struct device *start,
+ const char *name)
+{
+ return bus_find_device(bus, start, (void *)name, device_match_name);
+}
/**
* bus_find_device_by_of_node : device iterator for locating a particular device
Add a generic helper to match a device by its name. Also use the generic match by device name helper for bus_find_device_by_name. Since the new match function is also exported, let us convert this to a static inline function. Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: "Rafael J. Wysocki" <rafael@kernel.org> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> --- drivers/base/bus.c | 24 ------------------------ drivers/base/core.c | 6 ++++++ include/linux/device.h | 21 ++++++++++++++++++--- 3 files changed, 24 insertions(+), 27 deletions(-) -- 2.7.4