Skip to contentSkip to conversation

media: i2c: imx290: Make use of get_unaligned_le24(), put_unaligned_le24()

PATCH In review Andy Shevchenko 4 participants 8 messages Feb 9, 2023 – Mar 13, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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

Since we have a proper endianness converters for LE 24-bit data use them.

---
v2: dropped unrelated noise from the commit message (Laurent)

 drivers/media/i2c/imx290.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/media/i2c/imx290.c +7 -2
index 49d6c8bdec41..330098a0772d 100644
@@ -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) {
Signature · 1 line
2.39.1
Reviewed-by on v2 1/1
#1 lore raw

Hi Andy,

Thank you for the patch.

Quoted 3 lines · Andy Shevchenko

Since we have a proper endianness converters for LE 24-bit data use them.

I assume Sakari will pick both patches.

Quoted 42 lines

---
v2: dropped unrelated noise from the commit message (Laurent)

 drivers/media/i2c/imx290.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/media/i2c/imx290.c +7 -2
index 49d6c8bdec41..330098a0772d 100644
@@ -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) {
Signature · 3 lines
Regards,

Laurent Pinchart
#3 lore raw
Quoted 6 lines · Andy Shevchenko
Quoted 5 lines · Laurent Pinchart
Quoted 3 lines · Andy Shevchenko

Since we have a proper endianness converters for LE 24-bit data use them.

Quoted 7 lines
Quoted 1 line

Thank you for the reviews!

Quoted 1 line

I assume Sakari will pick both patches.

I also assume the same.

Sakari, do you have any comments?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#4 lore raw
Quoted 9 lines · Andy Shevchenko
Quoted 8 lines · Andy Shevchenko
Quoted 6 lines · Laurent Pinchart
Quoted 3 lines · Andy Shevchenko

Since we have a proper endianness converters for LE 24-bit data use them.

Quoted 7 lines
Quoted 5 lines

Thank you for the reviews!

Quoted 1 line

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.

Signature · 1 line
Sakari Ailus
#5 lore raw
Quoted 12 lines · Sakari Ailus
Quoted 11 lines · Andy Shevchenko
Quoted 10 lines · Andy Shevchenko
Quoted 6 lines · Laurent Pinchart
Quoted 3 lines · Andy Shevchenko

Since we have a proper endianness converters for LE 24-bit data use them.

Thank you for the reviews!

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

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/.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#6 lore raw
Quoted 17 lines · Andy Shevchenko
Quoted 16 lines · Sakari Ailus
Quoted 15 lines · Andy Shevchenko
Quoted 13 lines · Andy Shevchenko
Quoted 6 lines · Laurent Pinchart
Quoted 3 lines · Andy Shevchenko

Since we have a proper endianness converters for LE 24-bit data use them.

Thank you for the reviews!

Quoted 1 line

I assume Sakari will pick both patches.

I also assume the same.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

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.

Signature · 1 line
Sakari Ailus
#7 lore raw
Quoted 3 lines · Sakari Ailus
Quoted 2 lines · Andy Shevchenko
Quoted 1 line · Sakari Ailus

On Fri, Mar 10, 2023 at 07:21:44PM +0200, Andy Shevchenko wrote:

...

Quoted 9 lines
Quoted 5 lines
Quoted 1 line

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!

Signature · 2 lines
With Best Regards,
Andy Shevchenko