diff mbox series

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

Message ID 1559577023-558-54-git-send-email-suzuki.poulose@arm.com
State New
Headers show
Series [RFC,01/57] drivers: s390/cio: Use driver_for_each_device | expand

Commit Message

Suzuki K Poulose June 3, 2019, 3:50 p.m. UTC
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(+)

-- 
2.7.4
diff mbox series

Patch

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,