From: Jonathan Cameron <jic23@kernel.org>
To: "David Lechner (TI)" <dlechner@baylibre.com>
Cc: "Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>, "Chris Hall" <c-hall@ti.com>,
"Patrick Edwards" <pedwards@ti.com>,
"Kurt Borja" <kuurtb@gmail.com>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 3/3] iio: adc: ti-ads112c14: add continuous mode support
Date: Sun, 16 Aug 2026 21:26:12 +0100 [thread overview]
Message-ID: <20260816212612.4512d694@jic23-huawei> (raw)
In-Reply-To: <20260807-iio-adc-ti-ads112c14-continuous-mode-v3-3-76e0d30e6c6b@baylibre.com>
On Fri, 07 Aug 2026 16:19:48 -0500
"David Lechner (TI)" <dlechner@baylibre.com> wrote:
> Add support for continuous mode in the TI ADS112C14 ADC driver. In this
> mode the ADC itself is starting each conversion, so we add a trigger
> based on the DRDY interrupt to read each sample. This mode is also
> limited in that only one channel can be enabled at a time since the
> chip does not have a sequencer or simultaneous sampling capability.
> Continuous mode will only be used when this new trigger is the current
> trigger.
>
> Signed-off-by: David Lechner (TI) <dlechner@baylibre.com>
Hi David,
regmap_assign_bits() usage here is a bit odd.
It is just a bool taking wrapper around set_bits and clear_bits.
It 'works' here because the values are 0 and 1.
There isn't a natural bool for these two modes, so to make this look right
you'd end up with something like:
ADS112C14_DEVICE_CFG_CONV_MODE_SINGLE_NOT_CONT
and that is horrible. So I'd just use FIELD_PREP() and definitions
for the two values.
Otherwise looks fine to me.
J
> +
> +static int ads112c14_buffer_predisable(struct iio_dev *indio_dev)
> +{
> + struct ads112c14_data *data = iio_priv(indio_dev);
> + int ret;
> +
> + if (!ads112c14_using_drdy_trigger(indio_dev))
> + return 0;
> +
> + guard(mutex)(&data->lock);
> +
> + ret = regmap_write(data->regmap, ADS112C14_REG_CONVERSION_CTRL,
> + ADS112C14_CONVERSION_CTRL_STOP);
> + if (ret)
> + return ret;
> +
> + return regmap_assign_bits(data->regmap, ADS112C14_REG_DEVICE_CFG,
> + ADS112C14_DEVICE_CFG_CONV_MODE,
> + ADS112C14_DEVICE_CFG_CONV_MODE_SINGLE_SHOT);
This looks odd as last parameter that takes is a boolean.
I think you just want an update_bits + appropriate FIELD_PREP()
> +}
> +
> +static const struct iio_buffer_setup_ops ads112c14_buffer_setup_ops = {
> + .postenable = ads112c14_buffer_postenable,
> + .predisable = ads112c14_buffer_predisable,
> + .validate_scan_mask = ads112c14_validate_scan_mask,
> +};
> +
> static int ads112c14_populate_idac_mag(u32 current_nA, u8 *idac_mag)
> {
> u32 current_uA = current_nA / (NANO / MICRO);
> @@ -1480,6 +1594,19 @@ static int ads112c14_probe(struct i2c_client *client)
> 0, dev_name(dev), indio_dev);
> if (ret)
> return ret;
> +
> + data->drdy_trig = devm_iio_trigger_alloc(dev, "%s-dev%d-drdy",
> + info->name,
> + iio_device_id(indio_dev));
> + if (!data->drdy_trig)
> + return -ENOMEM;
> +
> + data->drdy_trig->ops = &ads112c14_trigger_ops;
> + iio_trigger_set_drvdata(data->drdy_trig, indio_dev);
> +
> + ret = devm_iio_trigger_register(dev, data->drdy_trig);
> + if (ret)
> + return ret;
> }
>
> ads112c14_populate_tables(data);
> @@ -1490,7 +1617,8 @@ static int ads112c14_probe(struct i2c_client *client)
>
> ret = devm_iio_triggered_buffer_setup(dev, indio_dev,
> iio_pollfunc_store_time,
> - ads112c14_trigger_handler, NULL);
> + ads112c14_trigger_handler,
> + &ads112c14_buffer_setup_ops);
> if (ret)
> return ret;
>
>
prev parent reply other threads:[~2026-08-16 20:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-07 21:19 [PATCH v3 0/3] iio: adc: ti-ads112c14: continuous mode support David Lechner (TI)
2026-08-07 21:19 ` [PATCH v3 1/3] iio: adc: ti-ads112c14: add DRDY interrupt support David Lechner (TI)
2026-08-10 8:50 ` Andy Shevchenko
2026-08-10 15:59 ` David Lechner
2026-08-10 17:01 ` Andy Shevchenko
2026-08-07 21:19 ` [PATCH v3 2/3] iio: adc: ti-ads112c14: create data read helper functions David Lechner (TI)
2026-08-07 21:19 ` [PATCH v3 3/3] iio: adc: ti-ads112c14: add continuous mode support David Lechner (TI)
2026-08-10 8:58 ` Andy Shevchenko
2026-08-16 20:26 ` Jonathan Cameron [this message]
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=20260816212612.4512d694@jic23-huawei \
--to=jic23@kernel.org \
--cc=andy@kernel.org \
--cc=c-hall@ti.com \
--cc=dlechner@baylibre.com \
--cc=kuurtb@gmail.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=pedwards@ti.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.