From patchwork Sat May 4 13:20:10 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: 13653911 X-Patchwork-Delegate: geert@linux-m68k.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2076.outbound.protection.outlook.com [40.107.22.76]) (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 5FE383D0D1; Sat, 4 May 2024 13:15:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.76 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714828545; cv=fail; b=cmVs+NTSjWNjcHNAVOZjEJ7116eiBdKJLGfk6ShxrV+uH9JpsZJhl6qBjj6Pxch70aEYB9EgsGgG5kSM2X295vXX2fz8ZhX2N/tOUZdKYcRwYVgLmJ3tY9OItuPj6ksret/TT/U6l1vZB3kAUn7xSfSF1pDZ2OwP80guYnDZxuU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714828545; c=relaxed/simple; bh=XjYcrC4knEYcZi59FiMv3CxGYKeUFr0HCFF+UrzXVqE=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=bNPdy1MrdJUKSoXP+ufOKTFu23TBJotMNVff8jCHciC4Tf4jYg+fKFQrDgJljd/20o+RKnITkEVINLrOEJJVi6I78IW3X0YmFY8aAobSEttKt2da2AQxZ1ALSJ/rJImkVT8Wh2Gmj9CgmE0dDlT09LgOi6GLQTLQ4Jv1v3KsWRY= 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=ikUa133S; arc=fail smtp.client-ip=40.107.22.76 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="ikUa133S" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W13wp9FiM++nWc+Yz28yg2bbPZLLdw+WTg1bDgGDy97n7my34QTBMGJm9rCBvzp1jMM40UEGyYOCjXD0zS8w/4qkYpLKQvl7qMriD27ylLz18r1NRpGpx71+GEwMlRijcmKKUhs+CFXmH3G9kKcmBss3HTxz6j5/wfn2/ZkDbfipOOFZwJudnMiD2ird4Hc/j/vk2HMY4xe4rTH60RivfIHTmI/7r/gxMu5AU+cvfzkbp3oXgi+gdfEF2NaAknoNou+/0PzqNZ5+f40vNXUDVNCCLF71gCdSTz7Sj63iiXWC0PUSOU1MYg18Pk0DfHCpTkaY8eI6SEW49xo2CPrxGQ== 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=lfJwrgHZf+RNEj6PZEelZwXcext4Fk8ZGEAWxpPRGZk=; b=EhXMCkb8gOkREMgpBl9dMK0MTGtMhyMCwsI/DCmdxXmz2BiDju4e0MARf+kdgnef3ekgtf/sA9wJjhLkLd6Woccc6Qi0oJ9qXs7HxQ4XHHn9TeSdhapuG31Hto5GwfCrDrrSFI74qAb7guux+hptHu8hvQZKzhaSYIDPhsgyorjn8xKgNNXFlwfRhwKyWTt7SG6vfhYriDHOeo0SOkJBpHhlAi6OWt4yqsUYKvHFcL4PAVylfJghDn6Pv8pNNg/UwTdNciF4jQVyFOU6oSCDIwWY4aCHM1nfV3820Dw/nCDJc4Pwz1nHR6zgMJtCOq8jckdo093BlwodHwDiJ8gSQg== 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=lfJwrgHZf+RNEj6PZEelZwXcext4Fk8ZGEAWxpPRGZk=; b=ikUa133ScwGjkZxB3mOk8JOHeMMaVQC05IL6z7ifMBDxhZikG5oDN5sD5QpBRr4tLPYGOACUrjCuJdwC44Z297sorvsDzH3xZIa//z39u4jVbrh6HxrLaD6DnCKoTP5EFf6x/zLkmrhHCBDTN7wVZUv4UsoaReDqBrH4StYeQPY= 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:15:40 +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:15:40 +0000 From: "Peng Fan (OSS)" Date: Sat, 04 May 2024 21:20:10 +0800 Subject: [PATCH v2 12/20] pinctrl: s32cc: Use scope based of_node_put() cleanups Message-Id: <20240504-pinctrl-cleanup-v2-12-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=2925; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=DE1TsODFhZuLZm6pDc3wReEJgqgWx9DxsgygoDyK3OE=; b=4lPD+sR8+ZJDBmnUSGc4BiJR63BC+fsZ9sA6ZLC22ieCU5l/dWZtPjTnnXlLTXwDaVFM8DgGy HeQBDCN8beEC267VymO0c1EOJ0IkKry6T9AQEMkG8hUVyAvlluXu2Hk 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: 0b200d19-f7e4-46c0-a449-08dc6c3c4bba 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?xHLPHeyT9tsHhS/evDi8fZCDww+tj4u?= =?utf-8?q?to1HTTholAYP727rq2DdxLNgkcqFi/59blmwxIz6/BOvXWPV2ycpDCQm1xSK+Iq8D?= =?utf-8?q?X+DYcCDjvLJAMsgQUMWKczcHRzXcdej1jWL7i8pQpw3JfFtUafohOXft7RHp8daWq?= =?utf-8?q?jpbyZqUFePUkOTtUoLNNx1iXi44Kx5Ea0Z4+fSSgJl2vY7oTgz+buDy0hxeiw20mJ?= =?utf-8?q?ybXGouUnbH09g5jMdDaJTvCumbHu791ts/6LS3CUYWw8jm7qImXg32udowtaLQINW?= =?utf-8?q?5s2crBuYFbm4gNEA2gs+hLKDS1LBvg29YQgLZry4/0X11kd3kKfMKRvk6M0+yMrRf?= =?utf-8?q?u2ZSDT7nE467vpHo/tJQYhvsctb2lAOCJpmHNIDYpt3wXcZ8dZ4/RoTaq20Y/b2Qx?= =?utf-8?q?1wdsiqkNzyfUQUQsDMZNFHmwceE92+WsRBqwWrlng7kok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WsMPdczJRUT9D+Qo=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?p6o6abnxST6DoCijFp+2Bno05NZG?= =?utf-8?q?GxOkLaApHDVQLZrlqsuxNeV4zVegVW9ri7kGjpPS2N0psATI9zUJvoQvCn1qQ98qP?= =?utf-8?q?nozkMO1t5msWWlSzO/JoUHGy5vj6yvGBevP0wPxYkOjkxe8ZcrUCV9tP6jS75umgG?= =?utf-8?q?z3rSNBtayyN8smFcq6Nw08kWXALTA94gSFd8McMHHFuWBw+8Q83h814B37hCAwfbL?= =?utf-8?q?j2vhM6EmlHy2ZNAb5wlVktY8rmPgJMAOhP9kGnilIFPA6c6diq1RIyFSF56GIFEYX?= =?utf-8?q?304h0r7KjIrI38NCnXM8QCa22D67ZldUSE3fyud5Frk45Qbfdl0nkerdoTB3aWhuZ?= =?utf-8?q?Wl6ykySTZ8OF5SO+yWPIEIwiY9iyQuuXUZ7TEXllPkq5QwWUxFo4Id7c4lakFfBgg?= =?utf-8?q?hOAnnmPLgGLHyX4K0n3Kg1Y3P3DIE6Qgo39UfAgN49sp6X05DUTKWwBVp3qkZKqO+?= =?utf-8?q?0TmQfPb6VS+VLrSZ6KStSffwVOg4sXvhb6zrT1CsaelEChGGUY2P+Te9xLFVr8bnm?= =?utf-8?q?ILRrwys3ljUCzUHekpAPgk5U3ZMkOROUOlM/CMrrvzhfXUL03ni8PVw8E2xifsue2?= =?utf-8?q?M+FuSaQjnJkKiF8Uvq16/Bibq0LyqymqamG4+0SHkrpW1JT/OWb+c7+yBooTP9eNt?= =?utf-8?q?nSlYLdDa7cfSf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AK2Gje/?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0b200d19-f7e4-46c0-a449-08dc6c3c4bba 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:15:40.5200 (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: kTB7cM73P9h5jqKaR9YGbwVTQwji2+xZXBGT2FJE8I8Ox6V09qZ1W0fqCU0ax8qp0sCNCd/aXZ64mGZHFKS8kQ== 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/nxp/pinctrl-s32cc.c | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/drivers/pinctrl/nxp/pinctrl-s32cc.c b/drivers/pinctrl/nxp/pinctrl-s32cc.c index f0cad2c501f7..df3e5d82da4b 100644 --- a/drivers/pinctrl/nxp/pinctrl-s32cc.c +++ b/drivers/pinctrl/nxp/pinctrl-s32cc.c @@ -268,28 +268,23 @@ static int s32_dt_node_to_map(struct pinctrl_dev *pctldev, unsigned int *num_maps) { unsigned int reserved_maps; - struct device_node *np; - int ret = 0; + int ret; reserved_maps = 0; *map = NULL; *num_maps = 0; - for_each_available_child_of_node(np_config, np) { + for_each_available_child_of_node_scoped(np_config, np) { ret = s32_dt_group_node_to_map(pctldev, np, map, &reserved_maps, num_maps, np_config->name); if (ret < 0) { - of_node_put(np); - break; + pinctrl_utils_free_map(pctldev, *map, *num_maps); + return ret; } } - if (ret) - pinctrl_utils_free_map(pctldev, *map, *num_maps); - - return ret; - + return 0; } static const struct pinctrl_ops s32_pctrl_ops = { @@ -786,7 +781,6 @@ static int s32_pinctrl_parse_functions(struct device_node *np, struct s32_pinctrl_soc_info *info, u32 index) { - struct device_node *child; struct pinfunction *func; struct s32_pin_group *grp; const char **groups; @@ -810,14 +804,12 @@ static int s32_pinctrl_parse_functions(struct device_node *np, if (!groups) return -ENOMEM; - for_each_child_of_node(np, child) { + for_each_child_of_node_scoped(np, child) { groups[i] = child->name; grp = &info->groups[info->grp_index++]; ret = s32_pinctrl_parse_groups(child, grp, info); - if (ret) { - of_node_put(child); + if (ret) return ret; - } i++; } @@ -831,7 +823,6 @@ static int s32_pinctrl_probe_dt(struct platform_device *pdev, { struct s32_pinctrl_soc_info *info = ipctl->info; struct device_node *np = pdev->dev.of_node; - struct device_node *child; struct resource *res; struct regmap *map; void __iomem *base; @@ -889,7 +880,7 @@ static int s32_pinctrl_probe_dt(struct platform_device *pdev, return -ENOMEM; info->ngroups = 0; - for_each_child_of_node(np, child) + for_each_child_of_node_scoped(np, child) info->ngroups += of_get_child_count(child); info->groups = devm_kcalloc(&pdev->dev, info->ngroups, @@ -898,12 +889,10 @@ static int s32_pinctrl_probe_dt(struct platform_device *pdev, return -ENOMEM; i = 0; - for_each_child_of_node(np, child) { + for_each_child_of_node_scoped(np, child) { ret = s32_pinctrl_parse_functions(child, info, i++); - if (ret) { - of_node_put(child); + if (ret) return ret; - } } return 0;