Re: [PATCH v3] rust: ACPI: fix missing match data for PRP0001
Markus Probst <[email protected]>
| Newsgroups | dev.linux.lists.acpica-devel,dev.linux.lists.driver-core,org.kernel.vger.linux-acpi,org.kernel.vger.linux-kernel,org.kernel.vger.rust-for-linux |
|---|---|
| Message-ID | <[email protected]> |
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
signature.asc
(application/pgp-signature, 870 B)
-----BEGIN PGP SIGNATURE----- iQJPBAABCAA5FiEEgnQYxPSsWOdyMMRzNHYf+OetQ9IFAmnWrxIbFIAAAAAABAAO bWFudTIsMi41KzEuMTIsMiwyAAoJEDR2H/jnrUPSligQALe2ivKKk9GxR7VNoq7j 6icq9A8ix4rAFMDkZVgBGzrXazG1g1oM77T1JByoQtsTTBngQu0o1xfnqj0NrqG8 mNJitWJ+SvnpU+lSAJ1hrE39I5Uimc9Vk9JevrfsdyXHWtmSURcSKzGP1BiRlqx3 tjbT0nKUqQI76cOj1OnFzHI4OXlZ7fWixGnnshwy7onxaHPw1QCaguGCxwGSGXy8 n24U8z6OnJlNGFcKpgJzZZ0LhzkIE9XCqEzdE1vZMImAityUFIXuXF5frJtgbTdu t0aIihN+XJCFXYM8+FpFBB7W2lpk5gdW8zp3KBns86O1fO91qB9BZ1EMKMs4r0JS 579rcCjW333rou3c7d+rEC1bcqTdPhe3onJPWbvWMzHZh37cREUR+q6hkQS6CRxf cDi568lUD2qYQds7h6nMCeUPZNMadpda7eQ2PLB77BACCFEYDCqQqOBb0qfiJtGD oPO+D2Bmgy6odHlMJPrCdktrbZ4BAGKi0LrG14JKzybutD7l6LdkBmQ7+MZsXb87 MiX+BttluBXljXSruLCbXkKVtHIw2ccNPbql6QMKqfwUlRDNWWSjTI+0BmJagFXo Hx1xJF1X1Vz/2U9DfAOWmD8tVfWM4XH9yMZK1irwne+cAACAIZEicRU50NJZe48T 2K7vvRnzMNUY3nfnHdaie9Vd =9ZyQ -----END PGP SIGNATURE-----