From: Jonathan Cameron <jic23@kernel.org>
To: Joel Stanley <joel@jms.id.au>,
Quentin Schulz <quentin.schulz@free-electrons.com>
Cc: Rick Altherr <raltherr@google.com>,
OpenBMC Maillist <openbmc@lists.ozlabs.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
William Breathitt Gray <vilhelm.gray@gmail.com>,
Andreas Klinger <ak@it-klinger.de>, Rob Herring <robh@kernel.org>,
linux-iio@vger.kernel.org, Hartmut Knaack <knaack.h@gmx.de>,
Geert Uytterhoeven <geert@linux-m68k.org>,
Marek Vasut <marek.vasut+renesas@gmail.com>,
Matt Ranostay <mranostay@gmail.com>,
Lars-Peter Clausen <lars@metafoo.de>,
Crestez Dan Leonard <leonard.crestez@intel.com>,
Akinobu Mita <akinobu.mita@gmail.com>,
Fabrice Gasnier <fabrice.gasnier@st.com>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
Maxime Ripard <maxime.ripard@free-electrons.com>,
Jacopo Mondi <jacopo@jmondi.org>
Subject: Re: [PATCH v2 2/2] iio: Aspeed AST2400/AST2500 ADC
Date: Sat, 25 Mar 2017 17:11:48 +0000 [thread overview]
Message-ID: <866cabad-d151-a54f-e316-201aa05cbbf5@kernel.org> (raw)
In-Reply-To: <CACPK8XcoQGo4uErK71aeUhmcJ-6Yt0k41q8N7wsemz6HLRSL4w@mail.gmail.com>
On 22/03/17 10:08, Joel Stanley wrote:
> Hello Quentin,
>
> On Wed, Mar 22, 2017 at 5:51 PM, Quentin Schulz
> <quentin.schulz@free-electrons.com> wrote:
>
>>> +
>>> +#define ASPEED_ADC_CHAN(_idx, _addr) { \
>>> + .type = IIO_VOLTAGE, \
>>> + .indexed = 1, \
>>> + .channel = (_idx), \
>>> + .address = (_addr), \
>>> + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
>>> + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \
>>> + BIT(IIO_CHAN_INFO_SAMP_FREQ), \
>>> +}
>>> +
>>> +static const struct iio_chan_spec aspeed_adc_iio_channels[] = {
>>> + ASPEED_ADC_CHAN(0, 0x10),
>>> + ASPEED_ADC_CHAN(1, 0x12),
>>> + ASPEED_ADC_CHAN(2, 0x14),
>>> + ASPEED_ADC_CHAN(3, 0x16),
>>> + ASPEED_ADC_CHAN(4, 0x18),
>>> + ASPEED_ADC_CHAN(5, 0x1A),
>>> + ASPEED_ADC_CHAN(6, 0x1C),
>>> + ASPEED_ADC_CHAN(7, 0x1E),
>>> + ASPEED_ADC_CHAN(8, 0x20),
>>> + ASPEED_ADC_CHAN(9, 0x22),
>>> + ASPEED_ADC_CHAN(10, 0x24),
>>> + ASPEED_ADC_CHAN(11, 0x26),
>>> + ASPEED_ADC_CHAN(12, 0x28),
>>> + ASPEED_ADC_CHAN(13, 0x2A),
>>> + ASPEED_ADC_CHAN(14, 0x2C),
>>> + ASPEED_ADC_CHAN(15, 0x2E),
>>
>> It would make sense to name the registers (the _addr parameter of your
>> macro) so it's easier to understand what it refers to.
>
> I appreciate the desire to not have magic values. However, I think
> these are okay. We don't use them anywhere else, and it is obvious
> from reading that they are the registers containing the ADC values for
> each channel.
>
> The alternative would look like this:
>
> + ASPEED_ADC_CHAN(14, ASPEED_ADC_CHAN_14_DATA),
> + ASPEED_ADC_CHAN(15, ASPEED_ADC_CHAN_15_DATA),
>
> Which doesn't really help me as someone reading the code.
>
>>> + /* Start all channels in normal mode. */
>>> + clk_prepare_enable(data->clk_scaler->clk);
>>> + adc_engine_control_reg_val = GENMASK(31, 16) |
>>> + ASPEED_ADC_OPERATION_MODE_NORMAL | ASPEED_ADC_ENGINE_ENABLE;
>>> + writel(adc_engine_control_reg_val,
>>> + data->base + ASPEED_ADC_REG_ENGINE_CONTROL);
>>> +
>>> + indio_dev->name = dev_name(&pdev->dev);
>>
>> This isn't good practice (cf.: https://lkml.org/lkml/2017/1/28/145 end
>> of the mail in the probe function). Better name it aspeed-adc or even
>> better to have a different name per compatible: ast2400-adc or ast2500-adc.
>
> The label comes out as "adc.1e6e9000". This is the reg property and
> the node name from the device tree, which seems sensible, even if it
> is a bit strange to be grabbing the name of the parent device for it
The intent is this provides the part number rather than a device tree
handle. The devicetree handle is available via other routes if desired.
.
>
> Could the iio core fill in a sensible name for us here? Rick is the
> 31st person to make this mistake, so it would be nice to fix properly.
It's not easy to actually generate it. Quite a few drivers do it by
querying the hardware to get precise model numbers. Manufacturers
of certain devices have an irritating habit of switching 'compatiblish'
chips without bothering to update device tree blobs.
Jonathan
>
> Cheers,
>
> Joel
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
next prev parent reply other threads:[~2017-03-25 17:19 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-21 20:48 [PATCH v2 1/2] Documentation: dt-bindings: Document bindings for Aspeed AST2400/AST2500 ADC Rick Altherr
2017-03-21 20:48 ` [PATCH v2 2/2] iio: " Rick Altherr
2017-03-21 21:14 ` Peter Meerwald-Stadler
[not found] ` <CAPLgG=kVewvVzcrWMzK+XyNWLjiEs6nr_hykfC2bbdpeLsf4aw@mail.gmail.com>
2017-03-23 16:54 ` Rick Altherr
2017-03-22 7:21 ` Quentin Schulz
2017-03-22 10:08 ` Joel Stanley
2017-03-25 17:11 ` Jonathan Cameron [this message]
[not found] ` <CAPLgG=kVsNake71fFLc2NsoMtrtG0_6Fb6XHep3dQKVuRgOmbA@mail.gmail.com>
2017-03-23 7:52 ` Quentin Schulz
2017-03-23 16:57 ` Rick Altherr
2017-03-22 9:47 ` Joel Stanley
2017-03-25 17:20 ` Jonathan Cameron
2017-03-23 2:42 ` kbuild test robot
2017-03-23 5:52 ` kbuild test robot
2017-03-21 21:16 ` [PATCH v2 1/2] Documentation: dt-bindings: Document bindings for " Peter Meerwald-Stadler
2017-03-29 0:33 ` Rob Herring
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=866cabad-d151-a54f-e316-201aa05cbbf5@kernel.org \
--to=jic23@kernel.org \
--cc=ak@it-klinger.de \
--cc=akinobu.mita@gmail.com \
--cc=fabrice.gasnier@st.com \
--cc=geert@linux-m68k.org \
--cc=jacopo@jmondi.org \
--cc=joel@jms.id.au \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=leonard.crestez@intel.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marek.vasut+renesas@gmail.com \
--cc=martin.blumenstingl@googlemail.com \
--cc=maxime.ripard@free-electrons.com \
--cc=mranostay@gmail.com \
--cc=openbmc@lists.ozlabs.org \
--cc=pmeerw@pmeerw.net \
--cc=quentin.schulz@free-electrons.com \
--cc=raltherr@google.com \
--cc=robh@kernel.org \
--cc=vilhelm.gray@gmail.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;
as well as URLs for NNTP newsgroup(s).