On Sat, 20 Apr 2024 20:34:11 -0300 Otávio Silva <otavio.ols@xxxxxx> wrote: > This implements the use of the sign_extend32 function to handle the output > of negative numbers. > > Co-developed-by: Thiago Duvanel <thiago.duvanel@xxxxxx> > Signed-off-by: Thiago Duvanel <thiago.duvanel@xxxxxx> > Co-developed-by: Felipe Aníbal Brito <felipeanibal@xxxxxx> > Signed-off-by: Felipe Aníbal Brito <felipeanibal@xxxxxx> > Signed-off-by: Otávio Silva <otavio.ols@xxxxxx> Hi All, What makes you think this is signed? It might be. If it is you need to provide that information to justify this change. It would also be a fix if so and need a fixes tag. Given this device has a mixture of differential and non differential channels, the single ended ones are very unlikely to give signed output, the differential channels 'might' be. The datasheet does refer to a bipolar mode with 2s complement output, so if that is in use, then the results would be 2s complement and should be sign extended. So you need to figure out if that mode is in use or not. Jonathan > --- > drivers/iio/adc/ltc2309.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/iio/adc/ltc2309.c b/drivers/iio/adc/ltc2309.c > index 8b3a89c1b..cb93dbc94 100644 > --- a/drivers/iio/adc/ltc2309.c > +++ b/drivers/iio/adc/ltc2309.c > @@ -124,7 +124,7 @@ static int ltc2309_read_raw_channel(struct ltc2309 *ltc2309, > return ret; > } > > - *val = be16_to_cpu(buf) >> 4; > + *val = sign_extend32(be16_to_cpu(buf) >> 4, 11); > > return ret; > }