[RFC PATCH 53/57] drivers: Introduce bus_find_next_device() helper

Suzuki K Poulose
2019-06-03T15:52:45Z

Add a helper to find the next device on the given bus from a
given device iterator position.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
include/linux/device.h | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/include/linux/device.h b/include/linux/device.h
index 7ea15e6..528efc0 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -234,6 +234,16 @@ static inline struct device *bus_find_device_by_devt(struct bus_type *bus,
return bus_find_device(bus, start, &devt, device_match_devt);
}

+/**
+ * bus_find_next_device - Find the next device after a given device in a
+ * given bus.
+ */
+static inline struct device *bus_find_next_device(struct bus_type *bus,
+ struct device *start)
+{
+ return bus_find_device(bus, start, NULL, device_match_any);
+}
+
struct device *subsys_find_device_by_id(struct bus_type *bus, unsigned int id,
struct device *hint);
int bus_for_each_drv(struct bus_type *bus, struct device_driver *start,
--
2.7.4