Linux IIO development
 help / color / mirror / Atom feed
* [PATCH] iio: adc: ti-ads1119: fix sample size in scan struct for triggered buffer
@ 2024-12-02 19:18 Javier Carrasco
  2024-12-02 19:46 ` Francesco Dolcini
  0 siblings, 1 reply; 3+ messages in thread
From: Javier Carrasco @ 2024-12-02 19:18 UTC (permalink / raw)
  To: Francesco Dolcini, João Paulo Gonçalves,
	Jonathan Cameron, Lars-Peter Clausen
  Cc: João Paulo Gonçalves, Francesco Dolcini,
	Jonathan Cameron, linux-iio, linux-kernel, Javier Carrasco

This device returns signed, 16-bit samples as stated in its datasheet
(see 8.5.2 Data Format). That is in line with the scan_type definition
for the IIO_VOLTAGE channel, but 'unsigned int' is being used to read
and push the data to userspace.

Given that the size of that type depends on the architecture (at least
2 bytes to store values up to 65535, but its actual size is often 4
bytes), use the 's16' type to provide the same structure in all cases.

Fixes: a9306887eba4 ("iio: adc: ti-ads1119: Add driver")
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
---
 drivers/iio/adc/ti-ads1119.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/adc/ti-ads1119.c b/drivers/iio/adc/ti-ads1119.c
index 533610ac214e..6637cb6a6dda 100644
--- a/drivers/iio/adc/ti-ads1119.c
+++ b/drivers/iio/adc/ti-ads1119.c
@@ -500,7 +500,7 @@ static irqreturn_t ads1119_trigger_handler(int irq, void *private)
 	struct iio_dev *indio_dev = pf->indio_dev;
 	struct ads1119_state *st = iio_priv(indio_dev);
 	struct {
-		unsigned int sample;
+		s16 sample;
 		s64 timestamp __aligned(8);
 	} scan;
 	unsigned int index;

---
base-commit: a0d6ec6575fce400e976af1dd9223823251775e9
change-id: 20241202-ti-ads1119_s16_chan-2ae1d6f5e1b3

Best regards,
-- 
Javier Carrasco <javier.carrasco.cruz@gmail.com>


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

end of thread, other threads:[~2024-12-08 16:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-02 19:18 [PATCH] iio: adc: ti-ads1119: fix sample size in scan struct for triggered buffer Javier Carrasco
2024-12-02 19:46 ` Francesco Dolcini
2024-12-08 16:59   ` Jonathan Cameron

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