Re: [PATCH v9 5/6] iio: adc: ltc2378: Add support for LTC2338-18

Marcelo Schmitt <[email protected]>
Newsgroups gmane.linux.drivers.devicetree,gmane.linux.kernel.iio,gmane.linux.kernel
Message-ID <anqM43NvcVhhkkWI@debian-BULLSEYE-live-builder-AMD64>
Hi Andy,

On 08/10, Andy Shevchenko wrote:
> 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).

This has already been applied to IIO testing. I do send another version of this
specific patch if that's okay.

With Best Regards,
Marcelo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.