[PATCH v4 0/2] rust: leds: add led classdev abstractions

Markus Probst posted 2 patches 2 months, 1 week ago
There is a newer version of this series
rust/kernel/alloc.rs      |   1 +
rust/kernel/alloc/kvec.rs |  86 ++++++++++
rust/kernel/led.rs        | 333 ++++++++++++++++++++++++++++++++++++++
rust/kernel/lib.rs        |   1 +
rust/kernel/prelude.rs    |   2 +-
5 files changed, 422 insertions(+), 1 deletion(-)
create mode 100644 rust/kernel/led.rs
[PATCH v4 0/2] rust: leds: add led classdev abstractions
Posted by Markus Probst 2 months, 1 week ago
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 Pin<Vec<T, A>> abstractions, that allow to initialize PinInit items with
  the guarantee that these will never be moved.

* add basic led classdev abstractions to register and unregister leds

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

Markus Probst (2):
  rust: add basic Pin<Vec<T, A>> abstractions
  rust: leds: add basic led classdev abstractions

 rust/kernel/alloc.rs      |   1 +
 rust/kernel/alloc/kvec.rs |  86 ++++++++++
 rust/kernel/led.rs        | 333 ++++++++++++++++++++++++++++++++++++++
 rust/kernel/lib.rs        |   1 +
 rust/kernel/prelude.rs    |   2 +-
 5 files changed, 422 insertions(+), 1 deletion(-)
 create mode 100644 rust/kernel/led.rs

-- 
2.49.1

Re: [PATCH v4 0/2] rust: leds: add led classdev abstractions
Posted by Benno Lossin 2 months, 1 week ago
On Sun Oct 12, 2025 at 4:52 PM CEST, Markus Probst wrote:
> 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 Pin<Vec<T, A>> abstractions, that allow to initialize PinInit items with
>   the guarantee that these will never be moved.
>
> * add basic led classdev abstractions to register and unregister leds
>
> Changes since v3:
> * fixed kunit tests failing because of example in documentation

Please give time for more feedback before sending a new version.

---
Cheers,
Benno