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 Thu, 2026-04-09 at 00:07 +0200, Danilo Krummrich wrote:
> On Wed Apr 8, 2026 at 11:42 PM CEST, Markus Probst wrote:
> > On Wed, 2026-04-08 at 21:59 +0200, Danilo Krummrich wrote:
> > > On Wed Apr 8, 2026 at 9:40 PM CEST, Markus Probst wrote:
> > > > 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.
> > >
> > > Usually we provide a stub instead of conditionalize the callers; this case might
> > > be a bit special, but I'd still follow the usual pattern.
> > The usual C pattern would be
> >
> > static inline 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);
> >
> > , which is ignored by bindgen (i. e. same error).
>
> That's where you define a Rust helper; we have lots of cases where we only have
> the Rust helper to deal with the inline function stub used when the
> corresponding CONFIG_* is disabled.
According to git commit msg [1], __rust_helper is needed to inline
these helpers into Rust code. Does this mean we could omit the extra
function declaration with #[inline(never)] and just use a helper
without __rust_helper?
[1]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a9aabb3b839aba094ed80861054993785c61462c
Thanks
- Markus Probst
signature.asc
(application/pgp-signature, 870 B)
-----BEGIN PGP SIGNATURE----- iQJPBAABCAA5FiEEgnQYxPSsWOdyMMRzNHYf+OetQ9IFAmnZD8gbFIAAAAAABAAO bWFudTIsMi41KzEuMTIsMiwyAAoJEDR2H/jnrUPSjTgQAJxzmgET7ENUYshXpn8f OQo7nKxHlBxDTDb/C+h9tV3LH/AlKQ4c1xcxfIxinrW/8N3/XwHpCZEi/mgx4PG5 pmthLwQFscaChQD/jMyscKKqZjDxddHpR2KuOqR4J7OD/EBM7yEi+niXAzg3IEjw GIZEtc3xKIk7m4hLAqNNqUXj5vO6XX4cpgTBvwkNGXVGRwHnsB4kB3XgfeJkJYjT l3sK/w8dnhQJ8LGrmJfAKE3MLOe6SREP4Bb5ZSXaAc0/CA347cMf13NLKV8Zi8VF I19TrBIxotc/WhvEc1jXJ0TANZ8tVmdKufaAcMmMXVbgUZCa4cvlP4hPMOO2+Vr/ MwixyugodZkyaO9d+RSTdBjduGmYuGdL7nmL4Fgchpw8QpDuDu3knldf9qOM3kU0 8TjLDdIIA9/fVYsTqb0rSPQ5onoKXiOLeNjKxiLqGYDwkeDlCr1SCZl0e0BLEbWM tAwmb/e1uVKwgIRAj1tYV5jWlctoDofhOt356qilNT83kqpBrJoGvzFX2eZa164M k4kso+djELpWsS4FA/ppJncxWhokjhHt6s+rqzQDeXkB56+9DLaQGajY+1i1h2Po 9R64BBAg8qE4xnTKnQMYQ6QLGUBR5EsTW4i5qIVUMT66v8PpeBratgGWZN53ySqQ oo4cqp+8nQhxKrIc6IRy1M7f =9POa -----END PGP SIGNATURE-----