Linux IIO development
 help / color / mirror / Atom feed
* [PATCH] iio: adc: use sign_extend32 to provide negative numbers conversion
@ 2024-04-20 23:34 Otávio Silva
  2024-04-21 17:38 ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Otávio Silva @ 2024-04-20 23:34 UTC (permalink / raw)
  To: jic23
  Cc: Otávio Silva, Thiago Duvanel, Felipe Aníbal Brito,
	linux-iio

This implements the use of the sign_extend32 function to handle the output
of negative numbers.

Co-developed-by: Thiago Duvanel <thiago.duvanel@usp.br>
Signed-off-by: Thiago Duvanel <thiago.duvanel@usp.br>
Co-developed-by: Felipe Aníbal Brito <felipeanibal@usp.br>
Signed-off-by: Felipe Aníbal Brito <felipeanibal@usp.br>
Signed-off-by: Otávio Silva <otavio.ols@usp.br>
---
 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-04-28  2:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-20 23:34 [PATCH] iio: adc: use sign_extend32 to provide negative numbers conversion Otávio Silva
2024-04-21 17:38 ` Jonathan Cameron
2024-04-28  2:02   ` Otávio Silva

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox