From patchwork Sat May 4 13:20:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan \(OSS\)" X-Patchwork-Id: 794807 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2059.outbound.protection.outlook.com [40.107.22.59]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E1FC22C1A0; Sat, 4 May 2024 13:14:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.59 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714828461; cv=fail; b=iPQKWmyvb+2vvvg8xwN2URpTqK/LDJnnFdq90a4l/C0/4euMXqpE1iBTypq9a7fe9Cex+fc/TjAgVi5Tfy91rGlRF7zXn4mUuvieqXgSX4kNKy8JqdB6+pVzwMiZ0Gkl7MifWpBJBqMME/Z3EjLiosIeG93g6EUL1OWGNwDcENM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714828461; c=relaxed/simple; bh=klyd7TcZI5h0sPA/ott/7mG9NW3OBXly1KYgwl3L3hA=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=X0f1pNk0Rs9DuRStvD16TrqRuEPsUi0lzAliVtzwaFercc6ey5FP3yl6MNkqoDRFS41++87viCmCEL1XIZKszSyI5P9nMKU72MGnzsZpMdmmhNZ5xBNhjrwlW92pNpgrlTuhqybn9c9X7dPbyZuA6kdsroKD/nqBi1RLiPAcG1A= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com; spf=pass smtp.mailfrom=oss.nxp.com; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b=CxNGfzcZ; arc=fail smtp.client-ip=40.107.22.59 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="CxNGfzcZ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e043KH9dCq8dWsmfeKQz3zMn/2C2bwJ7dl9LaOvScQd14Z1P3BuRUHiMQ4EWL2AX5BixlDRrF7G7hVqQ++bU27UsDQtNXIq+J25bfb1K+5Y4ewzDXjbek/UF1hq7yzVpFkX9i4zMiiBtcIwKWAFVxIzPXb51Ksfaf7FjCyQMPT1YNbluWlW0q5qZuVGhjNDDd6N1n8vftq18l6YfLwgDxYiSgzq1ARS3PPgXTGBuTD0M8dx2UgJcq6xWaWskZjYb1xbAg2lVRq0NJ82mgdVYvS/bLL6407xQ5iEbwcMgpMwkY2S/1aR7yKPX1fEKU5eesuS4tD18E+Nv1PVUQDRXUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xlpULG990sWFrI+9qxLt0ZBE85TdL60SLUPePmyaqSI=; b=O4Y2ScxgswofbZzRbVgTs64eSe100TK3S2nCZ+AafZ9bEEj7qu83tE2PQWUOfGYUt/0TDS4qPTzb+H2FYqHg4vtV9w5HZXKbXgofb6jXJ33H3SRRPoIyrRaCr/HXcAFG294xbPbrXOST5EWAojyL33MHs926WDQvsfy3zAqF9Uy4zGQi0sim7dbbyTuMaQsE1YZX5O6O+BLi2MBQlQ13uRGqmL+e2U8kB5iZhfv9964jflVaTOGLwKPUhRpShPW9m3TPQQFBcvfgwwlPZtLZRtjeS257Z4Wsg8DXsD0LG26zPLiNXKyuCwExzHKRMNFfX0P2j6yER4IOHXaRf4bl3w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xlpULG990sWFrI+9qxLt0ZBE85TdL60SLUPePmyaqSI=; b=CxNGfzcZ5jiD6UiFRzRV/406Ja8hQdGwImmDedFo6vSUAQUvVkb3fzxh1GmvkJ1+XRFIqmXPR9HqH/CNFpIvjFpmwMpnfOiqD7kceQQxiLXcuwj/BAIIXKMeHxBq80IcdBY527TNY2zfTABkjJFsegOU2y5BtGpEDMU1DONTAts= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by AM9PR04MB8633.eurprd04.prod.outlook.com (2603:10a6:20b:43c::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.34; Sat, 4 May 2024 13:14:16 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::d30b:44e7:e78e:662d]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::d30b:44e7:e78e:662d%4]) with mapi id 15.20.7544.036; Sat, 4 May 2024 13:14:16 +0000 From: "Peng Fan (OSS)" Date: Sat, 04 May 2024 21:20:05 +0800 Subject: [PATCH v2 07/20] pinctrl: renesas: Use scope based of_node_put() cleanups Message-Id: <20240504-pinctrl-cleanup-v2-7-26c5f2dc1181@nxp.com> References: <20240504-pinctrl-cleanup-v2-0-26c5f2dc1181@nxp.com> In-Reply-To: <20240504-pinctrl-cleanup-v2-0-26c5f2dc1181@nxp.com> To: Linus Walleij , Thierry Reding , Jonathan Hunter , Dvorkin Dmitry , Wells Lu , Maxime Coquelin , Alexandre Torgue , Emil Renner Berthing , Jianlong Huang , Hal Feng , Orson Zhai , Baolin Wang , Chunyan Zhang , Viresh Kumar , Shiraz Hashim , soc@kernel.org, Krzysztof Kozlowski , Sylwester Nawrocki , Alim Akhtar , Geert Uytterhoeven , Patrice Chotard , Heiko Stuebner , Damien Le Moal , Ludovic Desroches , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Dong Aisheng , Fabio Estevam , Shawn Guo , Jacky Bai , Pengutronix Kernel Team , Chester Lin , Matthias Brugger , Ghennadi Procopciuc , Sean Wang , Matthias Brugger , AngeloGioacchino Del Regno , Sascha Hauer , Andrew Jeffery , Joel Stanley , Dan Carpenter , Tony Lindgren , Stephen Warren Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, linux-samsung-soc@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-riscv@lists.infradead.org, linux-mediatek@lists.infradead.org, imx@lists.linux.dev, linux-aspeed@lists.ozlabs.org, openbmc@lists.ozlabs.org, Peng Fan X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1714828815; l=7378; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=rblCQQjgjZSJUmkJHlAJdcDG19G0fEKKnoN4VoqDxp8=; b=rP64dRmiJWkjbNAzDUBgxO/jiMdNGY2Dt53nxwhfN/1GpjWG/i9oTL6uo0n4rFB9bCsFKaLFJ jG5wo4Gqa6zAfFCB7rn9+S0tSvNdGYgf0P/NDnesEBdMWd+TqbHCddq X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2PR06CA0230.apcprd06.prod.outlook.com (2603:1096:4:ac::14) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9417:EE_|AM9PR04MB8633:EE_ X-MS-Office365-Filtering-Correlation-Id: abac60bd-c623-496b-f9fd-08dc6c3c19d5 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|52116005|7416005|376005|1800799015|366007|38350700005|921011; X-Microsoft-Antispam-Message-Info: =?utf-8?q?W4nB9+BotIUXWoAXy4d8CKPUZvHx+T6?= =?utf-8?q?HpViASP8rK07QaoYH2AnvU/bT9C7Xr4UUVziLlRvusRXetHfwOVm/PI7iO6QsZS0J?= =?utf-8?q?g6n9knuYbA3iVOfzea1lPBHPEsJEatY+KMPRYUBNpaXsSnF3irHdb3Qd0C4slFmkw?= =?utf-8?q?VPkVUHB1YCJm4DfBhpmMWEgyzKSvEANco6lvF7dE1nz9ZwQhtOoiPiVpC1e41fBhv?= =?utf-8?q?ja29u84t+bMeftoPh4Tw+pt34wDqkVbHYcNwy6UYmU8YscYW4OubLYEsSehD2E9Zm?= =?utf-8?q?SMdtMYWqrAODPmbJjelymBBmVMa4Cd3x08S8IIxFDRSoenbnZcG2LBauxPiqyaG7o?= =?utf-8?q?mbvsQA4gTjDBM031sIPWDx2zIsSLAeL4l7R8UlMzRZ7ae6advqEtjhQkR5wo6XRCL?= =?utf-8?q?gsACwislJQsnh8Td24cy0ssh2qQvdiZD2e7frMNaY1XI0NJaZxJ8lbQmzwn6GTL2l?=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; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DU0PR04MB9417.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(52116005)(7416005)(376005)(1800799015)(366007)(38350700005)(921011); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?ftL7oLDeKuJQxiyuIAet+AvwzeLe?= =?utf-8?q?ingb33Vk8fVdlmqclQxAfqnWc8yu8tt3oFnkiCseEeyVfU8H2fgU0UtV1mw9xGuMP?= =?utf-8?q?UFBHTf3fxBwSFmk5vkiSeI2XBYh+3UwE1W4NNLHxoZy6DOWeZlW55SCApB6+laq2o?= =?utf-8?q?+HTgY1gNLlJk6KCNPefnzB3feF5sDjVe9iiOsUVHi9nkQkFdZKtXRNw5D7jH9eMi9?= =?utf-8?q?nAYG6WX7gUIkDWAMg1tYMfyuSbVCCvBEJKUTWsdpHOxIxpFCyIAlFTb8Cj6lc7ZU/?= =?utf-8?q?cFR4CJEB/q/GFcueE8LJOIOiOYddoZirtbicC9NiIP3GqDMBncHQoMbjBGp23ikj/?= =?utf-8?q?P4tZxnK1oGnG1LW4kWFhJVQ1Jb0xzFR3wrng0dWT4XjP7pCCuSTdC9b/9gffgz+xf?= =?utf-8?q?FwCDiKAKiK7snEMyrNTEf1RvUf2faUbAeVMyoMSmnzERjG5UH8YWlD8urxGmrPYZw?= =?utf-8?q?OcPqtL11g+npN8hGVxWGF7+ZbBnZTScJ5G3FxWdC7xm/gYBwWcpLcIWSqhlKS9gok?= =?utf-8?q?mky9jv8BbA1vykzM0gNbBeoAMdikiQIxUCojMMgYenNoNM7mVobG5cSWaAcOpjx1x?= =?utf-8?q?25q2PWylYfUVRWSkdoMEWbH1T+/Fpg2kgwSQdy1Zm5OhFrEicJOIxDnrhfPnMm4dx?= =?utf-8?q?+KzM/8Nj4Gj+Q4sZcQsTCb0mYAloMC6HbxuPwCbD1r3t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enant-Network-Message-Id: abac60bd-c623-496b-f9fd-08dc6c3c19d5 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2024 13:14:16.8086 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: D7c/JWrShKmGOa5H4afl1vGgxSkCzZarqCkczeKZcBRMQ0KdqvL8ItqXWU6PkgfribG/1Sy3XlXOpFVDaCef6w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8633 From: Peng Fan Use scope based of_node_put() cleanup to simplify code. Signed-off-by: Peng Fan Reviewed-by: Geert Uytterhoeven Acked-by: Geert Uytterhoeven --- drivers/pinctrl/renesas/pinctrl-rza1.c | 14 ++++---------- drivers/pinctrl/renesas/pinctrl-rzg2l.c | 7 ++----- drivers/pinctrl/renesas/pinctrl-rzn1.c | 23 +++++++---------------- drivers/pinctrl/renesas/pinctrl-rzv2m.c | 7 ++----- drivers/pinctrl/renesas/pinctrl.c | 7 ++----- 5 files changed, 17 insertions(+), 41 deletions(-) diff --git a/drivers/pinctrl/renesas/pinctrl-rza1.c b/drivers/pinctrl/renesas/pinctrl-rza1.c index edcbe7c9ad56..6527872813dc 100644 --- a/drivers/pinctrl/renesas/pinctrl-rza1.c +++ b/drivers/pinctrl/renesas/pinctrl-rza1.c @@ -852,7 +852,6 @@ static const struct gpio_chip rza1_gpiochip_template = { */ static int rza1_dt_node_pin_count(struct device_node *np) { - struct device_node *child; struct property *of_pins; unsigned int npins; @@ -861,12 +860,10 @@ static int rza1_dt_node_pin_count(struct device_node *np) return of_pins->length / sizeof(u32); npins = 0; - for_each_child_of_node(np, child) { + for_each_child_of_node_scoped(np, child) { of_pins = of_find_property(child, "pinmux", NULL); - if (!of_pins) { - of_node_put(child); + if (!of_pins) return -EINVAL; - } npins += of_pins->length / sizeof(u32); } @@ -986,7 +983,6 @@ static int rza1_dt_node_to_map(struct pinctrl_dev *pctldev, struct rza1_pinctrl *rza1_pctl = pinctrl_dev_get_drvdata(pctldev); struct rza1_mux_conf *mux_confs, *mux_conf; unsigned int *grpins, *grpin; - struct device_node *child; const char *grpname; const char **fngrps; int ret, npins; @@ -1023,13 +1019,11 @@ static int rza1_dt_node_to_map(struct pinctrl_dev *pctldev, ret = rza1_parse_pinmux_node(rza1_pctl, np, mux_conf, grpin); if (ret == -ENOENT) - for_each_child_of_node(np, child) { + for_each_child_of_node_scoped(np, child) { ret = rza1_parse_pinmux_node(rza1_pctl, child, mux_conf, grpin); - if (ret < 0) { - of_node_put(child); + if (ret < 0) return ret; - } grpin += ret; mux_conf += ret; diff --git a/drivers/pinctrl/renesas/pinctrl-rzg2l.c b/drivers/pinctrl/renesas/pinctrl-rzg2l.c index c3256bfde502..fc7f33d3c613 100644 --- a/drivers/pinctrl/renesas/pinctrl-rzg2l.c +++ b/drivers/pinctrl/renesas/pinctrl-rzg2l.c @@ -745,7 +745,6 @@ static int rzg2l_dt_node_to_map(struct pinctrl_dev *pctldev, unsigned int *num_maps) { struct rzg2l_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); - struct device_node *child; unsigned int index; int ret; @@ -753,13 +752,11 @@ static int rzg2l_dt_node_to_map(struct pinctrl_dev *pctldev, *num_maps = 0; index = 0; - for_each_child_of_node(np, child) { + for_each_child_of_node_scoped(np, child) { ret = rzg2l_dt_subnode_to_map(pctldev, child, np, map, num_maps, &index); - if (ret < 0) { - of_node_put(child); + if (ret < 0) goto done; - } } if (*num_maps == 0) { diff --git a/drivers/pinctrl/renesas/pinctrl-rzn1.c b/drivers/pinctrl/renesas/pinctrl-rzn1.c index 4b2f107824fe..e1b4203c66c6 100644 --- a/drivers/pinctrl/renesas/pinctrl-rzn1.c +++ b/drivers/pinctrl/renesas/pinctrl-rzn1.c @@ -404,7 +404,6 @@ static int rzn1_dt_node_to_map(struct pinctrl_dev *pctldev, struct pinctrl_map **map, unsigned int *num_maps) { - struct device_node *child; int ret; *map = NULL; @@ -414,12 +413,10 @@ static int rzn1_dt_node_to_map(struct pinctrl_dev *pctldev, if (ret < 0) return ret; - for_each_child_of_node(np, child) { + for_each_child_of_node_scoped(np, child) { ret = rzn1_dt_node_to_map_one(pctldev, child, map, num_maps); - if (ret < 0) { - of_node_put(child); + if (ret < 0) return ret; - } } return 0; @@ -760,7 +757,6 @@ static int rzn1_pinctrl_parse_functions(struct device_node *np, { struct rzn1_pmx_func *func; struct rzn1_pin_group *grp; - struct device_node *child; unsigned int i = 0; int ret; @@ -793,15 +789,13 @@ static int rzn1_pinctrl_parse_functions(struct device_node *np, ipctl->ngroups++; } - for_each_child_of_node(np, child) { + for_each_child_of_node_scoped(np, child) { func->groups[i] = child->name; grp = &ipctl->groups[ipctl->ngroups]; grp->func = func->name; ret = rzn1_pinctrl_parse_groups(child, grp, ipctl); - if (ret < 0) { - of_node_put(child); + if (ret < 0) return ret; - } i++; ipctl->ngroups++; } @@ -816,7 +810,6 @@ static int rzn1_pinctrl_probe_dt(struct platform_device *pdev, struct rzn1_pinctrl *ipctl) { struct device_node *np = pdev->dev.of_node; - struct device_node *child; unsigned int maxgroups = 0; unsigned int i = 0; int nfuncs = 0; @@ -834,7 +827,7 @@ static int rzn1_pinctrl_probe_dt(struct platform_device *pdev, return -ENOMEM; ipctl->ngroups = 0; - for_each_child_of_node(np, child) + for_each_child_of_node_scoped(np, child) maxgroups += rzn1_pinctrl_count_function_groups(child); ipctl->groups = devm_kmalloc_array(&pdev->dev, @@ -844,12 +837,10 @@ static int rzn1_pinctrl_probe_dt(struct platform_device *pdev, if (!ipctl->groups) return -ENOMEM; - for_each_child_of_node(np, child) { + for_each_child_of_node_scoped(np, child) { ret = rzn1_pinctrl_parse_functions(child, ipctl, i++); - if (ret < 0) { - of_node_put(child); + if (ret < 0) return ret; - } } return 0; diff --git a/drivers/pinctrl/renesas/pinctrl-rzv2m.c b/drivers/pinctrl/renesas/pinctrl-rzv2m.c index 0767a5ac23e0..0cae5472ac67 100644 --- a/drivers/pinctrl/renesas/pinctrl-rzv2m.c +++ b/drivers/pinctrl/renesas/pinctrl-rzv2m.c @@ -388,7 +388,6 @@ static int rzv2m_dt_node_to_map(struct pinctrl_dev *pctldev, unsigned int *num_maps) { struct rzv2m_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); - struct device_node *child; unsigned int index; int ret; @@ -396,13 +395,11 @@ static int rzv2m_dt_node_to_map(struct pinctrl_dev *pctldev, *num_maps = 0; index = 0; - for_each_child_of_node(np, child) { + for_each_child_of_node_scoped(np, child) { ret = rzv2m_dt_subnode_to_map(pctldev, child, np, map, num_maps, &index); - if (ret < 0) { - of_node_put(child); + if (ret < 0) goto done; - } } if (*num_maps == 0) { diff --git a/drivers/pinctrl/renesas/pinctrl.c b/drivers/pinctrl/renesas/pinctrl.c index 4d9d58fc1356..03e9bdbc82b9 100644 --- a/drivers/pinctrl/renesas/pinctrl.c +++ b/drivers/pinctrl/renesas/pinctrl.c @@ -241,7 +241,6 @@ static int sh_pfc_dt_node_to_map(struct pinctrl_dev *pctldev, { struct sh_pfc_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev); struct device *dev = pmx->pfc->dev; - struct device_node *child; unsigned int index; int ret; @@ -249,13 +248,11 @@ static int sh_pfc_dt_node_to_map(struct pinctrl_dev *pctldev, *num_maps = 0; index = 0; - for_each_child_of_node(np, child) { + for_each_child_of_node_scoped(np, child) { ret = sh_pfc_dt_subnode_to_map(pctldev, child, map, num_maps, &index); - if (ret < 0) { - of_node_put(child); + if (ret < 0) goto done; - } } /* If no mapping has been found in child nodes try the config node. */