From patchwork Fri Aug 23 09:02:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjie Ruan X-Patchwork-Id: 13774800 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 21267C531DC for ; Fri, 23 Aug 2024 09:01:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=CM2sKUjGuJOYeGEnLd4ZLYVwbDTuRcH+7PYNThIUXl0=; b=hc8dnHNQsuECO46c5l9bAlUcmj mIwnuEqKaZly1Y5HAYi43DKY1AtsABteGlbGw86yMwJ92hKYE0G2SxNr+6SYeoidF0QJEEm0kLj2j WbsCKA4TjgCffQ4eW8NgPJoTEd+spHkIe4kGCWm4P/GB8dIFHc6oS9D2P9nUU1gYN4nBVKz6Mde6j 3weqrUvQ8oPIaoT9v2wqhnt0mbi5EZZC4TGci+8Ey4HTBjm1khuXtzfkl9gopPgKHlZ/QHWmybUUD LYEvckV6JBf5urS9WNi9b5MV6oj2Tw1lKBsQgdpjIbSzejnygKLiE+XEzsuWIfCyPefS8QDTd5B/N wTWcy6Zg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1shQAP-0000000G0B0-3NI2; Fri, 23 Aug 2024 09:01:09 +0000 Received: from szxga05-in.huawei.com ([45.249.212.191]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1shQ4I-0000000Fy7m-0sZr for linux-arm-kernel@lists.infradead.org; Fri, 23 Aug 2024 08:54:51 +0000 Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4Wqv1p3GSVz1HGkX; Fri, 23 Aug 2024 16:51:26 +0800 (CST) Received: from kwepemh500013.china.huawei.com (unknown [7.202.181.146]) by mail.maildlp.com (Postfix) with ESMTPS id 9A4C7140360; Fri, 23 Aug 2024 16:54:40 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemh500013.china.huawei.com (7.202.181.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Fri, 23 Aug 2024 16:54:39 +0800 From: Jinjie Ruan To: , , , , , , , , CC: Subject: [PATCH -next 1/3] media: samsung: exynos4-is: Use for_each_available_child_of_node_scoped() Date: Fri, 23 Aug 2024 17:02:15 +0800 Message-ID: <20240823090217.436622-2-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240823090217.436622-1-ruanjinjie@huawei.com> References: <20240823090217.436622-1-ruanjinjie@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemh500013.china.huawei.com (7.202.181.146) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240823_015450_791460_3E666D19 X-CRM114-Status: GOOD ( 11.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Avoids the need for manual cleanup of_node_put() in early exits from the loop. Signed-off-by: Jinjie Ruan --- .../platform/samsung/exynos4-is/media-dev.c | 27 ++++++------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/drivers/media/platform/samsung/exynos4-is/media-dev.c b/drivers/media/platform/samsung/exynos4-is/media-dev.c index 5f10bb4eb4f7..73d620c325ec 100644 --- a/drivers/media/platform/samsung/exynos4-is/media-dev.c +++ b/drivers/media/platform/samsung/exynos4-is/media-dev.c @@ -482,15 +482,12 @@ static int fimc_md_parse_one_endpoint(struct fimc_md *fmd, static int fimc_md_parse_port_node(struct fimc_md *fmd, struct device_node *port) { - struct device_node *ep; int ret; - for_each_child_of_node(port, ep) { + for_each_child_of_node_scoped(port, ep) { ret = fimc_md_parse_one_endpoint(fmd, ep); - if (ret < 0) { - of_node_put(ep); + if (ret < 0) return ret; - } } return 0; @@ -501,7 +498,6 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd) { struct device_node *parent = fmd->pdev->dev.of_node; struct device_node *ports = NULL; - struct device_node *node; int ret; /* @@ -518,7 +514,7 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd) fmd->num_sensors = 0; /* Attach sensors linked to MIPI CSI-2 receivers */ - for_each_available_child_of_node(parent, node) { + for_each_available_child_of_node_scoped(parent, node) { struct device_node *port; if (!of_node_name_eq(node, "csis")) @@ -530,10 +526,8 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd) ret = fimc_md_parse_port_node(fmd, port); of_node_put(port); - if (ret < 0) { - of_node_put(node); + if (ret < 0) goto cleanup; - } } /* Attach sensors listed in the parallel-ports node */ @@ -541,12 +535,10 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd) if (!ports) goto rpm_put; - for_each_child_of_node(ports, node) { + for_each_child_of_node_scoped(ports, node) { ret = fimc_md_parse_port_node(fmd, node); - if (ret < 0) { - of_node_put(node); + if (ret < 0) goto cleanup; - } } of_node_put(ports); @@ -736,10 +728,9 @@ static int fimc_md_register_platform_entity(struct fimc_md *fmd, static int fimc_md_register_platform_entities(struct fimc_md *fmd, struct device_node *parent) { - struct device_node *node; int ret = 0; - for_each_available_child_of_node(parent, node) { + for_each_available_child_of_node_scoped(parent, node) { struct platform_device *pdev; int plat_entity = -1; @@ -762,10 +753,8 @@ static int fimc_md_register_platform_entities(struct fimc_md *fmd, ret = fimc_md_register_platform_entity(fmd, pdev, plat_entity); put_device(&pdev->dev); - if (ret < 0) { - of_node_put(node); + if (ret < 0) break; - } } return ret; From patchwork Fri Aug 23 09:02:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjie Ruan X-Patchwork-Id: 13774801 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E781CC52D7C for ; Fri, 23 Aug 2024 09:02:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Bgq8YVPs8WXFCP9dyDVAkmIFPQWNhWkxL0ErEiOVRU4=; b=YQndw7Gblpq1kuTzVjwZlZMjSS l4BFn+TsvgQblSH/3pU/ufMms1H7X9N/3qIVjlM2pOTdBXzkURGsQ32i3n3TI1And8MKSjIGn6G+J n7y7ULiu4Qhk2TKU0Cy079mWH0vl5RqGPM85JWdYQDoNrVGHUc4iO/Z3wCE9kJzn5j+l+NFHuzTVe jHT7HkBf7X9ofPheUchahC0qfloqJE5a3yuMFl8Dbws+9HqozIyIehzq7gBeCLHROOYjHKYeLrvqf 8mx2NLFGVMMsRwcMyD7cy5HfDLI6C9yl4BJ0nFzHLO+6x1cgZaJ3RBa+zLyJzAw+AiNqyfY9U4Jdg 55yegyiw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1shQB8-0000000G0Ok-2ONh; Fri, 23 Aug 2024 09:01:54 +0000 Received: from szxga02-in.huawei.com ([45.249.212.188]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1shQ4I-0000000Fy7n-0rdb for linux-arm-kernel@lists.infradead.org; Fri, 23 Aug 2024 08:54:52 +0000 Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Wqv3C48nNzhY9j; Fri, 23 Aug 2024 16:52:39 +0800 (CST) Received: from kwepemh500013.china.huawei.com (unknown [7.202.181.146]) by mail.maildlp.com (Postfix) with ESMTPS id 0F3C91800D2; Fri, 23 Aug 2024 16:54:41 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemh500013.china.huawei.com (7.202.181.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Fri, 23 Aug 2024 16:54:40 +0800 From: Jinjie Ruan To: , , , , , , , , CC: Subject: [PATCH -next 2/3] media: c8sectpfe: Use for_each_child_of_node_scoped() Date: Fri, 23 Aug 2024 17:02:16 +0800 Message-ID: <20240823090217.436622-3-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240823090217.436622-1-ruanjinjie@huawei.com> References: <20240823090217.436622-1-ruanjinjie@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemh500013.china.huawei.com (7.202.181.146) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240823_015451_384202_BF6B565A X-CRM114-Status: GOOD ( 13.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Avoids the need for manual cleanup of_node_put() in early exits from the loop. Signed-off-by: Jinjie Ruan --- .../st/sti/c8sectpfe/c8sectpfe-core.c | 34 +++++++------------ 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.c b/drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.c index 67d3d6e50d2e..40ae91f65848 100644 --- a/drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.c +++ b/drivers/media/platform/st/sti/c8sectpfe/c8sectpfe-core.c @@ -658,7 +658,7 @@ static irqreturn_t c8sectpfe_error_irq_handler(int irq, void *priv) static int c8sectpfe_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct device_node *child, *np = dev->of_node; + struct device_node *np = dev->of_node; struct c8sectpfei *fei; struct resource *res; int ret, index = 0; @@ -742,17 +742,15 @@ static int c8sectpfe_probe(struct platform_device *pdev) return PTR_ERR(fei->pinctrl); } - for_each_child_of_node(np, child) { + for_each_child_of_node_scoped(np, child) { struct device_node *i2c_bus; fei->channel_data[index] = devm_kzalloc(dev, sizeof(struct channel_info), GFP_KERNEL); - if (!fei->channel_data[index]) { - ret = -ENOMEM; - goto err_node_put; - } + if (!fei->channel_data[index]) + return -ENOMEM; tsin = fei->channel_data[index]; @@ -761,7 +759,7 @@ static int c8sectpfe_probe(struct platform_device *pdev) ret = of_property_read_u32(child, "tsin-num", &tsin->tsin_id); if (ret) { dev_err(&pdev->dev, "No tsin_num found\n"); - goto err_node_put; + return ret; } /* sanity check value */ @@ -769,8 +767,7 @@ static int c8sectpfe_probe(struct platform_device *pdev) dev_err(&pdev->dev, "tsin-num %d specified greater than number\n\tof input block hw in SoC! (%d)", tsin->tsin_id, fei->hw_stats.num_ib); - ret = -EINVAL; - goto err_node_put; + return -EINVAL; } tsin->invert_ts_clk = of_property_read_bool(child, @@ -786,22 +783,20 @@ static int c8sectpfe_probe(struct platform_device *pdev) &tsin->dvb_card); if (ret) { dev_err(&pdev->dev, "No dvb-card found\n"); - goto err_node_put; + return ret; } i2c_bus = of_parse_phandle(child, "i2c-bus", 0); if (!i2c_bus) { dev_err(&pdev->dev, "No i2c-bus found\n"); - ret = -ENODEV; - goto err_node_put; + return -ENODEV; } tsin->i2c_adapter = of_find_i2c_adapter_by_node(i2c_bus); if (!tsin->i2c_adapter) { dev_err(&pdev->dev, "No i2c adapter found\n"); of_node_put(i2c_bus); - ret = -ENODEV; - goto err_node_put; + return -ENODEV; } of_node_put(i2c_bus); @@ -814,7 +809,7 @@ static int c8sectpfe_probe(struct platform_device *pdev) if (ret && ret != -EBUSY) { dev_err(dev, "Can't request tsin%d reset gpio\n", fei->channel_data[index]->tsin_id); - goto err_node_put; + return ret; } if (!ret) { @@ -856,10 +851,6 @@ static int c8sectpfe_probe(struct platform_device *pdev) c8sectpfe_debugfs_init(fei); return 0; - -err_node_put: - of_node_put(child); - return ret; } static void c8sectpfe_remove(struct platform_device *pdev) @@ -898,16 +889,15 @@ static void c8sectpfe_remove(struct platform_device *pdev) static int configure_channels(struct c8sectpfei *fei) { int index = 0, ret; - struct device_node *child, *np = fei->dev->of_node; + struct device_node *np = fei->dev->of_node; /* iterate round each tsin and configure memdma descriptor and IB hw */ - for_each_child_of_node(np, child) { + for_each_child_of_node_scoped(np, child) { ret = configure_memdma_and_inputblock(fei, fei->channel_data[index]); if (ret) { dev_err(fei->dev, "configure_memdma_and_inputblock failed\n"); - of_node_put(child); goto err_unmap; } index++; From patchwork Fri Aug 23 09:02:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjie Ruan X-Patchwork-Id: 13774798 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D0DFBC52D7C for ; Fri, 23 Aug 2024 08:59:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=TwdGsrBod8VS+0BJmLlGx3VbmIY+7Wslg6NJ7NiqMyw=; b=1uFTy4BT7fzRXMRMqZ56V9snZt OqbHgVA5Bl90SJmC8KmRAW0DlwHlI5WlMOa+vwizeyHFrpYr01Hzej+5biHBNp1vNZiLQqrcm8zMI qgXCNF9s2YaKejammbTm/tp61i4HjBykCJordMgmNu+LrRPy5dUEv3wWO00qH26OmJvN9AI1AyZux tCHXs7KrHbqBwI06QZ9ZNEOfHUWwhtLyTsTtvSSFUPjpOQ1twvnuDG515P2c0sbr7SjiUhyaSZfJd RLD7/zMc6oWK+2Dtikxmjz525SkD+hH4qcx0MMWHBiOeUdOakZk0unVKBLOtAiYzTIjbokeYoBwnK lVo1O39A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1shQ8w-0000000Fzl1-0iVX; Fri, 23 Aug 2024 08:59:38 +0000 Received: from szxga01-in.huawei.com ([45.249.212.187]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1shQ4I-0000000Fy89-071D for linux-arm-kernel@lists.infradead.org; Fri, 23 Aug 2024 08:54:51 +0000 Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Wqv545YHNzyRC2; Fri, 23 Aug 2024 16:54:16 +0800 (CST) Received: from kwepemh500013.china.huawei.com (unknown [7.202.181.146]) by mail.maildlp.com (Postfix) with ESMTPS id 8185C1800D2; Fri, 23 Aug 2024 16:54:41 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemh500013.china.huawei.com (7.202.181.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Fri, 23 Aug 2024 16:54:40 +0800 From: Jinjie Ruan To: , , , , , , , , CC: Subject: [PATCH -next 3/3] media: xilinx-vipp: Use for_each_child_of_node_scoped() Date: Fri, 23 Aug 2024 17:02:17 +0800 Message-ID: <20240823090217.436622-4-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240823090217.436622-1-ruanjinjie@huawei.com> References: <20240823090217.436622-1-ruanjinjie@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemh500013.china.huawei.com (7.202.181.146) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240823_015450_329338_6494B0A8 X-CRM114-Status: UNSURE ( 9.86 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Avoids the need for manual cleanup of_node_put() in early exits from the loop. Signed-off-by: Jinjie Ruan --- drivers/media/platform/xilinx/xilinx-vipp.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c b/drivers/media/platform/xilinx/xilinx-vipp.c index bfe48cc0ab52..8b2c39840656 100644 --- a/drivers/media/platform/xilinx/xilinx-vipp.c +++ b/drivers/media/platform/xilinx/xilinx-vipp.c @@ -450,7 +450,6 @@ static int xvip_graph_dma_init_one(struct xvip_composite_device *xdev, static int xvip_graph_dma_init(struct xvip_composite_device *xdev) { struct device_node *ports; - struct device_node *port; int ret = 0; ports = of_get_child_by_name(xdev->dev->of_node, "ports"); @@ -459,12 +458,10 @@ static int xvip_graph_dma_init(struct xvip_composite_device *xdev) return -EINVAL; } - for_each_child_of_node(ports, port) { + for_each_child_of_node_scoped(ports, port) { ret = xvip_graph_dma_init_one(xdev, port); - if (ret) { - of_node_put(port); + if (ret) break; - } } of_node_put(ports);