public inbox for rust-for-linux@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH RESEND v13 0/3] rust: leds: add led classdev abstractions
@ 2026-04-11 15:07 Markus Probst
  2026-04-11 15:07 ` [PATCH RESEND v13 1/3] rust: leds: add basic " Markus Probst
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Markus Probst @ 2026-04-11 15:07 UTC (permalink / raw)
  To: Lee Jones, Pavel Machek, Greg Kroah-Hartman, Dave Ertman,
	Ira Weiny, Leon Romanovsky, Miguel Ojeda, Alex Gaynor, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, Rafael J. Wysocki, Bjorn Helgaas,
	Krzysztof Wilczyński, Boqun Feng, Boqun Feng
  Cc: rust-for-linux, linux-leds, linux-kernel, linux-pci,
	Markus Probst

This patch series has previously been contained in
https://lore.kernel.org/rust-for-linux/20251008181027.662616-1-markus.probst@posteo.de/T/#t
which added a rust written led driver for a microcontroller via i2c.

As the reading and writing to the i2c client via the register!
macro has not been implemented yet [1], the patch series will only
contain the additional abstractions required.

[1] https://lore.kernel.org/rust-for-linux/DDDS2V0V2NVJ.16ZKXCKUA1HUV@kernel.org/

The following changes were made:
* add basic led classdev abstractions to register and unregister leds

* add basic led classdev abstractions to register and unregister
  multicolor leds

Changes since v12:
* add `led::DeviceBuilder::name()` and `DeviceBuilderState'
* add `led::Color::as_c_str`

Changes since v11:
* use `led::DeviceBuilder` instead of `led::InitData`
* use static_assert instead of const { assert!(...) }
* restructured patches to avoid moving `led::Device` from
  rust/kernel/led.rs to rust/kernel/led/normal.rs in the 2. patch

Changes since v10:
* allow in-place initialization of `LedOps`
* run rustfmt for code inside `try_pin_init!`

Changes since v9:
* add missing periods in documentation
* duplicate `led::Device` and `led::Adapter` instead of using a complex
  trait
* fix imports not using prelude
* adapt to CStr change
* documented `led::Color::Multi` and `led::Color::Rgb`

Changes since v8:
* accept `Option<ARef<Fwnode>>` in `led::InitData::fwnode()`
* make functions in `MultiColorSubLed` const
* drop the "rust: Add trait to convert a device reference to a bus
  device reference" patch, as it has been picked into driver-core

Changes since v7:
* adjusted import style
* added classdev parameter to callback functions in `LedOps`
* implement `led::Color`
* extend `led::InitData` with
  - initial_brightness
  - default_trigger
  - default_color
* split generic and normal led classdev abstractions up (see patch 3/4)
* add multicolor led class device abstractions (see patch 4/4)
* added MAINTAINERS entry

Changes since v6:
* fixed typos
* improved documentation

Changes since v5:
* rename `IntoBusDevice` trait into `AsBusDevice`
* fix documentation about `LedOps::BLOCKING`
* removed dependency on i2c bindings
* added `AsBusDevice` implementation for `platform::Device`
* removed `device::Device` fallback implementation
* document that `AsBusDevice` must not be used by drivers and is
  intended for bus and class device abstractions only.

Changes since v4:
* add abstraction to convert a device reference to a bus device
  reference
* require the bus device as parent device and provide it in class device
  callbacks
* remove Pin<Vec<_>> abstraction (as not relevant for the led
  abstractions)
* fixed formatting in `led::Device::new`
* fixed `LedOps::BLOCKING` did the inverse effect

Changes since v3:
* fixed kunit tests failing because of example in documentation

Changes since v2:
* return `Devres` on `led::Device` creation
* replace KBox<T> with T in struct definition
* increment and decrement reference-count of fwnode
* make a device parent mandatory for led classdev creation
* rename `led::Handler` to `led::LedOps`
* add optional `brightness_get` function to `led::LedOps`
* use `#[vtable]` instead of `const BLINK: bool`
* use `Opaque::cast_from` instead of casting a pointer
* improve documentation
* improve support for older rust versions
* use `&Device<Bound>` for parent

Changes since v1:
* fixed typos noticed by Onur Özkan

Signed-off-by: Markus Probst <markus.probst@posteo.de>
---
Markus Probst (3):
      rust: leds: add basic led classdev abstractions
      rust: leds: add Mode trait
      rust: leds: add multicolor classdev abstractions

 MAINTAINERS                     |   8 +
 rust/bindings/bindings_helper.h |   1 +
 rust/kernel/led.rs              | 358 +++++++++++++++++++++++++++++++++++++
 rust/kernel/led/multicolor.rs   | 387 ++++++++++++++++++++++++++++++++++++++++
 rust/kernel/led/normal.rs       | 231 ++++++++++++++++++++++++
 rust/kernel/lib.rs              |   1 +
 6 files changed, 986 insertions(+)
---
base-commit: d1d81e9d1a4dd846aee9ae77ff9ecc2800d72148
change-id: 20251114-rust_leds-a959f7c2f7f9
-----BEGIN PGP SIGNATURE-----

iQJPBAABCAA5FiEEgnQYxPSsWOdyMMRzNHYf+OetQ9IFAmnJX+IbFIAAAAAABAAO
bWFudTIsMi41KzEuMTEsMiwyAAoJEDR2H/jnrUPSKfEQAIr+nl9WCSty+mWQlJqB
D9B4+xLku25rFvvSCv/j7vEtL0VF5Rk5GJKFOhEEYg642WR6Os+VuTNnEOVAWTbK
qNfDNOP9hrn75anyf1HEOduwdsW9sTafrfF8gq36y80q0zVNWqD2SbYJ1A+Ri2Hw
uvJATuDnxMyBL7lAIPhshPjDHjO9wO7qiW6wSVY0RydD21tQZJkag3vg9gUG0Od7
v5DtM57QNf5h/7GXmC0oZ07h3Ua5ZSFNFrHBDm7MAt7YU8TllQcD1sL7f7OhcFDh
LzsQYm+A+VNQ9bL4/SdBeKGug7bEFshJywowdp6noRNJPR1Y2lCy1i3D85PnlM+j
h/NuFg6nUb1NupcB4J+ibzx/eL+80ablZDAqq5OKiskvDxiiTrQw4kC1TGlh+3rL
tFqqynKTU40N31nXRPHTG3bIfZsb3GHvXxEkJ1s1ufKKhk9WZKhCDOuSdduYrZX7
50kR5ptLn3YysJr1JTtt7xgT0ToSaxbre8ZWEKLCG8j8t2ONFDdJSskci+1VOUm3
FCkRLKILcnqFrQv7vnIa2tK6Xlg6jwcGQaVDB6KUIImGp8FatM0R6qP0iKM535+L
qAeYagvMjTUgwZXLIuUhwHWVk+1V54VjLlmBx6xfJ0a3MlfmtgdalruWfRAItSCq
ZjXW80wg0v3k/fsCPU5J+hY1
=OlH0
-----END PGP SIGNATURE-----
-- 
Markus Probst <markus.probst@posteo.de>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-04-11 15:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-11 15:07 [PATCH RESEND v13 0/3] rust: leds: add led classdev abstractions Markus Probst
2026-04-11 15:07 ` [PATCH RESEND v13 1/3] rust: leds: add basic " Markus Probst
2026-04-11 15:07 ` [PATCH RESEND v13 2/3] rust: leds: add Mode trait Markus Probst
2026-04-11 15:07 ` [PATCH RESEND v13 3/3] rust: leds: add multicolor classdev abstractions Markus Probst

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox