rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v8 0/4] rust: leds: add led classdev abstractions
@ 2025-11-15 17:25 Markus Probst
  2025-11-15 17:25 ` [PATCH v8 1/4] rust: Add trait to convert a device reference to a bus device reference Markus Probst
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Markus Probst @ 2025-11-15 17:25 UTC (permalink / raw)
  To: Lee Jones, Pavel Machek, Greg Kroah-Hartman, Dave Ertman,
	Ira Weiny, Leon Romanovsky, Miguel Ojeda, Alex Gaynor, Boqun Feng,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Alice Ryhl, Trevor Gross, Danilo Krummrich, Rafael J. Wysocki,
	Bjorn Helgaas, Krzysztof Wilczyński
  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 abstraction to convert a device reference to a bus device
  reference for use in class device callbacks

* add basic led classdev abstractions to register and unregister leds

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

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 (4):
      rust: Add trait to convert a device reference to a bus device reference
      rust: leds: add basic led classdev abstractions
      rust: leds: split generic and normal led classdev abstractions up
      rust: leds: add multicolor classdev abstractions

 MAINTAINERS                     |   8 +
 rust/bindings/bindings_helper.h |   1 +
 rust/kernel/auxiliary.rs        |   7 +
 rust/kernel/device.rs           |  35 ++-
 rust/kernel/led.rs              | 550 ++++++++++++++++++++++++++++++++++++++++
 rust/kernel/led/multicolor.rs   | 195 ++++++++++++++
 rust/kernel/led/normal.rs       |  39 +++
 rust/kernel/lib.rs              |   1 +
 rust/kernel/pci.rs              |   7 +
 rust/kernel/platform.rs         |   7 +
 rust/kernel/usb.rs              |   6 +
 11 files changed, 855 insertions(+), 1 deletion(-)
---
base-commit: e9a6fb0bcdd7609be6969112f3fbfcce3b1d4a7c
change-id: 20251114-rust_leds-a959f7c2f7f9


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

end of thread, other threads:[~2025-11-15 20:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-15 17:25 [PATCH v8 0/4] rust: leds: add led classdev abstractions Markus Probst
2025-11-15 17:25 ` [PATCH v8 1/4] rust: Add trait to convert a device reference to a bus device reference Markus Probst
2025-11-15 17:26 ` [PATCH v8 2/4] rust: leds: add basic led classdev abstractions Markus Probst
2025-11-15 20:48   ` Markus Probst
2025-11-15 17:26 ` [PATCH v8 3/4] rust: leds: split generic and normal led classdev abstractions up Markus Probst
2025-11-15 17:26 ` [PATCH v8 4/4] rust: leds: add multicolor classdev abstractions Markus Probst
2025-11-15 20:47   ` Markus Probst

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).