Re: [PATCH v3 0/2] rust: miscdevice: add additional data to MiscDeviceRegistration

From: Alice Ryhl
Date: Mon May 19 2025 - 14:09:31 EST


On Sat, May 17, 2025 at 01:33:48PM +0200, Christian Schrefl wrote:
> Currently there is no good way to pass arbitrary data from the driver to
> a `miscdevice` or to share data between individual handles to a
> `miscdevice` in rust.
>
> This series adds additional (generic) data to the MiscDeviceRegistration
> for this purpose.
>
> The first patch implements the changes and fixes the build of the sample
> without changing any functionality (this is currently the only in tree
> user).
>
> The second patch changes the `rust_misc_device` sample to use this to
> share the same data between multiple handles to the `miscdevice`.
> I have tested the sample with qemu and the C userspace example
> from the doc comments.
>
> This series its based on my `UnsafePinned` series [0] and the
> pin-init-next branch.
>
> Some discussion on Zulip about the motivation and approach [1].
> Thanks a lot to everyone helping me out with this.
>
> Link: https://lore.kernel.org/rust-for-linux/20250430-rust_unsafe_pinned-v2-0-fc8617a74024@xxxxxxxxx/ [0]
> Link: https://rust-for-linux.zulipchat.com/#narrow/channel/288089-General/topic/Passing.20a.20DevRes.20to.20a.20miscdev/near/494553814 [1]
>
> Signed-off-by: Christian Schrefl <chrisi.schrefl@xxxxxxxxx>

Reviewed-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>

Danilo's comment on the design of miscdevice is fair - it does not match
other types of drivers. But this series is an improvement over what is
here today.

Alice