Message ID | 64e32c0ac7357ca7ddea813ba932bf957cbbeca2.1737985435.git.Jonathan.Santos@analog.com (mailing list archive) |
---|---|
State | Changes Requested |
Headers | show |
Series | Add features, improvements, and fixes | expand |
On Mon, 27 Jan 2025 12:11:01 -0300 Jonathan Santos <Jonathan.Santos@analog.com> wrote: > From: Sergiu Cuciurean <sergiu.cuciurean@analog.com> > > The ad7768-1 ADC output code is two's complement, meaning that the voltage > conversion result is a signed value.. Since the value is a 24 bit one, > stored in a 32 bit variable, the sign should be extended in order to get > the correct representation. > > Also the channel description has been updated to signed representation, > to match the ADC specifications. > > Fixes: a5f8c7da3dbe ("iio: adc: Add AD7768-1 ADC basic support") > Reviewed-by: David Lechner <dlechner@baylibre.com> > Reviewed-by: Marcelo Schmitt <marcelo.schmitt@analog.com> > Signed-off-by: Sergiu Cuciurean <sergiu.cuciurean@analog.com> > --- > v2 Changes: > * Patch moved to the start of the patch series. Applied to the fixes-togreg branch of iio.git. Thanks, Jonathan > --- > drivers/iio/adc/ad7768-1.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/iio/adc/ad7768-1.c b/drivers/iio/adc/ad7768-1.c > index 113703fb7245..c3cf04311c40 100644 > --- a/drivers/iio/adc/ad7768-1.c > +++ b/drivers/iio/adc/ad7768-1.c > @@ -142,7 +142,7 @@ static const struct iio_chan_spec ad7768_channels[] = { > .channel = 0, > .scan_index = 0, > .scan_type = { > - .sign = 'u', > + .sign = 's', > .realbits = 24, > .storagebits = 32, > .shift = 8, > @@ -371,7 +371,7 @@ static int ad7768_read_raw(struct iio_dev *indio_dev, > > ret = ad7768_scan_direct(indio_dev); > if (ret >= 0) > - *val = ret; > + *val = sign_extend32(ret, chan->scan_type.realbits - 1); > > iio_device_release_direct_mode(indio_dev); > if (ret < 0)
On Mon, 27 Jan 2025 12:11:01 -0300 Jonathan Santos <Jonathan.Santos@analog.com> wrote: > From: Sergiu Cuciurean <sergiu.cuciurean@analog.com> > > The ad7768-1 ADC output code is two's complement, meaning that the voltage > conversion result is a signed value.. Since the value is a 24 bit one, > stored in a 32 bit variable, the sign should be extended in order to get > the correct representation. > > Also the channel description has been updated to signed representation, > to match the ADC specifications. > > Fixes: a5f8c7da3dbe ("iio: adc: Add AD7768-1 ADC basic support") > Reviewed-by: David Lechner <dlechner@baylibre.com> > Reviewed-by: Marcelo Schmitt <marcelo.schmitt@analog.com> > Signed-off-by: Sergiu Cuciurean <sergiu.cuciurean@analog.com> Dropped. Jonathan, this is missing your sign off. > --- > v2 Changes: > * Patch moved to the start of the patch series. > --- > drivers/iio/adc/ad7768-1.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/iio/adc/ad7768-1.c b/drivers/iio/adc/ad7768-1.c > index 113703fb7245..c3cf04311c40 100644 > --- a/drivers/iio/adc/ad7768-1.c > +++ b/drivers/iio/adc/ad7768-1.c > @@ -142,7 +142,7 @@ static const struct iio_chan_spec ad7768_channels[] = { > .channel = 0, > .scan_index = 0, > .scan_type = { > - .sign = 'u', > + .sign = 's', > .realbits = 24, > .storagebits = 32, > .shift = 8, > @@ -371,7 +371,7 @@ static int ad7768_read_raw(struct iio_dev *indio_dev, > > ret = ad7768_scan_direct(indio_dev); > if (ret >= 0) > - *val = ret; > + *val = sign_extend32(ret, chan->scan_type.realbits - 1); > > iio_device_release_direct_mode(indio_dev); > if (ret < 0)
diff --git a/drivers/iio/adc/ad7768-1.c b/drivers/iio/adc/ad7768-1.c index 113703fb7245..c3cf04311c40 100644 --- a/drivers/iio/adc/ad7768-1.c +++ b/drivers/iio/adc/ad7768-1.c @@ -142,7 +142,7 @@ static const struct iio_chan_spec ad7768_channels[] = { .channel = 0, .scan_index = 0, .scan_type = { - .sign = 'u', + .sign = 's', .realbits = 24, .storagebits = 32, .shift = 8, @@ -371,7 +371,7 @@ static int ad7768_read_raw(struct iio_dev *indio_dev, ret = ad7768_scan_direct(indio_dev); if (ret >= 0) - *val = ret; + *val = sign_extend32(ret, chan->scan_type.realbits - 1); iio_device_release_direct_mode(indio_dev); if (ret < 0)