]> git.baikalelectronics.ru Git - kernel.git/commitdiff
ACPI: bus: Introduce acpi_dev_for_each_child_reverse()
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 13 Jun 2022 18:26:47 +0000 (20:26 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 20 Jun 2022 18:33:15 +0000 (20:33 +0200)
Make it possible to walk the children of an ACPI device in the revese
order by defining acpi_dev_for_each_child_reverse() in analogy with
acpi_dev_for_each_child().

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
drivers/acpi/bus.c
include/acpi/acpi_bus.h

index 7027ff2edfba4324c51196cfcc71dcf2e663b4db..4d7c51a33b016d54b16ec2f03551b55bef81827d 100644 (file)
@@ -1115,6 +1115,18 @@ int acpi_dev_for_each_child(struct acpi_device *adev,
        return device_for_each_child(&adev->dev, &adwc, acpi_dev_for_one_check);
 }
 
+int acpi_dev_for_each_child_reverse(struct acpi_device *adev,
+                                   int (*fn)(struct acpi_device *, void *),
+                                   void *data)
+{
+       struct acpi_dev_walk_context adwc = {
+               .fn = fn,
+               .data = data,
+       };
+
+       return device_for_each_child_reverse(&adev->dev, &adwc, acpi_dev_for_one_check);
+}
+
 /* --------------------------------------------------------------------------
                              Initialization/Cleanup
    -------------------------------------------------------------------------- */
index 597961969ca1849a52b26be8a0b7cce092bf7453..76de1aa5d22135544ae9f20a503c2fc17994661b 100644 (file)
@@ -483,6 +483,9 @@ extern struct bus_type acpi_bus_type;
 int acpi_bus_for_each_dev(int (*fn)(struct device *, void *), void *data);
 int acpi_dev_for_each_child(struct acpi_device *adev,
                            int (*fn)(struct acpi_device *, void *), void *data);
+int acpi_dev_for_each_child_reverse(struct acpi_device *adev,
+                                   int (*fn)(struct acpi_device *, void *),
+                                   void *data);
 
 /*
  * Events