Re: [PATCH v2] iio: magnetometer: si7210: use devm_regulator_get_enable_read_voltage()
From: Andy Shevchenko
Date: Wed Feb 11 2026 - 03:54:07 EST
On Wed, Feb 11, 2026 at 10:18:28AM +0200, Antoniu Miclaus wrote:
> Simplify probe by using devm_regulator_get_enable_read_voltage() to
> get, enable and read the regulator voltage in a single call.
One nit-pick below, otherwise LGTM,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxx>
...
> struct si7210_data {
> struct regmap *regmap;
> struct i2c_client *client;
> - struct regulator *vdd;
> struct mutex fetch_lock; /* lock for a single measurement fetch */
> s8 temp_offset;
> s8 temp_gain;
> s8 scale_20_a[A_REGS_COUNT];
> s8 scale_200_a[A_REGS_COUNT];
> u8 curr_scale;
> + unsigned int vdd_uV;
> };
Haven't noticed, but I believe this is not the best place to put a new member.
Does `pahole` agree with me or with you?
...
> /* temp -= 0.222 * VDD */
> - temp -= 222 * div_s64(ret, MILLI);
> + temp -= 222 * (data->vdd_uV / MILLI);
Just a side note: Here is a possible loss in precision, wouldn't be better to
have it as
temp -= 222 * data->vdd_uV / MILLI;
?
Note, if you agree this needs to be checked with the datasheet, etc. and sent
in a separate patch. For now the original way seems okay to me.
--
With Best Regards,
Andy Shevchenko