Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ACPI: container: Use acpi_dev_for_each_child()

Instead of walking the list of children of an ACPI device directly,
use acpi_dev_for_each_child() to carry out an action for all of
the given ACPI device's children.

This will help to eliminate the children list head from struct
acpi_device as it is redundant and it is used in questionable ways
in some places (in particular, locking is needed for walking the
list pointed to it safely, but it is often missing).

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

+9 -8
+9 -8
drivers/acpi/container.c
··· 23 23 24 24 #ifdef CONFIG_ACPI_CONTAINER 25 25 26 + static int check_offline(struct acpi_device *adev, void *not_used) 27 + { 28 + if (acpi_scan_is_offline(adev, false)) 29 + return 0; 30 + 31 + return -EBUSY; 32 + } 33 + 26 34 static int acpi_container_offline(struct container_dev *cdev) 27 35 { 28 - struct acpi_device *adev = ACPI_COMPANION(&cdev->dev); 29 - struct acpi_device *child; 30 - 31 36 /* Check all of the dependent devices' physical companions. */ 32 - list_for_each_entry(child, &adev->children, node) 33 - if (!acpi_scan_is_offline(child, false)) 34 - return -EBUSY; 35 - 36 - return 0; 37 + return acpi_dev_for_each_child(ACPI_COMPANION(&cdev->dev), check_offline, NULL); 37 38 } 38 39 39 40 static void acpi_container_release(struct device *dev)