Skip to content

Commit

Permalink
mfd: core: Use acpi_find_child_device() for child devices lookup
Browse files Browse the repository at this point in the history
Use acpi_find_child_device() for child devices lookup in mfd_acpi_add_device()
instead of open coded approach. No functional change intended.

While at it, amend a note comment, since usage of _ADR is found on other
platforms and tables than Intel Galileo Gen 2, in particular USB wired devices
are using it, according to Microsoft specifications for embedded platforms.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
  • Loading branch information
Andy Shevchenko authored and Lee Jones committed Apr 14, 2021
1 parent 6dac44c commit 40cb71f
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions drivers/mfd/mfd-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ static void mfd_acpi_add_device(const struct mfd_cell *cell,
{
const struct mfd_cell_acpi_match *match = cell->acpi_match;
struct acpi_device *parent, *child;
struct acpi_device *adev;
struct acpi_device *adev = NULL;

parent = ACPI_COMPANION(pdev->dev.parent);
if (!parent)
Expand All @@ -77,10 +77,9 @@ static void mfd_acpi_add_device(const struct mfd_cell *cell,
* _ADR or it will use the parent handle if is no ID is given.
*
* Note that use of _ADR is a grey area in the ACPI specification,
* though Intel Galileo Gen2 is using it to distinguish the children
* devices.
* though at least Intel Galileo Gen 2 is using it to distinguish
* the children devices.
*/
adev = parent;
if (match) {
if (match->pnpid) {
struct acpi_device_id ids[2] = {};
Expand All @@ -93,22 +92,11 @@ static void mfd_acpi_add_device(const struct mfd_cell *cell,
}
}
} else {
unsigned long long adr;
acpi_status status;

list_for_each_entry(child, &parent->children, node) {
status = acpi_evaluate_integer(child->handle,
"_ADR", NULL,
&adr);
if (ACPI_SUCCESS(status) && match->adr == adr) {
adev = child;
break;
}
}
adev = acpi_find_child_device(parent, match->adr, false);
}
}

ACPI_COMPANION_SET(&pdev->dev, adev);
ACPI_COMPANION_SET(&pdev->dev, adev ?: parent);
}
#else
static inline void mfd_acpi_add_device(const struct mfd_cell *cell,
Expand Down

0 comments on commit 40cb71f

Please sign in to comment.