From: "Danilo Krummrich" <dakr@kernel.org>
To: "Igor Korotin" <igor.korotin@linux.dev>, "Gary Guo" <gary@garyguo.net>
Cc: "Nicolás Antinori" <nico.antinori.7@gmail.com>,
"Georgios Androutsopoulos" <georgeandrout13@gmail.com>,
"Muchamad Coirul Anwar" <muchamadcoirulanwar@gmail.com>,
"Jonathan Cameron" <jic23@kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Alice Ryhl" <aliceryhl@google.com>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Benno Lossin" <lossin@kernel.org>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Boqun Feng" <boqun@kernel.org>,
"Brigham Campbell" <me@brighamcampbell.com>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Jori Koolstra" <jkoolstra@xs4all.nl>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Onur Özkan" <work@onurozkan.dev>,
"Shuah Khan" <skhan@linuxfoundation.org>,
"Tamir Duberstein" <tamird@kernel.org>,
"Trevor Gross" <tmgross@umich.edu>,
linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org,
linux-kernel-mentees@lists.linux.dev
Subject: Re: [PATCH] rust: i2c: remove TryFrom<&Device> implementation for &I2cClient
Date: Thu, 22 Oct 2026 11:20:52 +0200 [thread overview]
Message-ID: <DMB98IOE3UFS.3GDRFXA47B2PW@kernel.org> (raw)
In-Reply-To: <DMAIXJB74Q1O.9A03KK0SSDLH@garyguo.net>
Igor,
On Wed Oct 21, 2026 at 2:44 PM CEST, Gary Guo wrote:
> On Wed Oct 21, 2026 at 1:32 PM BST, Igor Korotin wrote:
>> Hi all,
>>
>> Want to flag something before this lands -- I gave this an Acked-by
>> already, but while reviewing Muchamad's concurrent AS5600/IIO series
>> (Cc'd) I hit a real conflict with it.
>>
>> His IioDriver::read_raw is called by the generic IIO core, which only
>> ever hands the driver a generic &Device<Bound>
>
> That'd be a subsystem design issue.
Indeed, for class devices registered for a bus device there are two possible
options to get to the specific parent bus device:
(1) Track it in the type system taking advantage of the AsBusDevice trait.
(2) Let the driver store a reference to the specific bus device in its class
device registration data (which is guaranteed to be shorter lived than the
'bound lifetime).
The "upcast" was only ever needed for cases where we couldn't (easily) represent
the relationship through the type system (1); auxiliary bus was such an example.
But with the lifetime design this went away too.
> In the latest device driver lifecycle model design, class device must not mess
> around with parent bus device. It should use its own mechanism to carry around
> private data, which is initialized when creating the class device registration.
>
> The callback bridges should simply retrieve that registered data and hand it to
> the driver callback. The driver can decide to put whatever it needs there, and
> this include a `&Device<Bound>` of the bus device (hint -- you probably don't
> need it, it should just be a reference to whatever bus device resoruce the
> callback needs).
There's nothing wrong with a subsystem using AsBusDevice to keep track of the
specific parent bus device type and handing out references of it in callbacks,
but the lifetime design makes it largely unnecessary.
> The need for conversion is a strong indication that it's not aligned with the
> device driver lifetime design.
Indeed, but as mentioned above, this shouldn't even be necessary without it.
prev parent reply other threads:[~2026-10-22 9:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-19 15:23 Nicolás Antinori
2026-10-21 10:38 ` Igor Korotin
2026-10-21 12:32 ` Igor Korotin
2026-10-21 12:44 ` Gary Guo
2026-10-21 16:46 ` Igor Korotin
2026-10-22 9:20 ` Danilo Krummrich [this message]
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=DMB98IOE3UFS.3GDRFXA47B2PW@kernel.org \
--to=dakr@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=gary@garyguo.net \
--cc=georgeandrout13@gmail.com \
--cc=igor.korotin@linux.dev \
--cc=jic23@kernel.org \
--cc=jkoolstra@xs4all.nl \
--cc=linux-kernel-mentees@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=me@brighamcampbell.com \
--cc=muchamadcoirulanwar@gmail.com \
--cc=nico.antinori.7@gmail.com \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=work@onurozkan.dev \
/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
all inboxes | Powered by JetHome®