From: andy.shevchenko@gmail.com
To: George Stark <gnstark@sberdevices.ru>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
"jic23@kernel.org" <jic23@kernel.org>,
"lars@metafoo.de" <lars@metafoo.de>,
"neil.armstrong@linaro.org" <neil.armstrong@linaro.org>,
"khilman@baylibre.com" <khilman@baylibre.com>,
"jbrunet@baylibre.com" <jbrunet@baylibre.com>,
"martin.blumenstingl@googlemail.com"
<martin.blumenstingl@googlemail.com>,
"nuno.sa@analog.com" <nuno.sa@analog.com>,
"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-amlogic@lists.infradead.org"
<linux-amlogic@lists.infradead.org>,
kernel <kernel@sberdevices.ru>
Subject: Re: [PATCH v2] meson saradc: add iio device attrib to switch channel 7 mux
Date: Tue, 30 May 2023 02:32:58 +0300 [thread overview]
Message-ID: <ZHU2Khf84nbLW7Gg@surfacebook> (raw)
In-Reply-To: <9df82b13-7594-a8f0-f27e-87bce5a38b74@sberdevices.ru>
Mon, May 29, 2023 at 01:31:40AM +0300, George Stark kirjoitti:
> On 5/28/23 13:46, Andy Shevchenko wrote:
> > On Sun, May 28, 2023 at 12:48:54AM +0300, George Stark wrote:
...
> > > + if (index >= ARRAY_SIZE(chan7_vol))
> > > + index = ARRAY_SIZE(chan7_vol) - 1;
> > I think this is incorrect and prone to error in the future in case this array
> > will be extended. What I would expect is to return something like "unknown".
>
> I agree this part is unclean. Actually the register's last 3 (out of 8)
> possible values are stand for the same mux input "ch7_input". So
> theoretically we can read from register a value out of array bounds. There
> should be a comment at least.
You can add there in the array to extend it up to 8 entries, so it will be
clear. And for the rest you will return unknown / unsupported / etc.
...
> > > +static const char * const chan7_vol[] = {
> > > + "gnd",
> > > + "vdd/4",
> > > + "vdd/2",
> > > + "vdd*3/4",
> > > + "vdd",
> > > + "ch7_input",
> > > +};
> About the question of naming mux inputs from the other letter (vdd/2 vs
> 0.5Vdd etc).
> While I fully agree with you that point is better than slash but mixing
> letter cases... should we?
What's wrong with that?
> e.g. this is how iio_info output looks like now:
> ...
> voltage7: (input)
> 3 channel-specific attributes found:
> attr 0: mean_raw value: 0
> attr 1: raw value: 1
> attr 2: scale value: 0.439453125
> 4 device-specific attributes found:
> attr 0: chan7_mux value: gnd
> attr 1: chan7_mux_available value: gnd vdd/4 vdd/2 vdd*3/4
> vdd ch7_input
> attr 2: current_timestamp_clock value: realtime
>
> attr 3: waiting_for_supplier value: 0
>
> or naming with Jonathan's approach
> /sys/devices/platform/soc/fe000000.bus/fe002c00.adc/iio:device0/in_voltage_0.5vdd_raw
See the alternative I proposed is to have _ delimiter. But that might make
parsing a bit harder in user space.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2023-05-29 23:33 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-27 21:48 [PATCH v2] meson saradc: add iio device attrib to switch channel 7 mux George Stark
2023-05-28 10:46 ` Andy Shevchenko
2023-05-28 10:55 ` Andy Shevchenko
2023-05-28 11:00 ` Andy Shevchenko
2023-05-28 15:12 ` Jonathan Cameron
2023-05-28 22:31 ` George Stark
2023-05-29 23:32 ` andy.shevchenko [this message]
2023-05-28 15:11 ` Jonathan Cameron
2023-05-28 21:52 ` George Stark
2023-05-29 20:04 ` Martin Blumenstingl
2023-06-04 12:52 ` Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZHU2Khf84nbLW7Gg@surfacebook \
--to=andy.shevchenko@gmail.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=gnstark@sberdevices.ru \
--cc=jbrunet@baylibre.com \
--cc=jic23@kernel.org \
--cc=kernel@sberdevices.ru \
--cc=khilman@baylibre.com \
--cc=lars@metafoo.de \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.blumenstingl@googlemail.com \
--cc=neil.armstrong@linaro.org \
--cc=nuno.sa@analog.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox