Re: [PATCH v3 2/2] iio: adc: Add ti-ads1018 driver

From: Andy Shevchenko

Date: Sat Nov 29 2025 - 09:23:43 EST


On Sat, Nov 29, 2025 at 04:21:46PM +0200, Andy Shevchenko wrote:
> On Fri, Nov 28, 2025 at 10:47:13PM -0500, Kurt Borja wrote:

...

> > +/**
> > + * ADS1018_FSR_TO_SCALE - Converts FSR into scale
> > + * @_fsr: Full-scale range in millivolts
> > + * @_res: ADC resolution
>
> Add here something like this:
>
> *
> * The macro is crafted to avoid potential overflows on 32-bit machines.
> * This imposes restrictions to the possible values for @_fsr (less
> * than 274878), and @_res (great or equal to 6 bits).

* than 274878), and @_res (great than or equal to 6 bits).

(I missed "than")

> *
>
> > + * Return: Scale in IIO_VAL_INT_PLUS_NANO format
> > + */
> > +#define ADS1018_FSR_TO_SCALE(_fsr, _res) \
> > + { 0, ((_fsr) * (MICRO >> 6)) / BIT((_res) - 6) }

--
With Best Regards,
Andy Shevchenko