From patchwork Sat May 4 13:20:13 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: 13654022 X-Patchwork-Delegate: geert@linux-m68k.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2058.outbound.protection.outlook.com [40.107.22.58]) (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 D886A39FD7; Sat, 4 May 2024 13:16:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.58 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714828595; cv=fail; b=AaTH6O6L9AHh7l6mo980Lpwnbde0XBjPgw0VCysAOqqJdgbFLfBRfi/ThHCNXNh8R7AdiE4Gy8g0jjfyqjfkZNWEM1dtzqfwgjfBB0l/7lhPCt44n5d/7It3zCbUUBLKOIg2T3nuMsWLFcEmJLwxvAOA1sJqhC2IRjwc+o71ozI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714828595; c=relaxed/simple; bh=7oLy/VNXv8mod/yO9pa5qybVbR+daZZ1X7hIX56xPZk=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=ljsrVEScI7pvf0iAnssomqYaC8TZdcJPfbhF1BGOvNaboObH2lAX6xq5LPk+JvZvj6KvMSqnHcOirIucFBPY8rPcowbOtXKXSXFilCDc+eCmExKmm0+nVxNyd8pOUh0dk6bxTOTGpZIesgarw1bfAXY7mqNw/Q7ThykGMaI2xQc= 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=JwGL8Zs6; arc=fail smtp.client-ip=40.107.22.58 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="JwGL8Zs6" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LIMM1EBcMpsAfoIajRF8lWxzqD5W5hV8CGR9eAQIs2T1oAhTOaKF0HCpJcnlc8sroJw018a5EyhoY5IExC3qqM/iF61FMdZnyHLMLCHhq+o3yrexo0iu9Xr6TXSyls9xJcIV9CfYgZ+X/aCnw1tL8enOeJjt4t93iHXGazwvHkTRL9iCy39v8F84rGNy+ty1x9SjkVGouTe9sqS0rH8auDRgN7zXZLuVBTATTG/Q+EUh8bsjNjHp+HpDHsA7LAmZVOH2dIy2QjpI/oaqPgOrLmimERTvp+7q6Ez3IYJqHLdlc4/GhQ5pFdeXTBNPcjCVidkv+cXMKY7URRnZ/9XmTA== 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=G6JJzIlsATPz+eeVRC+tmQRXVLBCszxKxTWLO7z/7Rw=; b=iIBs6qs50gXDdVnot+R0Tt18PMfLYan0y5eX4WWZBZ6Rmn1OplAcASf2Ui7+GWnY0XYgH1qEIPRphOElHqDmFQ0Zwp6kIoZEpOkkA+jGHrU5kIwPxWj4a7Qfp9QyPyfzFcR/YpluMQWUoDneKgvXgDhQd5yzbpvUzSm9pGJU/ZhPNAtVfq9FVVodtKKzBKFkmrN+CHcjg6/6ldPW3ecglLQ6llosWZ/4FQCY0rikWyE9gVaYAfal2h9nPcS6PsLMFvNrT7JYHLWHqWyNYPCV/oFruvx2k2GN5W83t6C/Kc8qRswy4wIevZm6SgryLF3MhM/fbgDlE6Q6nM9FCbfr1g== 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=G6JJzIlsATPz+eeVRC+tmQRXVLBCszxKxTWLO7z/7Rw=; b=JwGL8Zs6PoyHk+U+trsx6DmiL7Uh7CdB7QXcgZ7fwYsKtjlQTGUndTL/ynWE1SI9AmOVt8aHUAITzcJGJjBmYWjzAdmi/zHzu3mXgciACNlrVtknBQWSZS3t4z9FZHrkV8M2dvU6mytpNprf/CaijdDfxEEPyGCXAiuTQK0BNhs= 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:16:30 +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:16:30 +0000 From: "Peng Fan (OSS)" Date: Sat, 04 May 2024 21:20:13 +0800 Subject: [PATCH v2 15/20] pinctrl: freescale: Use scope based of_node_put() cleanups Message-Id: <20240504-pinctrl-cleanup-v2-15-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=5535; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=CgYPpbd8zRZLHMaSBUod3MJSkUGYYuTkn7XHxXWmDfQ=; b=QThPNXw7bxO4a7RWVR+x8/it3yFCdDCIJhct6pJk1X4WfCzb33CCZ6xXajsk5epDPQ/hH1F0c spUFq/qYsKOCFwSsFFp6AnQ0TVEi4pJVnIpdLi/K9c5op0pxw0uris8 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-renesas-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: 826172fc-8f7a-47ae-4b44-08dc6c3c6988 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?oCEM8k9tR7q0B0/fG7ExEQCQQ5l1HFC?= =?utf-8?q?skLK3qMFv982FR04Lgr+kfktjdk7BLNGwUlkXfo1RbEXnXVNjtCH/YiZsjHOgnoAp?= =?utf-8?q?UBxu0UchRUjodbcO1kl9KTxjhWmi61vOTdIXdO5rDsgYhA18hknroBsO3+obYeTR8?= =?utf-8?q?Hfdw0Ue0issfoWWl6ZZP6P7Eq8ILFFrte9fCCDQdsyI5PhJ8cvWTMJ+8ZJ77p74Hh?= =?utf-8?q?/X3JaZSpVeDfG5PIk3ky/nHgr4xNXslwfzD5/JaPZBzheu/52+Je/4huA6AmcyvHY?= =?utf-8?q?KAoAQDwm27ufBghw0+yd/f7rNQOkIPoCqKimgbb9Yadw3lBK/cVm0c1fuRUpUW1pi?= =?utf-8?q?558W3EUsN7FvW28u69BITFwPLU6AzB0pI3nDVhOAeJqdr5438t4MEF6vJTIvSFrpD?= =?utf-8?q?6KWSWYVVxAgH0jJyWRyYBlgdGwU/fByw6HNlFpygvxC4L8B33WTOWeBUGwnaY+jzP?= =?utf-8?q?X1LI5DDhHNUQZ9wX0+6HIs9FgLRyvhB7BaPDxnOyB8Ox0LlHu5jl7SqCJ7jSG13+H?= =?utf-8?q?KqQkVE82MagVq73J7gA9f+XRMFVAO2KY2M/+Mm6XjGEzlnrNCgjPkjPFOyh3BTKyg?= =?utf-8?q?hV+SBXg+kUCeOdnEtd/3dwr0YGTV87DphYkw5bHFEgppLljD7SpORbQhyNK/PCoLy?= =?utf-8?q?e4MAi3fQj+ToFYWGonVI8xozH4iXaKnu2sawW7dfH3VDHp4of8WmV/HNlWryELkZV?= =?utf-8?q?IbSKK7U1h8qGkbiqmTDcczN6WM3DJ3R7k6PQ5xkfI3uq+Wqh/6ZCml/fBxkt1Qi1X?= =?utf-8?q?vEjg2oBK0Ol7DTPNoXZN2z9dLv3KWc76/qnDpMmKiACqHkebuRwCCYTD4iZUxyyX/?= =?utf-8?q?+feKnBSOONdCg64MexoaqxKpABim0oUDbS7nF9N9cidI9Tmvrehcu9LqaaJ/0ftPv?= =?utf-8?q?KK/S3VOnWBSIB/YttkI5XZr83whQiopfum+L16hr6rYcPIKensL1KhqWsCgDyhBC5?= =?utf-8?q?cj1PBCXg787UHUP5BkkKYXs2cTa2AXuGkI/XqaLB7YWH5Klnv7JBRaoWjXZ9QKvEq?= =?utf-8?q?sqQ7YCILsVqTRTSAhCmsGEpx2TWJ8AsumBJjZ9JDtSgH1S0nA3kPBbLtg4A8UVMgv?= =?utf-8?q?PKql5u0s+FEq6l5rbPikoS+2pJuh6QLqIpvwWMYwVB749fIlTV9g3qlCQZcwgTf6W?= =?utf-8?q?gNS8hgthapajQkYRuP3ISvsvmFItzMZiDcmeYGQhsalV10tW6XhhS/ruLf3e3MC/W?= =?utf-8?q?bb0Bvz6f5COv1FDG8ZwhY+T6AwDDQQBSWYsJQiFbnTTEHPBQOqWzjuQZ0jXs7vCJq?= =?utf-8?q?NtaoSDaV89UDScBjoYf3upchkBAb8opSVOQ=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;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?8RWWc/KtplBS2UCsXZvMfaFIRod2?= =?utf-8?q?Sz1limKFzSySJVbhImZIo14HcAZt8VF4o0HdKWB7vOz61AuvI/3nIvyaZ1xqsTzAn?= =?utf-8?q?r9psfqaTFibuMQXGAlJty/X+N4XK/bxLdb38URvrxTole9OqCjc0UqgBFvfu39+h6?= =?utf-8?q?/nExaPx858h+KIHFNom535ocrFkooup2nA/64ayaZyS3sicvroyVh9/qJgDgDk+XD?= =?utf-8?q?CmbIFdgdt0Os2/Xf8DgDS0zeAvifOh6tvoh+zNjh0pcRrs7Pg2DOReHh4xfckIGhn?= =?utf-8?q?sIc+32LU2SxHpt/Ai+FzBYXFdfyH9Ni8J662vTHtfY+18lFEnpTWTNlU6Gs/AinTy?= =?utf-8?q?P0oN466IhGC8mcO/p5+ezjyvh4L2vYTHWSDmqkDeYQ31I8pSfLYZ445vCbfgqJctl?= =?utf-8?q?is+HRaFOZ+xlIdkMnLaeCuOlJKFQqbYAoiHvAFl/KdcIuHiOSH2KyRbfDcPsGr1fL?= =?utf-8?q?raGsgPxXn0PkL+35pZew3LsWotab49xvOOYuZsWUjrlgJbcDuohjNv9j9skh3a5gK?= =?utf-8?q?i1viMsdaaeBiWwJXEmew7/Ep0GjQkahrgUhk+ozZVit7M+/gE7OEy3jlwDBPxX8wr?= =?utf-8?q?+c0H1L78uBtbKxVf8EH2wIRQy5+lRXpFzdBALbTTjaXUBFGY0PqbYSmhaGp398s/l?= =?utf-8?q?KW4tTq2e+gCwujraQMV9GFTpYlSlSOd183UlGr9melMVerkLihiScGgB++20qVxL5?= =?utf-8?q?CK21gmi7UAm5x7T2Fzdu63T20/6sJBXJkjPRQewwAu9XR+0KTH4aCdfq5ap8t84EV?= =?utf-8?q?fSnz9h0mFSIsLI/cDvF56E+gthTcxInyKvaE6EWCl8hMLtMa/Bjb0jUPIvVcnD6J6?= =?utf-8?q?2wqg49vbQZtE4XB9Kxvfb3hTWTE+CaJBiin99cFuXmAfB3V1dUCHp536SjpASY8D/?= =?utf-8?q?jCuxPd1S4p6Plimmo11kH07czL+0qfRqk+GyZBvSz8Y4nxaMU1yx64ExDZBavlN/M?= =?utf-8?q?Hvd+YtNAJyYzXUznztLzJRZyicXo+O/wCe45plSRS0paHVgIkPbiGaixq9MVeRnwu?= =?utf-8?q?poDy3ebZ1nezX4G02FxUt++yqnsxziE/eP/Agt5hCob6KXwAj1kt5brZc3mqqNL8q?= =?utf-8?q?p636F09TjdM/lsmCzSt7avWm4S9wPPLmshc6AM5/Jind2weY33Tbuy9sp/4AAQwXU?= =?utf-8?q?ggTOLwO0MfHkW1qrwCzhpqX9L+On014pAQFzh1hcw1qCOgckzUSbN9gDsGDEsIe2e?= =?utf-8?q?oRWGuG4pdqcAYM+Jayb//t8UnjuZp4Qyjkow1pCrKv2L93XxFwl3pSlL2YW6G0Fna?= =?utf-8?q?lIBrku+FU7dLvegO3c+1vPpakB9a1bsP8BzszBxsXewpcYuYhNd296no7yea+2Gyt?= =?utf-8?q?aVFyFpwdGJO7htRSRCulvk8AhjDOAP+5q8SXhQ4wiWJx2QoIso1NJvk42Fb/lDGQ9?= =?utf-8?q?NDJhEfX8D5cToM90V1t1GEMoBFOdBb80tdm3mmEYX1slQhY+KNOiLBseBYnG4BOnE?= =?utf-8?q?iPN/yIe80TMFbqo3JlMqXpgmtHKJvqTRmCr13nsOdG37bGATPPBfflGCiE1iMzSEk?= =?utf-8?q?tcOEaBrvJCgZ?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 826172fc-8f7a-47ae-4b44-08dc6c3c6988 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:16:30.5045 (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: vZZ7kr3dkSjhuW6rezuQjtYbweUoIm8juzVfBE1tlEK9WX76tRZQ7SkDKVhXwIHJQ/qGFmQ99JQhT5X1sU2CgA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8633 From: Peng Fan Use scope based of_node_put() cleanup to simplify code. Signed-off-by: Peng Fan --- drivers/pinctrl/freescale/pinctrl-imx.c | 25 +++++++------------------ drivers/pinctrl/freescale/pinctrl-imx1-core.c | 16 +++++----------- drivers/pinctrl/freescale/pinctrl-mxs.c | 14 ++++---------- 3 files changed, 16 insertions(+), 39 deletions(-) diff --git a/drivers/pinctrl/freescale/pinctrl-imx.c b/drivers/pinctrl/freescale/pinctrl-imx.c index 2d3d80921c0d..2b7448e3cd65 100644 --- a/drivers/pinctrl/freescale/pinctrl-imx.c +++ b/drivers/pinctrl/freescale/pinctrl-imx.c @@ -580,7 +580,6 @@ static int imx_pinctrl_parse_functions(struct device_node *np, u32 index) { struct pinctrl_dev *pctl = ipctl->pctl; - struct device_node *child; struct function_desc *func; struct group_desc *grp; const char **group_names; @@ -605,17 +604,15 @@ static int imx_pinctrl_parse_functions(struct device_node *np, if (!group_names) return -ENOMEM; i = 0; - for_each_child_of_node(np, child) + for_each_child_of_node_scoped(np, child) group_names[i++] = child->name; func->group_names = group_names; i = 0; - for_each_child_of_node(np, child) { + for_each_child_of_node_scoped(np, child) { grp = devm_kzalloc(ipctl->dev, sizeof(*grp), GFP_KERNEL); - if (!grp) { - of_node_put(child); + if (!grp) return -ENOMEM; - } mutex_lock(&ipctl->mutex); radix_tree_insert(&pctl->pin_group_tree, @@ -635,21 +632,13 @@ static int imx_pinctrl_parse_functions(struct device_node *np, */ static bool imx_pinctrl_dt_is_flat_functions(struct device_node *np) { - struct device_node *function_np; - struct device_node *pinctrl_np; - - for_each_child_of_node(np, function_np) { - if (of_property_read_bool(function_np, "fsl,pins")) { - of_node_put(function_np); + for_each_child_of_node_scoped(np, function_np) { + if (of_property_read_bool(function_np, "fsl,pins")) return true; - } - for_each_child_of_node(function_np, pinctrl_np) { - if (of_property_read_bool(pinctrl_np, "fsl,pins")) { - of_node_put(pinctrl_np); - of_node_put(function_np); + for_each_child_of_node_scoped(function_np, pinctrl_np) { + if (of_property_read_bool(pinctrl_np, "fsl,pins")) return false; - } } } diff --git a/drivers/pinctrl/freescale/pinctrl-imx1-core.c b/drivers/pinctrl/freescale/pinctrl-imx1-core.c index 90c696046b38..af1ccfc90bff 100644 --- a/drivers/pinctrl/freescale/pinctrl-imx1-core.c +++ b/drivers/pinctrl/freescale/pinctrl-imx1-core.c @@ -508,7 +508,6 @@ static int imx1_pinctrl_parse_functions(struct device_node *np, struct imx1_pinctrl_soc_info *info, u32 index) { - struct device_node *child; struct imx1_pmx_func *func; struct imx1_pin_group *grp; int ret; @@ -531,14 +530,12 @@ static int imx1_pinctrl_parse_functions(struct device_node *np, if (!func->groups) return -ENOMEM; - for_each_child_of_node(np, child) { + for_each_child_of_node_scoped(np, child) { func->groups[i] = child->name; grp = &info->groups[grp_index++]; ret = imx1_pinctrl_parse_groups(child, grp, info, i++); - if (ret == -ENOMEM) { - of_node_put(child); + if (ret == -ENOMEM) return ret; - } } return 0; @@ -548,7 +545,6 @@ static int imx1_pinctrl_parse_dt(struct platform_device *pdev, struct imx1_pinctrl *pctl, struct imx1_pinctrl_soc_info *info) { struct device_node *np = pdev->dev.of_node; - struct device_node *child; int ret; u32 nfuncs = 0; u32 ngroups = 0; @@ -557,7 +553,7 @@ static int imx1_pinctrl_parse_dt(struct platform_device *pdev, if (!np) return -ENODEV; - for_each_child_of_node(np, child) { + for_each_child_of_node_scoped(np, child) { ++nfuncs; ngroups += of_get_child_count(child); } @@ -579,12 +575,10 @@ static int imx1_pinctrl_parse_dt(struct platform_device *pdev, if (!info->functions || !info->groups) return -ENOMEM; - for_each_child_of_node(np, child) { + for_each_child_of_node_scoped(np, child) { ret = imx1_pinctrl_parse_functions(child, info, ifunc++); - if (ret == -ENOMEM) { - of_node_put(child); + if (ret == -ENOMEM) return -ENOMEM; - } } return 0; diff --git a/drivers/pinctrl/freescale/pinctrl-mxs.c b/drivers/pinctrl/freescale/pinctrl-mxs.c index e77311f26262..aee70fa55bec 100644 --- a/drivers/pinctrl/freescale/pinctrl-mxs.c +++ b/drivers/pinctrl/freescale/pinctrl-mxs.c @@ -490,16 +490,14 @@ static int mxs_pinctrl_probe_dt(struct platform_device *pdev, /* Get groups for each function */ idxf = 0; fn = fnull; - for_each_child_of_node(np, child) { + for_each_child_of_node_scoped(np, child) { if (is_mxs_gpio(child)) continue; if (of_property_read_u32(child, "reg", &val)) { ret = mxs_pinctrl_parse_group(pdev, child, idxg++, NULL); - if (ret) { - of_node_put(child); + if (ret) return ret; - } continue; } @@ -509,19 +507,15 @@ static int mxs_pinctrl_probe_dt(struct platform_device *pdev, f->ngroups, sizeof(*f->groups), GFP_KERNEL); - if (!f->groups) { - of_node_put(child); + if (!f->groups) return -ENOMEM; - } fn = child->name; i = 0; } ret = mxs_pinctrl_parse_group(pdev, child, idxg++, &f->groups[i++]); - if (ret) { - of_node_put(child); + if (ret) return ret; - } } return 0;