From: Joshua Crofts <joshua.crofts1@gmail.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: "Andy Shevchenko" <andriy.shevchenko@intel.com>,
"Petar Stepanovic" <pstepanovic@axiado.com>,
"Akhila Kavi" <akavi@axiado.com>,
"Prasad Bolisetty" <pbolisetty@axiado.com>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Harshit Shah" <hshah@axiado.com>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 2/2] iio: adc: add Axiado SARADC driver
Date: Mon, 17 Aug 2026 13:59:20 +0200 [thread overview]
Message-ID: <20260817135920.0000461d@gmail.com> (raw)
In-Reply-To: <20260817034541.053dac28@jic23-huawei>
On Mon, 17 Aug 2026 03:45:41 +0100
Jonathan Cameron <jic23@kernel.org> wrote:
> On Mon, 10 Aug 2026 21:27:26 +0300
> Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
>
> > On Mon, Aug 10, 2026 at 07:49:36AM -0700, Petar Stepanovic wrote:
> > > Add support for the SARADC controller found on Axiado AX3000 and
> > > AX3005 SoCs.
> > >
> > > The driver supports single-shot voltage reads through the IIO
> > > subsystem. The number of available input channels is selected from
> > > the SoC match data, allowing AX3000 and AX3005 variants to use the
> > > same driver.
> >
> > ...
> >
> > > +/* MANUAL_CTRL register fields */
> >
> > ^^^
> >
> > > +#define AX_SARADC_MANUAL_CTRL_ENABLE BIT(0)
> > > +#define AX_SARADC_MANUAL_CTRL_CH_SEL_MASK GENMASK(4, 1)
> > > +
> > > +#define AX_RESOLUTION_BITS 10
> > > +#define AX_SARADC_CONV_CYCLES 13
> > > +#define AX_SARADC_CONV_DELAY_MARGIN_US 10
> > > +
> > > +struct axiado_saradc {
> > > + struct regmap *regmap;
> > > + struct mutex lock; /* Serializes ADC conversions. */
> >
> > Choose the same style for all single-line comments (here is a period present
> > while in the above, for instance, there is none).
>
> Hmm. It is inconsistent in other places, but those two are arguably
> correct. The second is a sentence, the first is not (no verb)
>
> Anyhow, I did a sweep for other sentences and not all of them have
> periods. Given the rest of the driver looked fine to me and the other
> suggestions Andy made are easy to apply.
>
> Applied with the following diff to the testing branch of iio.git
> Note I'm fine with rebasing that (and will do on rc1 once that's available)
> so extra tags or review comments are easy to add for a few weeks at least.
>
> Mostly I did this just to reduce how many patch sets were undergoing
> revisions... I'm still over a 100 emails to read and run out of
> time for today.
>
> Jonathan
>
>
> diff --git a/drivers/iio/adc/axiado_saradc.c b/drivers/iio/adc/axiado_saradc.c
> index daa98dd2f176..699ee31616fc 100644
> --- a/drivers/iio/adc/axiado_saradc.c
> +++ b/drivers/iio/adc/axiado_saradc.c
> @@ -34,10 +34,10 @@
> #define AX_SARADC_GLOBAL_CTRL_PD BIT(2)
> #define AX_SARADC_GLOBAL_CTRL_ENABLE BIT(0)
>
> -/* GLOBAL_CTRL SAMPLE_MASK field value: 0 selects 16 samples */
> +/* GLOBAL_CTRL SAMPLE_MASK field value: 0 selects 16 samples. */
> #define AX_SARADC_GLOBAL_CTRL_SAMPLE_16 0
>
> -/* GLOBAL_CTRL MODE_MASK field value: 1 selects manual mode */
> +/* GLOBAL_CTRL MODE_MASK field value: 1 selects manual mode. */
> #define AX_SARADC_GLOBAL_CTRL_MODE_MANUAL 1
>
> /* MANUAL_CTRL register fields */
> @@ -76,16 +76,15 @@ static int axiado_saradc_conversion(struct axiado_saradc *info,
>
> guard(mutex)(&info->lock);
>
> - /* Select the channel to be used and trigger conversion */
> + /* Select the channel to be used and trigger conversion. */
> ret = regmap_write(info->regmap, AX_SARADC_MANUAL_CTRL_REG,
> AX_SARADC_MANUAL_CTRL_ENABLE |
> FIELD_PREP(AX_SARADC_MANUAL_CTRL_CH_SEL_MASK, chan->channel));
> if (ret)
> return ret;
>
> - /* Hardware requires 13 conversion cycles at clk_rate */
> - usecs = DIV_ROUND_UP(AX_SARADC_CONV_CYCLES * USEC_PER_SEC,
> - info->clk_rate);
> + /* Hardware requires 13 conversion cycles at clk_rate. */
> + usecs = DIV_ROUND_UP(AX_SARADC_CONV_CYCLES * USEC_PER_SEC, info->clk_rate);
> fsleep(usecs + AX_SARADC_CONV_DELAY_MARGIN_US);
>
> ret = regmap_read(info->regmap, AX_SARADC_DOUT_REG, ®val);
> @@ -220,7 +219,7 @@ static int axiado_saradc_probe(struct platform_device *pdev)
>
> soc_data = device_get_match_data(dev);
> if (!soc_data)
> - return dev_err_probe(dev, -EINVAL, "failed to get match data\n");
> + return dev_err_probe(dev, -ENODATA, "failed to get match data\n");
> >
> > > + unsigned long clk_rate;
> > > + int vref_uV;
> > > +};
> >
> > ...
> >
> > > +static int axiado_saradc_conversion(struct axiado_saradc *info,
> > > + struct iio_chan_spec const *chan, int *val)
> > > +{
> > > + unsigned long usecs;
> > > + unsigned int regval;
> > > + int ret;
> > > +
> > > + guard(mutex)(&info->lock);
> > > +
> > > + /* Select the channel to be used and trigger conversion */
> > > + ret = regmap_write(info->regmap, AX_SARADC_MANUAL_CTRL_REG,
> > > + AX_SARADC_MANUAL_CTRL_ENABLE |
> > > + FIELD_PREP(AX_SARADC_MANUAL_CTRL_CH_SEL_MASK, chan->channel));
> > > + if (ret)
> > > + return ret;
> > > +
> > > + /* Hardware requires 13 conversion cycles at clk_rate */
> >
> > > + usecs = DIV_ROUND_UP(AX_SARADC_CONV_CYCLES * USEC_PER_SEC,
> > > + info->clk_rate);
> >
> > I think it's okay to have this on a single line (83 characters).
> >
> > > + fsleep(usecs + AX_SARADC_CONV_DELAY_MARGIN_US);
> > > +
> > > + ret = regmap_read(info->regmap, AX_SARADC_DOUT_REG, ®val);
> > > +
> > > + /* Best effort to stop manual conversion. */
> > > + regmap_write(info->regmap, AX_SARADC_MANUAL_CTRL_REG, 0);
> > > +
> > > + if (ret)
> > > + return ret;
> > > +
> > > + *val = regval & GENMASK(AX_RESOLUTION_BITS - 1, 0);
> > > +
> > > + return 0;
> > > +}
> >
> > ...
> >
> > > + soc_data = device_get_match_data(dev);
> > > + if (!soc_data)
> > > + return dev_err_probe(dev, -EINVAL, "failed to get match data\n");
> >
> > -ENODATA
> >
>
>
With the diff Jonathan sent in mind,
Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>
--
Kind regards,
Joshua Crofts
next prev parent reply other threads:[~2026-08-17 11:59 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-10 14:49 [PATCH v5 0/2] iio: adc: Add " Petar Stepanovic
2026-08-10 14:49 ` [PATCH v5 1/2] dt-bindings: iio: adc: add Axiado AX3000/AX3005 SARADC Petar Stepanovic
2026-08-10 14:49 ` [PATCH v5 2/2] iio: adc: add Axiado SARADC driver Petar Stepanovic
2026-08-10 18:27 ` Andy Shevchenko
2026-08-17 2:45 ` Jonathan Cameron
2026-08-17 11:59 ` Joshua Crofts [this message]
2026-08-18 2:07 ` Jonathan Cameron
2026-08-17 11:56 ` Joshua Crofts
2026-08-17 13:05 ` Andy Shevchenko
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=20260817135920.0000461d@gmail.com \
--to=joshua.crofts1@gmail.com \
--cc=akavi@axiado.com \
--cc=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=hshah@axiado.com \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=pbolisetty@axiado.com \
--cc=pstepanovic@axiado.com \
--cc=robh@kernel.org \
/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
all inboxes | Powered by JetHome®