136998b0ace9bc13936caa2aacd43dfbe2ef0a6d
[openwrt/staging/ansuel.git] /
1 From 40361e75c3da4145a21ef6284ad76c28983b4364 Mon Sep 17 00:00:00 2001
2 From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
3 Date: Sun, 16 Oct 2022 09:15:07 +0300
4 Subject: [PATCH] media: i2c: imx290: Replace macro with explicit
5 ARRAY_SIZE()
6
7 Upstream commit 2548df538cdd.
8
9 Use ARRAY_SIZE(imx290->supplies) for code that needs the size of the
10 array, instead of relying on the IMX290_NUM_SUPPLIES. The result is less
11 error-prone as it ties the size to the array.
12
13 Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
14 Reviewed-by: Alexander Stein <alexander.stein@ew.tq-group.com>
15 Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
16 ---
17 drivers/media/i2c/imx290.c | 9 +++++----
18 1 file changed, 5 insertions(+), 4 deletions(-)
19
20 --- a/drivers/media/i2c/imx290.c
21 +++ b/drivers/media/i2c/imx290.c
22 @@ -790,10 +790,10 @@ static int imx290_get_regulators(struct
23 {
24 unsigned int i;
25
26 - for (i = 0; i < IMX290_NUM_SUPPLIES; i++)
27 + for (i = 0; i < ARRAY_SIZE(imx290->supplies); i++)
28 imx290->supplies[i].supply = imx290_supply_name[i];
29
30 - return devm_regulator_bulk_get(dev, IMX290_NUM_SUPPLIES,
31 + return devm_regulator_bulk_get(dev, ARRAY_SIZE(imx290->supplies),
32 imx290->supplies);
33 }
34
35 @@ -852,7 +852,8 @@ static int imx290_power_on(struct device
36 return ret;
37 }
38
39 - ret = regulator_bulk_enable(IMX290_NUM_SUPPLIES, imx290->supplies);
40 + ret = regulator_bulk_enable(ARRAY_SIZE(imx290->supplies),
41 + imx290->supplies);
42 if (ret) {
43 dev_err(dev, "Failed to enable regulators\n");
44 clk_disable_unprepare(imx290->xclk);
45 @@ -876,7 +877,7 @@ static int imx290_power_off(struct devic
46
47 clk_disable_unprepare(imx290->xclk);
48 gpiod_set_value_cansleep(imx290->rst_gpio, 1);
49 - regulator_bulk_disable(IMX290_NUM_SUPPLIES, imx290->supplies);
50 + regulator_bulk_disable(ARRAY_SIZE(imx290->supplies), imx290->supplies);
51
52 return 0;
53 }