aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorSuzuki K Poulose <suzuki.poulose@arm.com>2019-07-23 18:18:37 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-07-30 07:07:42 -0400
commit6bf85ba9e55f659ddc0747bf1bb504ec6d15f525 (patch)
tree4b240fa6a535a1e9c045152afe9276aa9266622a /include/linux
parent00500147cbd3fc51353d0d003eaa9d31c72c0d50 (diff)
drivers: Add generic helper to match any device
Add a generic helper to match any/all devices. Using this introduce new wrappers {bus/driver/class}_find_next_device(). Cc: Elie Morisse <syniurge@gmail.com> Cc: "James E.J. Bottomley" <jejb@linux.ibm.com> Cc: "Martin K. Petersen" <martin.petersen@oracle.com> Cc: Nehal Shah <nehal-bakulchandra.shah@amd.com> Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com> Cc: Shyam Sundar S K <shyam-sundar.s-k@amd.com> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> Acked-by: Bjorn Helgaas <bhelgaas@google.com> # PCI Link: https://lore.kernel.org/r/20190723221838.12024-7-suzuki.poulose@arm.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/device.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/include/linux/device.h b/include/linux/device.h
index 7514ef3d3f1a..8ae3f4b47293 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -169,6 +169,7 @@ int device_match_of_node(struct device *dev, const void *np);
169int device_match_fwnode(struct device *dev, const void *fwnode); 169int device_match_fwnode(struct device *dev, const void *fwnode);
170int device_match_devt(struct device *dev, const void *pdevt); 170int device_match_devt(struct device *dev, const void *pdevt);
171int device_match_acpi_dev(struct device *dev, const void *adev); 171int device_match_acpi_dev(struct device *dev, const void *adev);
172int device_match_any(struct device *dev, const void *unused);
172 173
173int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data, 174int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data,
174 int (*fn)(struct device *dev, void *data)); 175 int (*fn)(struct device *dev, void *data));
@@ -225,6 +226,16 @@ static inline struct device *bus_find_device_by_devt(struct bus_type *bus,
225 return bus_find_device(bus, NULL, &devt, device_match_devt); 226 return bus_find_device(bus, NULL, &devt, device_match_devt);
226} 227}
227 228
229/**
230 * bus_find_next_device - Find the next device after a given device in a
231 * given bus.
232 */
233static inline struct device *
234bus_find_next_device(struct bus_type *bus,struct device *cur)
235{
236 return bus_find_device(bus, cur, NULL, device_match_any);
237}
238
228#ifdef CONFIG_ACPI 239#ifdef CONFIG_ACPI
229struct acpi_device; 240struct acpi_device;
230 241
@@ -465,6 +476,12 @@ static inline struct device *driver_find_device_by_devt(struct device_driver *dr
465 return driver_find_device(drv, NULL, &devt, device_match_devt); 476 return driver_find_device(drv, NULL, &devt, device_match_devt);
466} 477}
467 478
479static inline struct device *driver_find_next_device(struct device_driver *drv,
480 struct device *start)
481{
482 return driver_find_device(drv, start, NULL, device_match_any);
483}
484
468#ifdef CONFIG_ACPI 485#ifdef CONFIG_ACPI
469/** 486/**
470 * driver_find_device_by_acpi_dev : device iterator for locating a particular 487 * driver_find_device_by_acpi_dev : device iterator for locating a particular