Message ID | 20210818111139.330636-2-miquel.raynal@bootlin.com (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
Series | Bring software triggers support to MAX1027-like ADCs | expand |
> -----Original Message----- > From: Miquel Raynal <miquel.raynal@bootlin.com> > Sent: Wednesday, August 18, 2021 1:11 PM > To: Jonathan Cameron <jic23@kernel.org>; Lars-Peter Clausen > <lars@metafoo.de> > Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>; linux- > iio@vger.kernel.org; linux-kernel@vger.kernel.org; Miquel Raynal > <miquel.raynal@bootlin.com>; stable@vger.kernel.org > Subject: [PATCH 01/16] iio: adc: max1027: Fix wrong shift with 12-bit > devices > > [External] > > 10-bit devices must shift the value twice. > This is not needed anymore on 12-bit devices. > > Fixes: ae47d009b508 ("iio: adc: max1027: Introduce 12-bit devices > support") > Cc: stable@vger.kernel.org > Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> > --- > drivers/iio/adc/max1027.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/iio/adc/max1027.c b/drivers/iio/adc/max1027.c > index 655ab02d03d8..4a42d140a4b0 100644 > --- a/drivers/iio/adc/max1027.c > +++ b/drivers/iio/adc/max1027.c > @@ -103,7 +103,7 @@ MODULE_DEVICE_TABLE(of, > max1027_adc_dt_ids); > .sign = 'u', \ > .realbits = depth, \ > .storagebits = 16, \ > - .shift = 2, \ > + .shift = (depth == 10) ? 2 : 0, \ > .endianness = IIO_BE, \ > }, \ > } > -- > 2.27.0 Reviewed-by: Nuno Sá <nuno.sa@analog.com>
On Fri, 20 Aug 2021 07:02:54 +0000 "Sa, Nuno" <Nuno.Sa@analog.com> wrote: > > -----Original Message----- > > From: Miquel Raynal <miquel.raynal@bootlin.com> > > Sent: Wednesday, August 18, 2021 1:11 PM > > To: Jonathan Cameron <jic23@kernel.org>; Lars-Peter Clausen > > <lars@metafoo.de> > > Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>; linux- > > iio@vger.kernel.org; linux-kernel@vger.kernel.org; Miquel Raynal > > <miquel.raynal@bootlin.com>; stable@vger.kernel.org > > Subject: [PATCH 01/16] iio: adc: max1027: Fix wrong shift with 12-bit > > devices > > > > [External] > > > > 10-bit devices must shift the value twice. > > This is not needed anymore on 12-bit devices. > > > > Fixes: ae47d009b508 ("iio: adc: max1027: Introduce 12-bit devices > > support") > > Cc: stable@vger.kernel.org > > Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> > > --- > > drivers/iio/adc/max1027.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/iio/adc/max1027.c b/drivers/iio/adc/max1027.c > > index 655ab02d03d8..4a42d140a4b0 100644 > > --- a/drivers/iio/adc/max1027.c > > +++ b/drivers/iio/adc/max1027.c > > @@ -103,7 +103,7 @@ MODULE_DEVICE_TABLE(of, > > max1027_adc_dt_ids); > > .sign = 'u', \ > > .realbits = depth, \ > > .storagebits = 16, \ > > - .shift = 2, \ > > + .shift = (depth == 10) ? 2 : 0, \ > > .endianness = IIO_BE, \ > > }, \ > > } > > -- > > 2.27.0 > > Reviewed-by: Nuno Sá <nuno.sa@analog.com> Ouch. I briefly wondered if we should dot his as 12 - depth, but given we are unlikely to ever see a 9 or 11 bit device and it doesn't make much sense for anything 8 or less what you have here is effectively the same. Applied to the fixes-togreg branch of iio.git Jonathan >
diff --git a/drivers/iio/adc/max1027.c b/drivers/iio/adc/max1027.c index 655ab02d03d8..4a42d140a4b0 100644 --- a/drivers/iio/adc/max1027.c +++ b/drivers/iio/adc/max1027.c @@ -103,7 +103,7 @@ MODULE_DEVICE_TABLE(of, max1027_adc_dt_ids); .sign = 'u', \ .realbits = depth, \ .storagebits = 16, \ - .shift = 2, \ + .shift = (depth == 10) ? 2 : 0, \ .endianness = IIO_BE, \ }, \ }
10-bit devices must shift the value twice. This is not needed anymore on 12-bit devices. Fixes: ae47d009b508 ("iio: adc: max1027: Introduce 12-bit devices support") Cc: stable@vger.kernel.org Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> --- drivers/iio/adc/max1027.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)