Re: [PATCH v3 0/4] rust: extend `module!` macro with integer parameter support

Josh Triplett
2024-12-18T02:16:54Z

On Mon, Dec 16, 2024 at 04:48:21PM +0100, Miguel Ojeda wrote:
> On Mon, Dec 16, 2024 at 4:39 PM Miguel Ojeda
> <miguel.ojeda.sandonis@gmail.com> wrote:
> >
> > Agreed. I would suggest to consider marking it as a Rust reference
> > driver, since it is a prime candidate for it:
> >
> > https://rust-for-linux.com/rust-reference-drivers
> >
> > That way, it is clearer that the duplication is meant to build the
> > abstractions and temporary in the long-term.
> >
> > Then we can also easily track which ones are meant to be those, and
> > Greg can get justifiably angry at you/us if the duplication isn't
> > resolved when the right time comes... :)
>
> By the way, I half-jokingly suggested this elsewhere, but we could
> trivially allow module parameters only for particular modules, i.e.
> only allow to use the `params` key here if the name matches `rnull`
> (or if they set a special flag or whatever).
>
> Yes, it is a hack, but it would give people pause when trying to use
> the feature, i.e. to think twice. And, to me, it makes sense to
> encode/acknowledge this kind of thing explicitly anyway.
>
> So if that would unblock this and reduce the chance of repeating
> mistakes of the past, then we can easily do that too.

This seems like a great idea. An allowlist of drivers that are allowed
to use module parameters would encourage *new* drivers to not use them,
and that allowlist can have a comment atop it saying "Only add your
driver to this list if it needs to maintain an interface compatible with
an existing driver in order to avoid breaking userspace. Otherwise, use
configfs, sysfs, debugfs, or something else other than module
parameters."

I wonder if we can implement such an allowlist for C modules, too. :)