Re: [PATCH v3 3/5] iio: amplifiers: ada4250: use devm_regulator_get_enable_read_voltage()

From: David Lechner
Date: Thu Jun 12 2025 - 11:39:44 EST


On 6/12/25 8:03 AM, Andy Shevchenko wrote:
> On Wed, Jun 11, 2025 at 04:33:03PM -0500, David Lechner wrote:
>> Use devm_regulator_get_enable_read_voltage() to simplify the code.
>>
>> Replace 1000000 with MICRO while we are touching this for better
>> readability.
>
> ...
>
>> - voltage_v = DIV_ROUND_CLOSEST(voltage_v, 1000000);
>> + voltage_v = DIV_ROUND_CLOSEST(st->avdd_uv, MICRO);
>
> Side note. I'm always worry about CLOSEST choice when it's related to voltage
> or current. Imagine the table which gives you 5, 3.3, and 1.2. If it happens to
> be closest to higher value, it may damage HW forever.
>

The rounding to volts seems strange to me too, but I could not find a public
datasheet for this part, so I wasn't able to determine what the "right" thing
to do is. It sounds like this is just some sort of small gain/offset calibration,
so I don't think there is any serious problem here, like it could damage the part.
So I will have to leave it to someone with the part and the datasheet to figure
out if there is actually a problem here.