aboutsummaryrefslogtreecommitdiff
path: root/drivers/media/i2c/adp1653.c
diff options
context:
space:
mode:
authorGravatar Hans Verkuil <hverkuil-cisco@xs4all.nl> 2023-10-06 12:08:43 +0200
committerGravatar Hans Verkuil <hverkuil-cisco@xs4all.nl> 2023-10-12 10:12:54 +0200
commitb925fb423d3c9aa5cf24bd5e4953649fcf271245 (patch)
tree1baadcc9c87b51a4d70d7276d355c34d5677c547 /drivers/media/i2c/adp1653.c
parentmedia: rkisp1: resizer: Fix resizer disable check when starting stream (diff)
downloadlinux-b925fb423d3c9aa5cf24bd5e4953649fcf271245.tar.gz
linux-b925fb423d3c9aa5cf24bd5e4953649fcf271245.tar.bz2
linux-b925fb423d3c9aa5cf24bd5e4953649fcf271245.zip
media: i2c: adp1653: don't reuse the same node pointer
The child device_node pointer was used for two different children. This confused smatch, causing this warning: drivers/media/i2c/adp1653.c:444 adp1653_of_init() warn: missing unwind goto? Use two different pointers, one for each child node, and add separate goto labels for each node as well. This also improves error logging since it will now state for which node the property was missing. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> [hverkuil: fix typo: childs -> children]
Diffstat (limited to 'drivers/media/i2c/adp1653.c')
-rw-r--r--drivers/media/i2c/adp1653.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/drivers/media/i2c/adp1653.c b/drivers/media/i2c/adp1653.c
index 98ca417b8004..5ace7b5804d4 100644
--- a/drivers/media/i2c/adp1653.c
+++ b/drivers/media/i2c/adp1653.c
@@ -411,43 +411,44 @@ static int adp1653_of_init(struct i2c_client *client,
struct device_node *node)
{
struct adp1653_platform_data *pd;
- struct device_node *child;
+ struct device_node *node_indicator = NULL;
+ struct device_node *node_flash;
pd = devm_kzalloc(&client->dev, sizeof(*pd), GFP_KERNEL);
if (!pd)
return -ENOMEM;
flash->platform_data = pd;
- child = of_get_child_by_name(node, "flash");
- if (!child)
+ node_flash = of_get_child_by_name(node, "flash");
+ if (!node_flash)
return -EINVAL;
- if (of_property_read_u32(child, "flash-timeout-us",
+ if (of_property_read_u32(node_flash, "flash-timeout-us",
&pd->max_flash_timeout))
goto err;
- if (of_property_read_u32(child, "flash-max-microamp",
+ if (of_property_read_u32(node_flash, "flash-max-microamp",
&pd->max_flash_intensity))
goto err;
pd->max_flash_intensity /= 1000;
- if (of_property_read_u32(child, "led-max-microamp",
+ if (of_property_read_u32(node_flash, "led-max-microamp",
&pd->max_torch_intensity))
goto err;
pd->max_torch_intensity /= 1000;
- of_node_put(child);
- child = of_get_child_by_name(node, "indicator");
- if (!child)
- return -EINVAL;
+ node_indicator = of_get_child_by_name(node, "indicator");
+ if (!node_indicator)
+ goto err;
- if (of_property_read_u32(child, "led-max-microamp",
+ if (of_property_read_u32(node_indicator, "led-max-microamp",
&pd->max_indicator_intensity))
goto err;
- of_node_put(child);
+ of_node_put(node_flash);
+ of_node_put(node_indicator);
pd->enable_gpio = devm_gpiod_get(&client->dev, "enable", GPIOD_OUT_LOW);
if (IS_ERR(pd->enable_gpio)) {
@@ -458,7 +459,8 @@ static int adp1653_of_init(struct i2c_client *client,
return 0;
err:
dev_err(&client->dev, "Required property not found\n");
- of_node_put(child);
+ of_node_put(node_flash);
+ of_node_put(node_indicator);
return -EINVAL;
}