* [PATCH v4] ACPI: bus: Align acpi_device_get_match_data() with driver match order
@ 2026-01-14 8:23 Kartik Rajput
2026-01-14 8:35 ` Andy Shevchenko
2026-01-14 9:14 ` Sakari Ailus
0 siblings, 2 replies; 4+ messages in thread
From: Kartik Rajput @ 2026-01-14 8:23 UTC (permalink / raw)
To: lenb, sakari.ailus, mika.westerberg, andriy.shevchenko, rafael,
thierry.reding, jonathanh, linux-acpi, linux-kernel
Cc: Kartik Rajput
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>
---
Changes in v4:
* Use __acpi_match_device to get the match data.
* Remove now unused function acpi_of_device_get_match_data().
* Update commit message.
Changes in v3:
* Swap arguments while comparing HID against PRP0001.
* Check value of adev against NULL.
* Declare variables in reversed xmas tree order.
* Update commit message.
Changes in v2:
* Fix build errors.
---
drivers/acpi/bus.c | 30 ++++++++++++------------------
1 file changed, 12 insertions(+), 18 deletions(-)
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 5e110badac7b..c973de7cbe33 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -1016,30 +1016,24 @@ const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids,
}
EXPORT_SYMBOL_GPL(acpi_match_device);
-static const void *acpi_of_device_get_match_data(const struct device *dev)
-{
- struct acpi_device *adev = ACPI_COMPANION(dev);
- const struct of_device_id *match = NULL;
-
- if (!acpi_of_match_device(adev, dev->driver->of_match_table, &match))
- return NULL;
-
- return match->data;
-}
-
const void *acpi_device_get_match_data(const struct device *dev)
{
const struct acpi_device_id *acpi_ids = dev->driver->acpi_match_table;
- const struct acpi_device_id *match;
+ const struct of_device_id *of_ids = dev->driver->of_match_table;
+ const struct acpi_device *adev = acpi_companion_match(dev);
+ const struct acpi_device_id *acpi_id = NULL;
+ const struct of_device_id *of_id = NULL;
- if (!acpi_ids)
- return acpi_of_device_get_match_data(dev);
-
- match = acpi_match_device(acpi_ids, dev);
- if (!match)
+ if (!__acpi_match_device(adev, acpi_ids, of_ids, &acpi_id, &of_id))
return NULL;
- return (const void *)match->driver_data;
+ if (acpi_id)
+ return (const void *)acpi_id->driver_data;
+
+ if (of_id)
+ return of_id->data;
+
+ return NULL;
}
EXPORT_SYMBOL_GPL(acpi_device_get_match_data);
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v4] ACPI: bus: Align acpi_device_get_match_data() with driver match order
2026-01-14 8:23 [PATCH v4] ACPI: bus: Align acpi_device_get_match_data() with driver match order Kartik Rajput
@ 2026-01-14 8:35 ` Andy Shevchenko
2026-01-14 9:14 ` Sakari Ailus
1 sibling, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2026-01-14 8:35 UTC (permalink / raw)
To: Kartik Rajput
Cc: lenb, sakari.ailus, mika.westerberg, rafael, thierry.reding,
jonathanh, linux-acpi, linux-kernel
On Wed, Jan 14, 2026 at 01:53:06PM +0530, Kartik Rajput wrote:
> 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().
LGTM,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v4] ACPI: bus: Align acpi_device_get_match_data() with driver match order
2026-01-14 8:23 [PATCH v4] ACPI: bus: Align acpi_device_get_match_data() with driver match order Kartik Rajput
2026-01-14 8:35 ` Andy Shevchenko
@ 2026-01-14 9:14 ` Sakari Ailus
2026-01-14 16:17 ` Rafael J. Wysocki
1 sibling, 1 reply; 4+ messages in thread
From: Sakari Ailus @ 2026-01-14 9:14 UTC (permalink / raw)
To: Kartik Rajput
Cc: lenb, mika.westerberg, andriy.shevchenko, rafael, thierry.reding,
jonathanh, linux-acpi, linux-kernel
Hi Kartik,
On Wed, Jan 14, 2026 at 01:53:06PM +0530, Kartik Rajput wrote:
> 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>
Thank you for the update, this looks really nice now.
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
--
Sakari Ailus
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v4] ACPI: bus: Align acpi_device_get_match_data() with driver match order
2026-01-14 9:14 ` Sakari Ailus
@ 2026-01-14 16:17 ` Rafael J. Wysocki
0 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2026-01-14 16:17 UTC (permalink / raw)
To: Sakari Ailus, Kartik Rajput
Cc: mika.westerberg, andriy.shevchenko, thierry.reding, jonathanh,
linux-acpi, linux-kernel
On Wed, Jan 14, 2026 at 10:14 AM Sakari Ailus
<sakari.ailus@linux.intel.com> wrote:
>
> Hi Kartik,
>
> On Wed, Jan 14, 2026 at 01:53:06PM +0530, Kartik Rajput wrote:
> > 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>
>
> Thank you for the update, this looks really nice now.
>
> Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Applied as 6.20 material, thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-01-14 16:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-14 8:23 [PATCH v4] ACPI: bus: Align acpi_device_get_match_data() with driver match order Kartik Rajput
2026-01-14 8:35 ` Andy Shevchenko
2026-01-14 9:14 ` Sakari Ailus
2026-01-14 16:17 ` Rafael J. Wysocki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®