ACPI: bus: Add iterator for dependent devices
authorDaniel Scally <djrscally@gmail.com>
Wed, 21 Sep 2022 23:04:36 +0000 (00:04 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Sat, 24 Sep 2022 17:12:32 +0000 (19:12 +0200)
Add a helper macro to iterate over ACPI devices that are flagged
as consumers of an initial supplier ACPI device.

Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Daniel Scally <djrscally@gmail.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
include/acpi/acpi_bus.h

index c66d17c3298b86fd2604421793bb10c50993644e..f016c155b462e7bf887d107a21acbc5b7a8fd8ae 100644 (file)
@@ -745,6 +745,17 @@ bool acpi_dev_ready_for_enumeration(const struct acpi_device *device);
 struct acpi_device *acpi_dev_get_next_consumer_dev(struct acpi_device *supplier,
                                                   struct acpi_device *start);
 
+/**
+ * for_each_acpi_consumer_dev - iterate over the consumer ACPI devices for a
+ *                             given supplier
+ * @supplier: Pointer to the supplier's ACPI device
+ * @consumer: Pointer to &struct acpi_device to hold the consumer, initially NULL
+ */
+#define for_each_acpi_consumer_dev(supplier, consumer)                 \
+       for (consumer = acpi_dev_get_next_consumer_dev(supplier, NULL); \
+            consumer;                                                  \
+            consumer = acpi_dev_get_next_consumer_dev(supplier, consumer))
+
 struct acpi_device *
 acpi_dev_get_next_match_dev(struct acpi_device *adev, const char *hid, const char *uid, s64 hrv);
 struct acpi_device *