Re: [PATCH 3/3] sample: rust: Add GPIO consumer sample driver

From: Kohei Ito

Date: Sun Sep 13 2026 - 04:46:35 EST


Hi, Bartosz,

On Thu, Sep 10, 2026 at 12:37:17AM -0700, Bartosz Golaszewski wrote:
> On Sun, 6 Sep 2026 10:45:51 +0200, Kohei Ito <koheiito.dev@xxxxxxxxx> said:
> > Add a sample driver to demonstrate the use of the Rust GPIO APIs.
> >
> > Signed-off-by: Kohei Ito <koheiito.dev@xxxxxxxxx>
> > ---
>
> I don't like samples as they rarely get built or tested. We seem to already
> have kunit support for rust, wouldn't it make more sense to implement a kunit
> module for rust GPIO abstractions? If we don't have provider abstractions, you
> should be able to reuse gpio-sim as the GPIO controller for testing just by
> instantiating simulated GPIO devices.

Thank you for your suggestion.

I assume the kunit module you have in mind would be implemented like
`gpiolib-kunit.c`. Based on your comment, I agree that a kunit-based
approach is more appropriate than a sample driver.

However, as far as I know, we don't yet have Rust abstractions for
platform_device registration and software_node, which are required to
implement a kunit-based module for testing GPIO consumer APIs. Given the
current state of Rust for Linux, I think creating a sample driver is a
more practical approach for now. I would like to consider migrating to a
kunit-based module as future work.

Best regards,
Kohei Ito