Re: [PATCH v3 6/9] iio: adc: ti-ads1262: support excitation currents
Jonathan Cameron <[email protected]>
| Newsgroups | org.kernel.vger.linux-gpio,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-iio,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <20260816224252.0c449ee0@jic23-huawei> |
On Fri, 07 Aug 2026 22:58:28 -0500 Kurt Borja <[email protected]> wrote: > Support the two IDAC excitation current sources. Each channel can route > its IDAC1/IDAC2 outputs to a pin via the "excitation-channels" property > and select a magnitude via "excitation-current-nanoamp". > > Signed-off-by: Kurt Borja <[email protected]> > --- > drivers/iio/adc/ti-ads1262.c | 101 +++++++++++++++++++++++++++++++++++++++++-- > 1 file changed, 98 insertions(+), 3 deletions(-) > > diff --git a/drivers/iio/adc/ti-ads1262.c b/drivers/iio/adc/ti-ads1262.c > index e2659941e1af..d5464b4f2bfb 100644 > --- a/drivers/iio/adc/ti-ads1262.c > +++ b/drivers/iio/adc/ti-ads1262.c > @@ -277,6 +282,25 @@ static const char * const ads1262_ref_sources_neg[] = { > NULL > }; > > +static const u32 ads1262_idac_mags_nA[] = { > + 0, 50000, 100000, 250000, 500000, 750000, 1000000, 1500000, 2000000, Where we have long arrays like this a useful convention is to break them into a power of 2 elements and provide a comment that says /* 0..7 */ etc just to make it easier to count. > + 2500000, 3000000 > +}; > + > +static int ads1262_find_one(const int *array, size_t num_elements, int val) > +{ > + int i; > + > + for (i = 0; i < num_elements; i++) { > + if (val == array[i]) > + break; Assuming this doesn't change later, an early return on match makes life simpler. return i; > + } return -EINVAL; > + if (i == num_elements) > + return -EINVAL; > + > + return i; > +} > +