Messages in this thread |  | | Date | Sun, 4 Oct 2026 01:58:10 +0900 | | From | Kohei Ito <> | | Subject | Re: [PATCH 3/3] sample: rust: Add GPIO consumer sample driver |
| |
Hi Bartosz, Alexandre,
Thank you for your advice.
> >> The best approach I think is a combination of a Rust consumer driver and > >> a C kunit module dedicated to testing the consumer driver. This is > >> almost the same as `drivers/gpio/gpiolib-kunit.c`, except that instead > >> of directly exercising the GPIO consumer APIs, the module I'm suggesting > >> exercises them indirectly, through the Rust consumer driver. > >> > > > > Can't you just call a C function registering the platform device from unsafe > > rust? > > You should be able to. It's a but laborious, but better than not having > tests at all, and acceptable as a temporary solution IMHO. > > Of course an even better solution would be to provide a safe abstraction > for registering platform devices. :) I don't know exactly how much work > that would be, but there is already a `platform` module, so supposedly > we wouldn't be starting from absolute scratch.
Sure. I'll explore the Rust kunit approach by directly calling C functions to register `platform_device` and `software_node` from unsafe Rust. I'll also drop the sample driver. I'll let you know if I face problems.
Best regards, Kohei Ito
|  |