rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Danilo Krummrich" <dakr@kernel.org>
To: "Markus Probst" <markus.probst@posteo.de>
Cc: "Alice Ryhl" <aliceryhl@google.com>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Alex Gaynor" <alex.gaynor@gmail.com>,
	"Lee Jones" <lee@kernel.org>, "Pavel Machek" <pavel@kernel.org>,
	"Lorenzo Stoakes" <lorenzo.stoakes@oracle.com>,
	"Vlastimil Babka" <vbabka@suse.cz>,
	"Liam R. Howlett" <Liam.Howlett@oracle.com>,
	"Uladzislau Rezki" <urezki@gmail.com>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Gary Guo" <gary@garyguo.net>, <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Trevor Gross" <tmgross@umich.edu>,
	<rust-for-linux@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-leds@vger.kernel.org>
Subject: Re: [PATCH v4 2/2] rust: leds: add basic led classdev abstractions
Date: Wed, 15 Oct 2025 19:27:57 +0200	[thread overview]
Message-ID: <DDJ2MSQ0UJQL.199XI9U29HPXL@kernel.org> (raw)
In-Reply-To: <25f3fd337ce5e58915125c4e2eb85ef4d7af3627.camel@posteo.de>

On Wed Oct 15, 2025 at 5:02 PM CEST, Markus Probst wrote:
> Not necessarily every, like I said `container::Device` itself also
> would implement `device::Container` (still allowing &Device<Bound>).

Sure, but eventually we'll need all bus devices to implement it because you want
to be able to use this class device on any bus.

> We already know the address of it with the `struct led_classdev`-
>`parent` field, we just need to substract the offset from `<T as
> Container>::Offset`, and we have the address of the device container
> (like `struct i2c_client`). No Box needed.

Yeah, that should work.

What I still don't like about it (and didn't like back then when I thought about
something similar) is that this provides a publicly accessible unsafe way to
upcast from a generic device to a bus device.

However, I do see the ergonomic advantage for drivers. Even though I'd say it's
minor, it is indeed nice that the class device callbacks can already carry the
actual parent bus device.

So, I'm fine giving this a shot. If go for an implementation, please name the
trait something along the lines of device::IntoBusDevice, device::Container is
too generic. Only bus devices have a DeviceContext.

  reply	other threads:[~2025-10-15 17:28 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-12 14:52 [PATCH v4 0/2] rust: leds: add led classdev abstractions Markus Probst
2025-10-12 14:52 ` [PATCH v4 1/2] rust: add basic Pin<Vec<T, A>> abstractions Markus Probst
2025-10-12 16:26   ` Benno Lossin
2025-10-12 16:57     ` Markus Probst
2025-10-12 21:31       ` Benno Lossin
2025-10-12 22:11         ` Markus Probst
2025-10-13  8:03           ` Benno Lossin
2025-10-13  9:22             ` Alice Ryhl
2025-10-13  9:39               ` Benno Lossin
2025-10-13 13:43             ` Markus Probst
2025-10-13 14:47               ` Benno Lossin
2025-10-14 14:15                 ` Markus Probst
2025-10-12 14:52 ` [PATCH v4 2/2] rust: leds: add basic led classdev abstractions Markus Probst
2025-10-13 18:34   ` Alice Ryhl
2025-10-13 20:11     ` Danilo Krummrich
2025-10-14 14:46       ` Markus Probst
2025-10-15 13:44     ` Markus Probst
2025-10-15 14:52       ` Danilo Krummrich
2025-10-15 15:02         ` Markus Probst
2025-10-15 17:27           ` Danilo Krummrich [this message]
2025-10-12 16:27 ` [PATCH v4 0/2] rust: leds: add " Benno Lossin

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=DDJ2MSQ0UJQL.199XI9U29HPXL@kernel.org \
    --to=dakr@kernel.org \
    --cc=Liam.Howlett@oracle.com \
    --cc=a.hindborg@kernel.org \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=gary@garyguo.net \
    --cc=lee@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=lossin@kernel.org \
    --cc=markus.probst@posteo.de \
    --cc=ojeda@kernel.org \
    --cc=pavel@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tmgross@umich.edu \
    --cc=urezki@gmail.com \
    --cc=vbabka@suse.cz \
    /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;
as well as URLs for NNTP newsgroup(s).