[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAGXv+5Hnrpv8kTU+0B9S4NyqALEz+DQOLfO3U7GwMZp9AoqLEw@mail.gmail.com>
Date: Mon, 12 Jun 2023 17:27:12 +0800
From: Chen-Yu Tsai <wenst@...omium.org>
To: David Laight <David.Laight@...lab.com>
Cc: Mark Brown <broonie@...nel.org>,
Liam Girdwood <lgirdwood@...il.com>,
Manivannan Sadhasivam <mani@...nel.org>,
Cristian Ciocaltea <cristian.ciocaltea@...il.com>,
Matti Vaittinen <mazziesaccount@...il.com>,
"linux-actions@...ts.infradead.org"
<linux-actions@...ts.infradead.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.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@...lab.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@...lab.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.
> >
> > Or we could add a sanity check at runtime that checks the values during
> > regulator registration. How does that sound?
> >
> > Mark, is this something you'd like?
>
> Can you change the name of the function the values are passed to?
.set_voltage_sel = regulator_set_voltage_sel_pickable_regmap,
This one, and
.get_voltage_sel = regulator_get_voltage_sel_pickable_regmap,
which calls the helper regulator_range_selector_to_index() that actually
uses the values.
Not sure how changing the helper names would help, or how it is different
from changing the field name? The names are already quite long but spot
on.
> Or maybe change the type to 'unsigned char' (assuming bit numbers
> are small).
That doesn't quite work if the range selector is in the upper four bits.
The values would fit nevertheless.
ChenYu
Powered by blists - more mailing lists