mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Fiona Behrens <me@kloenk.dev>
To: Lee Jones <lee@kernel.org>
Cc: "Pavel Machek" <pavel@ucw.cz>,
	linux-leds@vger.kernel.org, "Miguel Ojeda" <ojeda@kernel.org>,
	"Alex Gaynor" <alex.gaynor@gmail.com>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <benno.lossin@proton.me>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Trevor Gross" <tmgross@umich.edu>,
	"FUJITA Tomonori" <fujita.tomonori@gmail.com>,
	linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org
Subject: Re: [RFC PATCH 0/2] rust: LED abstractions
Date: Mon, 11 Nov 2024 11:21:30 +0100	[thread overview]
Message-ID: <468C6459-F13F-421D-B592-5B8425D57650@kloenk.dev> (raw)
In-Reply-To: <20241111094102.GA8552@google.com>



On 11 Nov 2024, at 10:41, Lee Jones wrote:

> On Wed, 09 Oct 2024, Fiona Behrens wrote:
>
>> This RFC implements a basic LED abstraction to show how this would work with rust.
>>
>> Currently this just implements a sample driver, to show how to use the abstraction, which just
>> prints the requested state, supporting a on/off LED and an led with brightness level up to 255 and
>> hardware blinking. I intend to write a hardware specific driver for submitting.
>>
>> The abstractions is a generic struct that holds a generic driver data on which the vtable is
>> implemented. Because this struct also holds the c led_classdev (include/linux/leds.h) struct this
>> struct is pinned and is using pin_init to create and directly register the LED.
>> Dropping the struct unregisteres the LED. I plan to also add devm functions later, but as device
>> abstractions in rust are not yet that far I opted agains that for the first iteration of the LED
>> abstractions.
>>
>> This is currently using core::time::Duration for the blinking interval, but will likely change that
>> to use the Delta time type from FUJITA Tomonori [1].
>>
>> This is requiring the Opaque::try_ffi_init patch by Alice Ryhl[2] which just got merged into
>> char-misc-testing.
>>
>> [1]: https://lore.kernel.org/rust-for-linux/20241005122531.20298-3-fujita.tomonori@gmail.com/
>> [2]: https://lore.kernel.org/rust-for-linux/20240926-b4-miscdevice-v1-1-7349c2b2837a@google.com/
>>
>> Fiona Behrens (2):
>>   rust: LED abstraction
>>   samples: rust: led sample
>>
>>  rust/kernel/leds.rs      | 399 +++++++++++++++++++++++++++++++++++++++
>>  rust/kernel/lib.rs       |   2 +
>>  samples/rust/Kconfig     |  10 +
>>  samples/rust/Makefile    |   1 +
>>  samples/rust/rust_led.rs | 103 ++++++++++
>>  5 files changed, 515 insertions(+)
>>  create mode 100644 rust/kernel/leds.rs
>>  create mode 100644 samples/rust/rust_led.rs
>
> FYI: I'm not ignoring this patch-set.  On the contrary.  I'm trying to
> place myself into a position where I can not only review it with some
> confidence, but use it to author LED drivers.
>

Ah amazing, the first RFC was to probe for a general would LED accept rust code, and this sounds like a yes. Nice!

Currently still working on a LED driver for a Lenovo board that does not (as of when I started, and think still not yet) have a C driver for the LED. Current things missing is a static dmi match table (idea is to hardcoded that for now) and a abstraction for port memory but working on that, and can otherwise just go around that with unsafe calls in the driver itself.

  - Fiona

> -- 
> Lee Jones [李琼斯]

      reply	other threads:[~2024-11-11 10:29 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-09 10:57 Fiona Behrens
2024-10-09 10:57 ` [RFC PATCH 1/2] rust: LED abstraction Fiona Behrens
2024-11-16 15:47   ` Marek Behún
2024-11-18 10:19     ` Alice Ryhl
2024-11-18 16:39       ` Miguel Ojeda
2024-11-18 10:22   ` Alice Ryhl
2024-11-21  9:47     ` Fiona Behrens
2024-11-27 11:39       ` Alice Ryhl
2024-10-09 10:57 ` [RFC PATCH 2/2] samples: rust: led sample Fiona Behrens
2024-11-11  9:41 ` [RFC PATCH 0/2] rust: LED abstractions Lee Jones
2024-11-11 10:21   ` Fiona Behrens [this message]

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=468C6459-F13F-421D-B592-5B8425D57650@kloenk.dev \
    --to=me@kloenk.dev \
    --cc=a.hindborg@kernel.org \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=benno.lossin@proton.me \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=fujita.tomonori@gmail.com \
    --cc=gary@garyguo.net \
    --cc=lee@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=ojeda@kernel.org \
    --cc=pavel@ucw.cz \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tmgross@umich.edu \
    /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

all inboxes | Powered by JetHome®