Re: [PATCH v3] rust: ACPI: fix missing match data for PRP0001
From: Markus Probst
Date: Wed Apr 08 2026 - 15:40:35 EST
On Wed, 2026-04-08 at 18:03 +0200, Danilo Krummrich wrote:
> On Tue Apr 7, 2026 at 11:41 PM CEST, Markus Probst wrote:
> > diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
> > index aad1a95e6863..d0098f24346f 100644
> > --- a/include/acpi/acpi_bus.h
> > +++ b/include/acpi/acpi_bus.h
> > @@ -187,6 +187,10 @@ struct acpi_driver {
> > * -----------
> > */
> >
> > +bool acpi_of_match_device(const struct acpi_device *adev,
> > + const struct of_device_id *of_match_table,
> > + const struct of_device_id **of_id);
>
> This also has to be defined for !CONFIG_ACPI, otherwise we run into the
> following compatible error.
>
> error[E0425]: cannot find function `acpi_of_match_device` in crate `bindings`
> --> rust/kernel/driver.rs:295:24
> |
> 295 | unsafe { bindings::acpi_of_match_device(adev, of_match_table, of_id) }
> | ^^^^^^^^^^^^^^^^^^^^
> |
> ::: /mnt/nvme/work/projects/linux/driver-core/driver-core-testing/rust/bindings/bindings_generated.rs:118713:5
>
> There is an
>
> #else /* CONFIG_ACPI */
>
> block at the end of acpi_bus.h for this.
I don't think the function exists in that case and bindgen can't
generate inline functions, so I will just add a `#[cfg(CONFIG_ACPI)]`
condition on top of the function.
>
> > +
> > /* Status (_STA) */
> >
> > struct acpi_device_status {
> > diff --git a/rust/bindings/bindings_helper.h b/rust/bindings/bindings_helper.h
> > index 083cc44aa952..e47643ce8b50 100644
> > --- a/rust/bindings/bindings_helper.h
> > +++ b/rust/bindings/bindings_helper.h
> > @@ -96,6 +96,11 @@
> > */
> > #include <../../drivers/base/base.h>
> >
> > +/*
> > + * The driver-core Rust code needs to call `acpi_of_match_device`.
> > + */
>
> NIT: I'd drop this comment as such comments usually do not age very well. :)
>
> I assume you followed the above comment for
>
> #include <../../drivers/base/base.h>
>
> but this one is different as it justifies why we have to include an internal
> header in general (i.e. not for a specific function).
>
> > @@ -278,6 +283,18 @@ fn init(
> > }
> > }
> >
> > +#[inline(never)]
> > +#[allow(clippy::missing_safety_doc)]
> > +#[must_use]
> > +unsafe fn acpi_of_match_device(
>
> Maybe add a very brief comment similar to the one in devres.rs for this.
>
> > + adev: *const bindings::acpi_device,
> > + of_match_table: *const bindings::of_device_id,
> > + of_id: *mut *const bindings::of_device_id,
> > +) -> bool {
> > + // SAFETY: Safety requirements are the same as `bindings::acpi_device_id`.
>
> Typo: s/bindings::acpi_device_id/bindings::acpi_of_match_device/
>
> > + unsafe { bindings::acpi_of_match_device(adev, of_match_table, of_id) }
> > +}
Thanks
- Markus Probst
Attachment:
signature.asc
Description: This is a digitally signed message part