diff mbox series

[v2,1/1] media: i2c: imx290: Make use of get_unaligned_le24(), put_unaligned_le24()

Message ID 20230209221205.46573-1-andriy.shevchenko@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series [v2,1/1] media: i2c: imx290: Make use of get_unaligned_le24(), put_unaligned_le24() | expand

Commit Message

Andy Shevchenko Feb. 9, 2023, 10:12 p.m. UTC
Since we have a proper endianness converters for LE 24-bit data use them.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v2: dropped unrelated noise from the commit message (Laurent)
 drivers/media/i2c/imx290.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Laurent Pinchart Feb. 9, 2023, 10:35 p.m. UTC | #1
Hi Andy,

Thank you for the patch.

On Fri, Feb 10, 2023 at 12:12:05AM +0200, Andy Shevchenko wrote:
> Since we have a proper endianness converters for LE 24-bit data use them.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

I assume Sakari will pick both patches.

> ---
> v2: dropped unrelated noise from the commit message (Laurent)
>  drivers/media/i2c/imx290.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/i2c/imx290.c b/drivers/media/i2c/imx290.c
> index 49d6c8bdec41..330098a0772d 100644
> --- a/drivers/media/i2c/imx290.c
> +++ b/drivers/media/i2c/imx290.c
> @@ -16,6 +16,9 @@
>  #include <linux/pm_runtime.h>
>  #include <linux/regmap.h>
>  #include <linux/regulator/consumer.h>
> +
> +#include <asm/unaligned.h>
> +
>  #include <media/media-entity.h>
>  #include <media/v4l2-ctrls.h>
>  #include <media/v4l2-device.h>
> @@ -466,18 +469,20 @@ static int __always_unused imx290_read(struct imx290 *imx290, u32 addr, u32 *val
>  		return ret;
>  	}
>  
> -	*value = (data[2] << 16) | (data[1] << 8) | data[0];
> +	*value = get_unaligned_le24(data);
>  	return 0;
>  }
>  
>  static int imx290_write(struct imx290 *imx290, u32 addr, u32 value, int *err)
>  {
> -	u8 data[3] = { value & 0xff, (value >> 8) & 0xff, value >> 16 };
> +	u8 data[3];
>  	int ret;
>  
>  	if (err && *err)
>  		return *err;
>  
> +	put_unaligned_le24(value, data);
> +
>  	ret = regmap_raw_write(imx290->regmap, addr & IMX290_REG_ADDR_MASK,
>  			       data, (addr >> IMX290_REG_SIZE_SHIFT) & 3);
>  	if (ret < 0) {
Andy Shevchenko Feb. 10, 2023, 5:06 p.m. UTC | #2
On Fri, Feb 10, 2023 at 12:35:09AM +0200, Laurent Pinchart wrote:
> On Fri, Feb 10, 2023 at 12:12:05AM +0200, Andy Shevchenko wrote:
> > Since we have a proper endianness converters for LE 24-bit data use them.
> > 
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Thank you for the reviews!

> I assume Sakari will pick both patches.

I also assume the same.
Andy Shevchenko March 10, 2023, 5:21 p.m. UTC | #3
On Fri, Feb 10, 2023 at 07:06:32PM +0200, Andy Shevchenko wrote:
> On Fri, Feb 10, 2023 at 12:35:09AM +0200, Laurent Pinchart wrote:
> > On Fri, Feb 10, 2023 at 12:12:05AM +0200, Andy Shevchenko wrote:
> > > Since we have a proper endianness converters for LE 24-bit data use them.
> > > 
> > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > 
> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
> Thank you for the reviews!
> 
> > I assume Sakari will pick both patches.
> 
> I also assume the same.

Sakari, do you have any comments?
Sakari Ailus March 13, 2023, 11:32 a.m. UTC | #4
On Fri, Mar 10, 2023 at 07:21:44PM +0200, Andy Shevchenko wrote:
> On Fri, Feb 10, 2023 at 07:06:32PM +0200, Andy Shevchenko wrote:
> > On Fri, Feb 10, 2023 at 12:35:09AM +0200, Laurent Pinchart wrote:
> > > On Fri, Feb 10, 2023 at 12:12:05AM +0200, Andy Shevchenko wrote:
> > > > Since we have a proper endianness converters for LE 24-bit data use them.
> > > > 
> > > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > > 
> > > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > 
> > Thank you for the reviews!
> > 
> > > I assume Sakari will pick both patches.
> > 
> > I also assume the same.
> 
> Sakari, do you have any comments?

Yes. These are in my tree now.
Andy Shevchenko March 13, 2023, 12:01 p.m. UTC | #5
On Mon, Mar 13, 2023 at 01:32:55PM +0200, Sakari Ailus wrote:
> On Fri, Mar 10, 2023 at 07:21:44PM +0200, Andy Shevchenko wrote:
> > On Fri, Feb 10, 2023 at 07:06:32PM +0200, Andy Shevchenko wrote:
> > > On Fri, Feb 10, 2023 at 12:35:09AM +0200, Laurent Pinchart wrote:
> > > > On Fri, Feb 10, 2023 at 12:12:05AM +0200, Andy Shevchenko wrote:
> > > > > Since we have a proper endianness converters for LE 24-bit data use them.
> > > > > 
> > > > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > > > 
> > > > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > > 
> > > Thank you for the reviews!
> > > 
> > > > I assume Sakari will pick both patches.
> > > 
> > > I also assume the same.
> > 
> > Sakari, do you have any comments?
> 
> Yes. These are in my tree now.

Which is...?

I don't see anything on https://git.linuxtv.org/sailus/media_tree.git/.
Sakari Ailus March 13, 2023, 1:20 p.m. UTC | #6
On Mon, Mar 13, 2023 at 02:01:23PM +0200, Andy Shevchenko wrote:
> On Mon, Mar 13, 2023 at 01:32:55PM +0200, Sakari Ailus wrote:
> > On Fri, Mar 10, 2023 at 07:21:44PM +0200, Andy Shevchenko wrote:
> > > On Fri, Feb 10, 2023 at 07:06:32PM +0200, Andy Shevchenko wrote:
> > > > On Fri, Feb 10, 2023 at 12:35:09AM +0200, Laurent Pinchart wrote:
> > > > > On Fri, Feb 10, 2023 at 12:12:05AM +0200, Andy Shevchenko wrote:
> > > > > > Since we have a proper endianness converters for LE 24-bit data use them.
> > > > > > 
> > > > > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > > > > 
> > > > > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > > > 
> > > > Thank you for the reviews!
> > > > 
> > > > > I assume Sakari will pick both patches.
> > > > 
> > > > I also assume the same.
> > > 
> > > Sakari, do you have any comments?
> > 
> > Yes. These are in my tree now.
> 
> Which is...?
> 
> I don't see anything on https://git.linuxtv.org/sailus/media_tree.git/.

This is a bit opportunistic since we don't have rc1 in the media tree yet.

I'll push it once we do.
Andy Shevchenko March 13, 2023, 3:57 p.m. UTC | #7
On Mon, Mar 13, 2023 at 03:20:42PM +0200, Sakari Ailus wrote:
> On Mon, Mar 13, 2023 at 02:01:23PM +0200, Andy Shevchenko wrote:
> > On Mon, Mar 13, 2023 at 01:32:55PM +0200, Sakari Ailus wrote:
> > > On Fri, Mar 10, 2023 at 07:21:44PM +0200, Andy Shevchenko wrote:

...

> > > Yes. These are in my tree now.
> > 
> > Which is...?
> > 
> > I don't see anything on https://git.linuxtv.org/sailus/media_tree.git/.
> 
> This is a bit opportunistic since we don't have rc1 in the media tree yet.
> 
> I'll push it once we do.

Ah, thank you!
diff mbox series

Patch

diff --git a/drivers/media/i2c/imx290.c b/drivers/media/i2c/imx290.c
index 49d6c8bdec41..330098a0772d 100644
--- a/drivers/media/i2c/imx290.c
+++ b/drivers/media/i2c/imx290.c
@@ -16,6 +16,9 @@ 
 #include <linux/pm_runtime.h>
 #include <linux/regmap.h>
 #include <linux/regulator/consumer.h>
+
+#include <asm/unaligned.h>
+
 #include <media/media-entity.h>
 #include <media/v4l2-ctrls.h>
 #include <media/v4l2-device.h>
@@ -466,18 +469,20 @@  static int __always_unused imx290_read(struct imx290 *imx290, u32 addr, u32 *val
 		return ret;
 	}
 
-	*value = (data[2] << 16) | (data[1] << 8) | data[0];
+	*value = get_unaligned_le24(data);
 	return 0;
 }
 
 static int imx290_write(struct imx290 *imx290, u32 addr, u32 value, int *err)
 {
-	u8 data[3] = { value & 0xff, (value >> 8) & 0xff, value >> 16 };
+	u8 data[3];
 	int ret;
 
 	if (err && *err)
 		return *err;
 
+	put_unaligned_le24(value, data);
+
 	ret = regmap_raw_write(imx290->regmap, addr & IMX290_REG_ADDR_MASK,
 			       data, (addr >> IMX290_REG_SIZE_SHIFT) & 3);
 	if (ret < 0) {