Re: [PATCH v2 2/2] rust: miscdevice: add base miscdevice abstraction

From: Alice Ryhl
Date: Tue Oct 01 2024 - 05:13:26 EST


On Tue, Oct 1, 2024 at 10:54 AM Dirk Behme <dirk.behme@xxxxxxxxxxxx> wrote:
>
> On 01.10.2024 10:22, Alice Ryhl wrote:
> ....
> > diff --git a/rust/kernel/miscdevice.rs b/rust/kernel/miscdevice.rs
> > new file mode 100644
> > index 000000000000..cbd5249b5b45
> > --- /dev/null
> > +++ b/rust/kernel/miscdevice.rs
> ...
> > +/// Trait implemented by the private data of an open misc device.
> > +#[vtable]
> > +pub trait MiscDevice {
> > + /// What kind of pointer should `Self` be wrapped in.
> > + type Ptr: ForeignOwnable + Send + Sync;
> > +
> > + /// Called when the misc device is opened.
> > + ///
> > + /// The returned pointer will be stored as the private data for the file.
> > + fn open() -> Result<Self::Ptr>;
> > +
> > + /// Called when the misc device is released.
> > + fn release(device: Self::Ptr) {
> > + drop(device);
> > + }
> > +
> > + /// Handler for ioctls.
> > + ///
> > + /// The `cmd` argument is usually manipulated using the utilties in [`kernel::ioctl`].
>
> Nit: utilties -> utilities

Thanks!

Alice