mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-07 02:19:54 +00:00
media: i2c: imx290: Replace macro with explicit ARRAY_SIZE()
Use ARRAY_SIZE(imx290->supplies) for code that needs the size of the array, instead of relying on the IMX290_NUM_SUPPLIES. The result is less error-prone as it ties the size to the array. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Alexander Stein <alexander.stein@ew.tq-group.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
This commit is contained in:
committed by
Sakari Ailus
parent
fbe0a89dc7
commit
2548df538c
@@ -790,10 +790,10 @@ static int imx290_get_regulators(struct device *dev, struct imx290 *imx290)
|
|||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
for (i = 0; i < IMX290_NUM_SUPPLIES; i++)
|
for (i = 0; i < ARRAY_SIZE(imx290->supplies); i++)
|
||||||
imx290->supplies[i].supply = imx290_supply_name[i];
|
imx290->supplies[i].supply = imx290_supply_name[i];
|
||||||
|
|
||||||
return devm_regulator_bulk_get(dev, IMX290_NUM_SUPPLIES,
|
return devm_regulator_bulk_get(dev, ARRAY_SIZE(imx290->supplies),
|
||||||
imx290->supplies);
|
imx290->supplies);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -852,7 +852,8 @@ static int imx290_power_on(struct device *dev)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = regulator_bulk_enable(IMX290_NUM_SUPPLIES, imx290->supplies);
|
ret = regulator_bulk_enable(ARRAY_SIZE(imx290->supplies),
|
||||||
|
imx290->supplies);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(dev, "Failed to enable regulators\n");
|
dev_err(dev, "Failed to enable regulators\n");
|
||||||
clk_disable_unprepare(imx290->xclk);
|
clk_disable_unprepare(imx290->xclk);
|
||||||
@@ -876,7 +877,7 @@ static int imx290_power_off(struct device *dev)
|
|||||||
|
|
||||||
clk_disable_unprepare(imx290->xclk);
|
clk_disable_unprepare(imx290->xclk);
|
||||||
gpiod_set_value_cansleep(imx290->rst_gpio, 1);
|
gpiod_set_value_cansleep(imx290->rst_gpio, 1);
|
||||||
regulator_bulk_disable(IMX290_NUM_SUPPLIES, imx290->supplies);
|
regulator_bulk_disable(ARRAY_SIZE(imx290->supplies), imx290->supplies);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user