[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e8734476-2b47-4031-92fe-98b325629408@baylibre.com>
Date: Wed, 17 Sep 2025 08:14:57 -0500
From: David Lechner <dlechner@...libre.com>
To: Andy Shevchenko <andriy.shevchenko@...el.com>
Cc: Marilene Andrade Garcia <marilene.agarcia@...il.com>,
linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org,
devicetree@...r.kernel.org, Kim Seer Paller <kimseer.paller@...log.com>,
Lars-Peter Clausen <lars@...afoo.de>,
Michael Hennerich <Michael.Hennerich@...log.com>,
Jonathan Cameron <jic23@...nel.org>, Nuno Sá
<nuno.sa@...log.com>, Andy Shevchenko <andy@...nel.org>,
Rob Herring <robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>,
Marcelo Schmitt <marcelo.schmitt1@...il.com>,
Marcelo Schmitt <Marcelo.Schmitt@...log.com>,
Ceclan Dumitru <dumitru.ceclan@...log.com>,
Jonathan Santos <Jonathan.Santos@...log.com>,
Dragos Bogdan <dragos.bogdan@...log.com>
Subject: Re: [PATCH v11 2/3] iio: adc: max14001: New driver
On 9/17/25 3:10 AM, Andy Shevchenko wrote:
> On Tue, Sep 16, 2025 at 01:04:41PM -0500, David Lechner wrote:
>> On 9/15/25 5:16 PM, Marilene Andrade Garcia wrote:
>
...
>>> + if (ret < 0)
>>> + ret = 1250000;
>>> + else
>>> + ext_vrefin = 1;
>>> + st->vref_mV = ret / (MICRO / MILLI);
>>
>> Just a style choice here, but in other drivers with similar handling
>> we wrote it like this to avoid the extra if statement:
>
> I didn't get this. You move from clear if to not-so-clear ternary. How is
> the proposed code better?
I can't say one is better than the other. What I suggested is just
how we've done it other similar other drivers.
>
>> if (ret < 0 && ret != -ENODEV)
>> return dev_err_probe(dev, ret, "Failed to get REFIN voltage\n");
>>
>> ext_vrefin = ret != -ENODEV;
>> st->vref_mV = ext_vrefin ? ret / 1000 : 1250;
>>
>> Keeping (MICRO / MILLI) instead of 1000 is fine too. There are varying opinions
>> on this.
>
>> Or we could drop ext_vrefin and have:
>
> It goes back and force. Can we keep the code as it's in this version?
Sure. Existing code is good enough for me. (And in that case, I
agree that renaming to `use_ext_vrefin` is an improvement.)
>
>> if (ret < 0 && ret != -ENODEV)
>> return dev_err_probe(dev, ret, "Failed to get REFIN voltage\n");
>>
>> if (ret != -ENODEV) {
>> st->vref_mV = ret / 1000;
>>
>> /* regmap set bits goes here. */
>> ...
>> } else {
>> st->vref_mV = 1250;
>> }
>
Powered by blists - more mailing lists