Re: [PATCH v9 5/6] iio: adc: ltc2378: Add support for LTC2338-18
Andy Shevchenko <[email protected]>
| Newsgroups | org.kernel.vger.linux-iio,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-kernel |
|---|---|
| Organization | Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo |
| Message-ID | <[email protected]> |
On Mon, Jul 27, 2026 at 06:31:58PM -0300, Marcelo Schmitt wrote:
> LTC2338-18 is similar to LTC2378-18, differentiating from the already
> supported part mainly on the embedment of an internal voltage reference and
> addition of a resistor divider network connected to the input signal path.
> Extend the device driver, handling the internal reference and input signal
> attenuation, enabling it to also support LTC2338-18.
...
> +static int ltc2378_refin_setup(struct device *dev, struct ltc2378_state *st)
> +{
> + int ret;
> +
> + /*
> + * The internal reference buffer amplifies both the internal reference
> + * and REFIN by a factor of 2.
> + */
> + ret = devm_regulator_get_enable_read_voltage(dev, "refin");
> + if (ret == -ENODEV) { /* refin is optional */
> + st->ref_uV = st->info->internal_ref_uV * 2;
> + return 0;
> + }
> +
> + if (ret < 0)
> + return dev_err_probe(dev, ret, "failed to read refin regulator\n");
> +
> + st->ref_uV = ret * 2;
> +
> + return 0;
I'm not sure about others' preferences, but I would do it as if-else-if and
remove dup return 0.
if (ret == -ENODEV) /* refin is optional */
st->ref_uV = st->info->internal_ref_uV * 2;
else if (ret < 0)
return dev_err_probe(dev, ret, "failed to read refin regulator\n");
else
st->ref_uV = ret * 2;
return 0;
It also makes code shorter (in amount of LoC).
> +}
--
With Best Regards,
Andy Shevchenko