[PATCH] regulator: Use bitfield values for range selectors

David Laight David.Laight at ACULAB.COM
Mon Jun 12 03:13:40 PDT 2023


From: Chen-Yu Tsai
> Sent: 12 June 2023 10:27
> To: David Laight <David.Laight at ACULAB.COM>
> Cc: Mark Brown <broonie at kernel.org>; Liam Girdwood <lgirdwood at gmail.com>; Manivannan Sadhasivam
> <mani at kernel.org>; Cristian Ciocaltea <cristian.ciocaltea at gmail.com>; Matti Vaittinen
> <mazziesaccount at gmail.com>; linux-actions at lists.infradead.org; linux-kernel at vger.kernel.org; linux-
> arm-kernel at lists.infradead.org
> Subject: Re: [PATCH] regulator: Use bitfield values for range selectors
> 
> On Mon, Jun 12, 2023 at 3:48 PM David Laight <David.Laight at aculab.com> wrote:
> >
> > From: Chen-Yu Tsai
> > > Sent: 12 June 2023 04:39
> > >
> > > On Sun, Jun 11, 2023 at 1:10 AM David Laight <David.Laight at aculab.com> wrote:
> > > >
> > > > From: Chen-Yu Tsai
> > > > > Sent: 08 June 2023 08:57
> > > > >
> > > > > Right now the regulator helpers expect raw register values for the range
> > > > > selectors. This is different from the voltage selectors, which are
> > > > > normalized as bitfield values. This leads to a bit of confusion. Also,
> > > > > raw values are harder to copy from datasheets or match up with them,
> > > > > as datasheets will typically have bitfield values.
> > > > >
> > > > > Make the helpers expect bitfield values, and convert existing users.
> > > > > Include bitops.h explicitly for ffs(), and reorder the header include
> > > > > statements. While at it, also replace module.h with export.h, since the
> > > > > only use is EXPORT_SYMBOL_GPL.
> > > > >
> > > > ...
> > > > >  static const unsigned int atc260x_ldo_voltage_range_sel[] = {
> > > > > -     0x0, 0x20,
> > > > > +     0x0, 0x1,
> > > > >  };
> > > >
> > > > Is there any way the change can be done so that un-edited
> > > > modules fail to compile?
> > > > Otherwise the whole thing is an accident waiting to happen.
> > >
> > > I think we could change the field name in the regulator description?
> > > But unsuspecting end users / developers might just edit the name and not
> > > see that the scheme has changed.

Looking at it, that would seem to be needed.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)


More information about the linux-arm-kernel mailing list