Linux IIO development
 help / color / mirror / Atom feed
* [PATCH] iio: dac: ad5770r: Convert to get_unaligned_le16
@ 2024-09-28 16:18 Abhash Jha
  2024-09-29 16:51 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Abhash Jha @ 2024-09-28 16:18 UTC (permalink / raw)
  To: linux-iio; +Cc: Michael.Hennerich, jic23, lars, linux-kernel, Abhash Jha

Convert the manual shifting to use `get_unaligned_le16` api.

Signed-off-by: Abhash Jha <abhashkumarjha123@gmail.com>
---
 drivers/iio/dac/ad5770r.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/dac/ad5770r.c b/drivers/iio/dac/ad5770r.c
index c360ebf52..12c98f3e6 100644
--- a/drivers/iio/dac/ad5770r.c
+++ b/drivers/iio/dac/ad5770r.c
@@ -17,6 +17,7 @@
 #include <linux/regmap.h>
 #include <linux/regulator/consumer.h>
 #include <linux/spi/spi.h>
+#include <asm/unaligned.h>
 
 #define ADI_SPI_IF_CONFIG_A		0x00
 #define ADI_SPI_IF_CONFIG_B		0x01
@@ -325,7 +326,7 @@ static int ad5770r_read_raw(struct iio_dev *indio_dev,
 		if (ret)
 			return 0;
 
-		buf16 = st->transf_buf[0] + (st->transf_buf[1] << 8);
+		buf16 = get_unaligned_le16(st->transf_buf);
 		*val = buf16 >> 2;
 		return IIO_VAL_INT;
 	case IIO_CHAN_INFO_SCALE:
-- 
2.43.0


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

* Re: [PATCH] iio: dac: ad5770r: Convert to get_unaligned_le16
  2024-09-28 16:18 [PATCH] iio: dac: ad5770r: Convert to get_unaligned_le16 Abhash Jha
@ 2024-09-29 16:51 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2024-09-29 16:51 UTC (permalink / raw)
  To: Abhash Jha; +Cc: linux-iio, Michael.Hennerich, lars, linux-kernel

On Sat, 28 Sep 2024 21:48:05 +0530
Abhash Jha <abhashkumarjha123@gmail.com> wrote:

> Convert the manual shifting to use `get_unaligned_le16` api.
> 
> Signed-off-by: Abhash Jha <abhashkumarjha123@gmail.com>
Looks straight forward so I've applied this, but plenty of time for
additional reviews if anyone has time to take a look.

Thanks,

Jonathan

> ---
>  drivers/iio/dac/ad5770r.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/dac/ad5770r.c b/drivers/iio/dac/ad5770r.c
> index c360ebf52..12c98f3e6 100644
> --- a/drivers/iio/dac/ad5770r.c
> +++ b/drivers/iio/dac/ad5770r.c
> @@ -17,6 +17,7 @@
>  #include <linux/regmap.h>
>  #include <linux/regulator/consumer.h>
>  #include <linux/spi/spi.h>
> +#include <asm/unaligned.h>
>  
>  #define ADI_SPI_IF_CONFIG_A		0x00
>  #define ADI_SPI_IF_CONFIG_B		0x01
> @@ -325,7 +326,7 @@ static int ad5770r_read_raw(struct iio_dev *indio_dev,
>  		if (ret)
>  			return 0;
>  
> -		buf16 = st->transf_buf[0] + (st->transf_buf[1] << 8);
> +		buf16 = get_unaligned_le16(st->transf_buf);
>  		*val = buf16 >> 2;
>  		return IIO_VAL_INT;
>  	case IIO_CHAN_INFO_SCALE:


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

end of thread, other threads:[~2024-09-29 16:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-28 16:18 [PATCH] iio: dac: ad5770r: Convert to get_unaligned_le16 Abhash Jha
2024-09-29 16:51 ` Jonathan Cameron

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