Skip to content

Commit 8567b57

Browse files
Kartik Rajputrafaeljw
authored andcommitted
ACPI: bus: Align acpi_device_get_match_data() with driver match order
During pre-production development, drivers may provide both ACPI and OF match tables while a formal ACPI HID for the device is not yet allocated. Such devices are enumerated via PRP0001. In this case, acpi_device_get_match_data() consults only the driver’s ACPI match table and returns NULL, even though the device was successfully matched via PRP0001. This behavior also risks breaking existing PRP0001 setups if a driver later gains an ACPI HID, as the presence of an ACPI match table changes the match-data lookup path. Make acpi_device_get_match_data() use the same precedence as driver matching by using __acpi_match_device(). Return match data from the acpi_id or of_id that was actually matched. Remove now-unused acpi_of_device_get_match_data(). Signed-off-by: Kartik Rajput <kkartik@nvidia.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com> Link: https://patch.msgid.link/20260114082306.48119-1-kkartik@nvidia.com Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent b2f90ef commit 8567b57

1 file changed

Lines changed: 12 additions & 18 deletions

File tree

drivers/acpi/bus.c

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,30 +1013,24 @@ const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids,
10131013
}
10141014
EXPORT_SYMBOL_GPL(acpi_match_device);
10151015

1016-
static const void *acpi_of_device_get_match_data(const struct device *dev)
1017-
{
1018-
struct acpi_device *adev = ACPI_COMPANION(dev);
1019-
const struct of_device_id *match = NULL;
1020-
1021-
if (!acpi_of_match_device(adev, dev->driver->of_match_table, &match))
1022-
return NULL;
1023-
1024-
return match->data;
1025-
}
1026-
10271016
const void *acpi_device_get_match_data(const struct device *dev)
10281017
{
10291018
const struct acpi_device_id *acpi_ids = dev->driver->acpi_match_table;
1030-
const struct acpi_device_id *match;
1019+
const struct of_device_id *of_ids = dev->driver->of_match_table;
1020+
const struct acpi_device *adev = acpi_companion_match(dev);
1021+
const struct acpi_device_id *acpi_id = NULL;
1022+
const struct of_device_id *of_id = NULL;
10311023

1032-
if (!acpi_ids)
1033-
return acpi_of_device_get_match_data(dev);
1034-
1035-
match = acpi_match_device(acpi_ids, dev);
1036-
if (!match)
1024+
if (!__acpi_match_device(adev, acpi_ids, of_ids, &acpi_id, &of_id))
10371025
return NULL;
10381026

1039-
return (const void *)match->driver_data;
1027+
if (acpi_id)
1028+
return (const void *)acpi_id->driver_data;
1029+
1030+
if (of_id)
1031+
return of_id->data;
1032+
1033+
return NULL;
10401034
}
10411035
EXPORT_SYMBOL_GPL(acpi_device_get_match_data);
10421036

0 commit comments

Comments
 (0)