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

Configure Feed

Select the types of activity you want to include in your feed.

mfd: core: 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>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Link: https://lore.kernel.org/r/2726954.BEx9A2HvPv@kreacher

authored by

Rafael J. Wysocki and committed by
Lee Jones
0c9b9c2a f2906aa8

+24 -7
+24 -7
drivers/mfd/mfd-core.c
··· 60 60 EXPORT_SYMBOL(mfd_cell_disable); 61 61 62 62 #if IS_ENABLED(CONFIG_ACPI) 63 + struct match_ids_walk_data { 64 + struct acpi_device_id *ids; 65 + struct acpi_device *adev; 66 + }; 67 + 68 + static int match_device_ids(struct acpi_device *adev, void *data) 69 + { 70 + struct match_ids_walk_data *wd = data; 71 + 72 + if (!acpi_match_device_ids(adev, wd->ids)) { 73 + wd->adev = adev; 74 + return 1; 75 + } 76 + 77 + return 0; 78 + } 79 + 63 80 static void mfd_acpi_add_device(const struct mfd_cell *cell, 64 81 struct platform_device *pdev) 65 82 { 66 83 const struct mfd_cell_acpi_match *match = cell->acpi_match; 67 - struct acpi_device *parent, *child; 68 84 struct acpi_device *adev = NULL; 85 + struct acpi_device *parent; 69 86 70 87 parent = ACPI_COMPANION(pdev->dev.parent); 71 88 if (!parent) ··· 100 83 if (match) { 101 84 if (match->pnpid) { 102 85 struct acpi_device_id ids[2] = {}; 86 + struct match_ids_walk_data wd = { 87 + .adev = NULL, 88 + .ids = ids, 89 + }; 103 90 104 91 strlcpy(ids[0].id, match->pnpid, sizeof(ids[0].id)); 105 - list_for_each_entry(child, &parent->children, node) { 106 - if (!acpi_match_device_ids(child, ids)) { 107 - adev = child; 108 - break; 109 - } 110 - } 92 + acpi_dev_for_each_child(parent, match_device_ids, &wd); 93 + adev = wd.adev; 111 94 } else { 112 95 adev = acpi_find_child_device(parent, match->adr, false); 113 96 }