From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Danilo Krummrich <dakr@kernel.org>
Cc: "Markus Probst" <markus.probst@posteo.de>,
"Rafael J. Wysocki" <rafael@kernel.org>,
"Len Brown" <lenb@kernel.org>, "Miguel Ojeda" <ojeda@kernel.org>,
"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org,
rust-for-linux@vger.kernel.org, driver-core@lists.linux.dev
Subject: Re: [PATCH] rust: ACPI: fix missing match data for PRP0001
Date: Thu, 2 Apr 2026 14:31:39 +0200 [thread overview]
Message-ID: <2026040220-voice-reps-04a9@gregkh> (raw)
In-Reply-To: <DHI5Y6PNVJSJ.SCAJL0A4W2TR@kernel.org>
On Thu, Apr 02, 2026 at 12:15:07AM +0200, Danilo Krummrich wrote:
> On Wed Apr 1, 2026 at 8:46 PM CEST, Markus Probst wrote:
> > On Wed, 2026-04-01 at 20:32 +0200, Greg Kroah-Hartman wrote:
> >> On Wed, Apr 01, 2026 at 02:06:25PM +0000, Markus Probst wrote:
> >> > Export `acpi_of_match_device` function and use it to match the of device
> >> > table against ACPI PRP0001 in Rust.
> >> >
> >> > This fixes id_info being None on ACPI PRP0001 devices.
> >> >
> >> > Using `device_get_match_data` is not possible, because Rust stores an
> >> > index in the of device id instead of a data pointer.
> >>
> >> I'm confused, why are we open-coding this in the rust layer? What do we
> >> need to change in the C side to make both layers be able to call the
> >> same function instead?
> > No commit message I have seen has explained why it was done this way. I
> > don't think we would need to change anything on the C side.
>
> The Rust code stores an index into the array the contains the actual device ID
> info in the driver_data field of a device ID instead of a raw pointer to the
> device ID info.
>
> The reason for this is that it was the only way to build this in a way that
> results in an API that is convinient and obvious to use for drivers when
> declaring the device ID table, can be evaluated in const context (i.e. at
> compile time), and does not rely on unstable language features. Fulfilling all
> three of those requirements at the same was a rather tricky one.
>
> The unfortunate consequence is that device_get_match_data() does not give us a
> pointer to the actual device ID info, but it gives us the index of the device ID
> info in the device ID table.
>
> The problem is that this does not really help, because now we know the index,
> but not which table it belongs to.
>
> I.e. we wouldn't know whether to call
>
> Self::acpi_id_table().info(index)
>
> or
>
> Self::of_id_table().info(index)
>
> to obtain the actual device ID info.
>
> So, unfortunately, I think we have to open code this for now.
>
> But I think this is still a minor inconvinience for being able to fulfill the
> requirements mentioned above.
Ok, that makes more sense, thanks for the detail. Perhaps some of that
could go into the changelog :)
thanks,
greg k-h
next prev parent reply other threads:[~2026-04-02 12:31 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-01 14:06 [PATCH] rust: ACPI: fix missing match data for PRP0001 Markus Probst
2026-04-01 18:32 ` Greg Kroah-Hartman
2026-04-01 18:46 ` Markus Probst
2026-04-01 22:15 ` Danilo Krummrich
2026-04-02 12:31 ` Greg Kroah-Hartman [this message]
2026-04-04 21:23 ` Gary Guo
2026-04-04 21:32 ` Danilo Krummrich
2026-04-05 5:47 ` Greg Kroah-Hartman
2026-04-04 21:33 ` Markus Probst
2026-04-04 21:38 ` Danilo Krummrich
2026-04-04 22:08 ` Gary Guo
2026-04-04 22:07 ` Danilo Krummrich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2026040220-voice-reps-04a9@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=a.hindborg@kernel.org \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=dakr@kernel.org \
--cc=driver-core@lists.linux.dev \
--cc=gary@garyguo.net \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=markus.probst@posteo.de \
--cc=ojeda@kernel.org \
--cc=rafael@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox