[PATCH] iio: adc: use sign_extend32 to provide negative numbers conversion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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>
---
 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;
 }
-- 
2.44.0





[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux