Re: [PATCH 00/21] lib: add alternatives for GENMASK()
From: Linus Torvalds
Date: Thu Nov 27 2025 - 12:30:02 EST
On Thu, 27 Nov 2025 at 06:12, Nicolas Frattaroli
<nicolas.frattaroli@xxxxxxxxxxxxx> wrote:
>
> I think enforcing GENMASK to take constant values is a good idea in
> light of that, because people who really need a non-const version
> should make this explicit so that reviewers can catch it as a
> potential code smell, in addition to the less horrid preprocessor
> output.
So I did some very preliminary checking, and we do end up having more
GENMASK() users with non-constant arguments than I thought.
They are still a small minority - about 3% of the users - which is why
my first grep made me think "it's all just constants".
It's just not quite as tiny a minority as I thought from a quick visual grep.
IOW, there's about a thousand cases of GENMASK() with things that
aren't obvious constants.
So trying to get rid of them would be somewhat painful. Fairly easily
automated, but still..
Linus