bcm27xx: 6.1: add kernel patches
[openwrt/staging/stintel.git] / target / linux / bcm27xx / patches-6.1 / 950-0652-media-i2c-imx290-Make-use-of-get_unaligned_le24-put_.patch
1 From e6a7be26a288f293847b92fe6333bb981eb74ba3 Mon Sep 17 00:00:00 2001
2 From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
3 Date: Fri, 10 Feb 2023 00:12:05 +0200
4 Subject: [PATCH] media: i2c: imx290: Make use of get_unaligned_le24(),
5 put_unaligned_le24()
6
7 Should be upstream commit 5d129c4539c3
8
9 Since we have a proper endianness converters for LE 24-bit data use them.
10
11 Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
12 Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
13 Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
14 ---
15 drivers/media/i2c/imx290.c | 9 +++++++--
16 1 file changed, 7 insertions(+), 2 deletions(-)
17
18 --- a/drivers/media/i2c/imx290.c
19 +++ b/drivers/media/i2c/imx290.c
20 @@ -16,6 +16,9 @@
21 #include <linux/pm_runtime.h>
22 #include <linux/regmap.h>
23 #include <linux/regulator/consumer.h>
24 +
25 +#include <asm/unaligned.h>
26 +
27 #include <media/media-entity.h>
28 #include <media/v4l2-ctrls.h>
29 #include <media/v4l2-device.h>
30 @@ -466,18 +469,20 @@ static int __always_unused imx290_read(s
31 return ret;
32 }
33
34 - *value = (data[2] << 16) | (data[1] << 8) | data[0];
35 + *value = get_unaligned_le24(data);
36 return 0;
37 }
38
39 static int imx290_write(struct imx290 *imx290, u32 addr, u32 value, int *err)
40 {
41 - u8 data[3] = { value & 0xff, (value >> 8) & 0xff, value >> 16 };
42 + u8 data[3];
43 int ret;
44
45 if (err && *err)
46 return *err;
47
48 + put_unaligned_le24(value, data);
49 +
50 ret = regmap_raw_write(imx290->regmap, addr & IMX290_REG_ADDR_MASK,
51 data, (addr >> IMX290_REG_SIZE_SHIFT) & 3);
52 if (ret < 0) {