Fwd: [PATCH] regmap: add regmap_update_bits variant to autoshift mask

From: Brandon Cheo Fusi
Date: Wed Nov 08 2023 - 09:34:20 EST


---------- Forwarded message ---------
From: Brandon Cheo Fusi <fusibrandon13@xxxxxxxxx>
Date: Wed, Nov 8, 2023 at 11:18 AM
Subject: Re: [PATCH] regmap: add regmap_update_bits variant to autoshift mask
To: Mark Brown <broonie@xxxxxxxxxx>


On Mon, Nov 6, 2023 at 5:54 PM Mark Brown <broonie@xxxxxxxxxx> wrote:
>
> On Mon, Nov 06, 2023 at 05:34:06PM +0100, Brandon Cheo Fusi wrote:
>
> > +static inline int regmap_update_bits_autoshift_val(struct regmap *map, unsigned int reg,
> > + unsigned int mask, unsigned int val)
> > +{
>
> Really not a fan of the name here, and in any case if the shifting of
> the value is an issue wouldn't this be a good case for using a field?

True. But all this does is handle the special and very common case of
'regmap_update_bits(regmap, reg, GENMASK(hi,lo), val)' where [hi,lo]
isn't at the bottom of reg. Most drivers don't resort to allocating
regmap_fields for each bit range they manipulate.

>
> Please also add kunit testcases for new APIs.

I'd be happy to send a v2 with kunit testcases, if you think the API is
worthwhile.