From patchwork Fri Jun 9 09:43:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 13273602 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38099C7EE2E for ; Fri, 9 Jun 2023 09:51:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241353AbjFIJu7 (ORCPT ); Fri, 9 Jun 2023 05:50:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241344AbjFIJuX (ORCPT ); Fri, 9 Jun 2023 05:50:23 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5D04728C for ; Fri, 9 Jun 2023 02:43:55 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6431C60E94 for ; Fri, 9 Jun 2023 09:43:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63817C433EF; Fri, 9 Jun 2023 09:43:16 +0000 (UTC) Message-ID: Date: Fri, 9 Jun 2023 11:43:14 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Content-Language: en-US To: Linux Media Mailing List Cc: Sakari Ailus From: Hans Verkuil Subject: [PATCH] media: i2c: adp1653: don't reuse the same node pointer Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The child device_node pointer was used for two different childs. 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 diff --git a/drivers/media/i2c/adp1653.c b/drivers/media/i2c/adp1653.c index 98ca417b8004..04ec465aaa94 100644 --- a/drivers/media/i2c/adp1653.c +++ b/drivers/media/i2c/adp1653.c @@ -411,43 +411,43 @@ 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_flash, *node_indicator; 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; + goto err_flash; - 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; + goto err_flash; 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; + goto err_flash; pd->max_torch_intensity /= 1000; - of_node_put(child); + of_node_put(node_flash); - child = of_get_child_by_name(node, "indicator"); - if (!child) + node_indicator = of_get_child_by_name(node, "indicator"); + if (!node_indicator) return -EINVAL; - 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; + goto err_indicator; - of_node_put(child); + of_node_put(node_indicator); pd->enable_gpio = devm_gpiod_get(&client->dev, "enable", GPIOD_OUT_LOW); if (IS_ERR(pd->enable_gpio)) { @@ -456,9 +456,13 @@ 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); +err_flash: + dev_err(&client->dev, "Required flash property not found\n"); + of_node_put(node_flash); + return -EINVAL; +err_indicator: + dev_err(&client->dev, "Required indicator property not found\n"); + of_node_put(node_indicator); return -EINVAL; }