Re: [PATCH 3/4] rust: leds: add basic led classdev abstractions
From: Danilo Krummrich
Date: Thu Oct 09 2025 - 07:37:30 EST
On Wed Oct 8, 2025 at 8:10 PM CEST, Markus Probst wrote:
> +/// The led class device representation.
> +///
> +/// This structure represents the Rust abstraction for a C `struct led_classdev`.
> +#[pin_data(PinnedDrop)]
> +pub struct LedClassDev {
Please just call this structure Device; drivers will refer to it as led::Device.
This is for consistency with drm::Device, pwm::Device, etc.
> + default_trigger: Option<CString>,
> + parent: Option<ARef<Device>>,
> + handler: KBox<dyn LedHandlerImpl>,
Those fields are already covered by the C struct led_classdev, there is no need
to duplicate them.
Please have a look at how drm::Device [1] and pwm::Device [2] abstract things
for reference. The general patterns for abstracting class devices should be very
similar.
[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/rust/kernel/drm/device.rs
[2] https://lore.kernel.org/all/20250930-rust-next-pwm-working-fan-for-sending-v15-3-5661c3090877@xxxxxxxxxxx/