Re: [PATCH v11 2/3] iio: adc: max14001: New driver

David Lechner
2025-09-17T13:15:00Z

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;
>> }
>