From: Matti Vaittinen <mazziesaccount@gmail.com>
To: Jonathan Cameron <jic23@kernel.org>,
David Lechner <dlechner@baylibre.com>
Cc: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>,
Lars-Peter Clausen <lars@metafoo.de>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>, Nuno Sa <nuno.sa@analog.com>,
Javier Carrasco <javier.carrasco.cruz@gmail.com>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH RFC v3 8/8] iio: ti-adc128s052: Drop variable vref
Date: Mon, 14 Apr 2025 09:03:06 +0300 [thread overview]
Message-ID: <f705fa4e-331b-46a1-9640-d33e83f7a894@gmail.com> (raw)
In-Reply-To: <20250412124229.7917e2df@jic23-huawei>
On 12/04/2025 14:42, Jonathan Cameron wrote:
> On Fri, 11 Apr 2025 08:34:42 -0500
> David Lechner <dlechner@baylibre.com> wrote:
>
>> On 4/7/25 6:37 AM, Matti Vaittinen wrote:
>>> According to Jonathan, variable reference voltages are very rare. It is
>>> unlikely it is needed, and supporting it makes the code a bit more
>>> complex.
>>>
>>> Simplify the driver and drop the variable vref support.
>>>
>>> Suggested-by: Jonathan Cameron <jic23@kernel.org>
>>> Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
>>>
>>> ---
>>
>> ...
>>
>>> static int adc128_probe(struct spi_device *spi)
>>> {
>>> const struct adc128_configuration *config;
>>> @@ -183,17 +173,12 @@ static int adc128_probe(struct spi_device *spi)
>>> indio_dev->channels = config->channels;
>>> indio_dev->num_channels = config->num_channels;
>>>
>>> - adc->reg = devm_regulator_get(&spi->dev, config->refname);
>>> - if (IS_ERR(adc->reg))
>>> - return PTR_ERR(adc->reg);
>>> + adc->vref_mv = devm_regulator_get_enable_read_voltage(&spi->dev,
>>> + config->refname);
>>> + if (adc->vref_mv < 0)
>>> + return adc->vref_mv;
>>>
>>> - ret = regulator_enable(adc->reg);
>>> - if (ret < 0)
>>> - return ret;
>>> - ret = devm_add_action_or_reset(&spi->dev, adc128_disable_regulator,
>>> - adc->reg);
>>> - if (ret)
>>> - return ret;
>>> + adc->vref_mv /= 1000;
>>
>> In other drivers, we've been doing:
>>
>> ret = devm_regulator_get_enable_read_voltage(...);
>> if (ret < 0)
>> return dev_err_probe(dev, ret, "failed to read '%s' voltage, ...);
>>
>> adc->vref_mv = ret / 1000;
>>
>> It can be easy to make a typo or forget to specify the voltage when creating
>> a .dts, so I think the error message is helpful to catch that.
>>
>> And we use ret to avoid having adc->vref_mv temporarily holding a
>> value with the wrong units (and can make it have an unsigned type).
>
> Good idea.
> Applied patches 1-7. I did tweak this one as well but then couldn't make
> up my mind on whether to change the type of vref_mv so I'll avoid making
> a decision and will leave patch 8 for a v4 from Matti :)
Thanks for handling the 1-7 :) I'll re-spin this, but it's likely to
take some time. I'm having 2 weeks off from work, and my motorbike and
boat is requiring some attention ;)
I hope I have regained a lot of energy after 2 weeks ;)
>
> Jonathan
>
>
>
>>
>>>
>>> if (config->num_other_regulators) {
>>> ret = devm_regulator_bulk_get_enable(&spi->dev,
>>
>
Yours,
-- Matti
next prev parent reply other threads:[~2025-04-14 6:03 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-07 10:44 [PATCH v3 0/8] Support ROHM BD79104 ADC Matti Vaittinen
2025-04-07 10:45 ` [PATCH v3 1/8] dt-bindings: " Matti Vaittinen
2025-04-07 11:35 ` [PATCH v3 2/8] iio: adc: ti-adc128s052: Simplify using be16_to_cpu() Matti Vaittinen
2025-04-07 11:36 ` [PATCH v3 3/8] iio: adc: ti-adc128s052: Be consistent with arrays Matti Vaittinen
2025-04-07 11:36 ` [PATCH v3 4/8] iio: adc: ti-adc128s052: Use devm_mutex_init() Matti Vaittinen
2025-04-07 11:36 ` [PATCH v3 5/8] iio: adc: ti-adc128s052: Simplify using guard(mutex) Matti Vaittinen
2025-04-07 11:36 ` [PATCH v3 6/8] iio: adc: ti-adc128s052: Support ROHM BD79104 Matti Vaittinen
2025-04-07 11:36 ` [PATCH v3 7/8] MAINTAINERS: A driver for TI/ROHM ADCs Matti Vaittinen
2025-04-07 11:37 ` [PATCH RFC v3 8/8] iio: ti-adc128s052: Drop variable vref Matti Vaittinen
2025-04-11 13:34 ` David Lechner
2025-04-12 11:42 ` Jonathan Cameron
2025-04-14 6:03 ` Matti Vaittinen [this message]
2025-04-14 6:00 ` Matti Vaittinen
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=f705fa4e-331b-46a1-9640-d33e83f7a894@gmail.com \
--to=mazziesaccount@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=javier.carrasco.cruz@gmail.com \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matti.vaittinen@fi.rohmeurope.com \
--cc=nuno.sa@analog.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;
as well as URLs for NNTP newsgroup(s).