From patchwork Sat May 4 13:20:02 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: 13653916 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 ACA02C4345F for ; Sat, 4 May 2024 13:13:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Cc:To:In-Reply-To: References:Message-Id:Subject:Date:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=SFl73ULq4cta9fIJt1SHmTVx42DnUYXIHnPT29Royf0=; b=JtaJRh7wwQRcfiId8KePNjz7gv rovbxzeh4/nf24IrM/NenrcQ+BxuGPFPka7T/15QSeltmwXyAUlL7Z9fxnwKDhGjE3K+U6sHJaMs3 Ohzsd152xFAN7YHzl9uuQky1bkDI4b4lh9uxpx8o/2nmX/YLuyGiLxaQOyvStzJ4QEkHvPA76TZIj j06XZ0DJw6JxHdsa5J54go1FpPrlgr2htsV36G29vof21B3CQsPcAiEwMiCiHb7QQNM2lNdoidzJG t9NRuR4ixKRWl+JoZ34nsAHwBuBctT54sE5mOUzQUNXrIXP5EYRMptR/YhT+CFPkWQ2kNld53bggh t4z/vQXA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s3FCo-000000025g0-3WdP; Sat, 04 May 2024 13:13:34 +0000 Received: from mail-db5eur02on20601.outbound.protection.outlook.com ([2a01:111:f403:2608::601] helo=EUR02-DB5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s3FCj-000000025cf-2Udl; Sat, 04 May 2024 13:13:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W8dFrHb4e4KL7HwgGceMdwnIPATbwEajoCf0r1L751fG9TntfkojtXEFdwtU3+h4mGisBNyqodX9P/617fvvKWFPWxKVesYpSiNfQ8n/RRhkSVTQR/G4CqrXUZe5kqbNc18EwGKBOT+1RnK8SpANUOyYwY+SEYB4G6SDHCGZzWU8pzS94pMbF3xGWG6I0U1Y/Ik6reegZfH/pLahiWARc/kW1s+u3iYzsC1rwNBokyY+YWDlIXGS8lXQsaXkiRuluFYQu/tKOoN4SjT/5FMPs72IDiKaNoTvOWhm9gEZs1CAFtzVyUqLHFEOiFHuKC8zBN3OvjtFjjADEq70ZaZa2g== 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=2P30wZxS8Lt+11rd/nJOtDx2uGO5cN4rLrSAJ1jfCLE=; b=O62izbjHXj+4zdPt7+GiEoTPn8XodB2piI+Ga/xTuqqDcmWL9YM1JeivlJYchx61wb9HDbYxTJLgAgFo78/feSpBITmSsIsQX2uoJDhSRcT6zzZFFHcazvbiyvXEQYS8Aknsm1YD2Fgtg5D7ju3xiiP0MhbXDCDxFyRAUr7g8L8rP1Flxz13XuN2u1BOr8zF2XKrHV35s8AmEKn2fFtROZTMDgax8b0ny/gsVv4roL7RxmNYmvTuEgeMn5UjyvjEDOO+UCObxyNXu7b9BuyuGZTJPIdJO3NFSvTsSEj3lqXZTbU2W9zhsII+airVQrB9JAMhp7lkwyNT4Cu3blGHoA== 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=2P30wZxS8Lt+11rd/nJOtDx2uGO5cN4rLrSAJ1jfCLE=; b=EPpXBiBuohwFfGAUtTWvLzMJ2DMt4ltyln5SdZNBx/EDHOeCEMyumXCN8/sG48I8pRdal8qf6VU3jh7h5UhovOLHJgRoiDULw+dFDM21AVVJh135v+SO6E5K4vjpdQfOU1ITVUyr8xhWADRG989kAil8xzzq+wC9G2PYy63kYBw= 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 PAXPR04MB8174.eurprd04.prod.outlook.com (2603:10a6:102:1c4::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.39; Sat, 4 May 2024 13:13:26 +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:13:26 +0000 From: "Peng Fan (OSS)" Date: Sat, 04 May 2024 21:20:02 +0800 Subject: [PATCH v2 04/20] pinctrl: starfive: Use scope based of_node_put() cleanups Message-Id: <20240504-pinctrl-cleanup-v2-4-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 , Emil Renner Berthing X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1714828815; l=6725; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=Y9g/ve7R+m3W/e7zIx8b/uEfWQwRmgNvX+GDch7Of5U=; b=3vMnbw9Ysa7jrTpC44efhMT+UFQsFvhEKHMRSieT7F1Sbddy2bEGEc5EfpALwgSvWWAxat145 9aXjF5wEdpVCTILYnh3hhNbtAWkA3LZyCxa8WDZMWvRG7MOlkDt1Wen 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) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9417:EE_|PAXPR04MB8174:EE_ X-MS-Office365-Filtering-Correlation-Id: 5b5c4df5-44d8-4c73-20b1-08dc6c3bfbe3 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|376005|7416005|52116005|1800799015|366007|921011|38350700005; X-Microsoft-Antispam-Message-Info: =?utf-8?q?+gfrw/c0aUOQC7aFNAxcqO0bhyUV052?= =?utf-8?q?FRMAXxhbS8Y0RQJM0uBh8b609+gGNG9mrLIkjHeE4a+CG0iHIiYZOEMi/r3wQfEBL?= =?utf-8?q?kq0OF7xqPPLLqn1ERVpMXJxJpPVX+VUG6iZNWT6ocCQlcsayLGI62HldWy4Tq+164?= =?utf-8?q?6jxyc7rvoyRUhdCV8ddn1Gb+brCnRWNiTSDcEzhGV9lIIjWH6gKlHx/LjJjPlKCD4?= =?utf-8?q?aY0+sNEmaB8o0xh/b15mc0EjS+i4snCgj8OnWFitxuuAK1Um3W+k3FEWc1QABMKuh?= =?utf-8?q?esKtqgFddd22TBDzwdkxKFsiOub4l2XoWPPgHgERJ13TYHoSViT4YgC5hir5azKs4?= =?utf-8?q?8Otg5F5dRVAa4SrXGqHfK7BrAU2ZVfLtB5BXm043f+PCbn3ywd+onnmJTyDSA4gn8?= =?utf-8?q?5JFdvyV2lacrunJk//jf4XZQmB0S597TeDqjzCri/8xYYbrxcrq3E7GrfRuoasAn+?= =?utf-8?q?hl5AY1hB6kZQvH+CGByWVeO4M+SvpAbjPavzj/g0icszTbaxgHLWWH5/iijzt0uv4?= =?utf-8?q?AOi5FchPNUCT2oAFrvQofX608HsQSf6SV9p2X2eEhXScobQuxMLVgKaq1liaotchB?= =?utf-8?q?xjkmgQTwlvLZt2UI/sKEm4KFEQlP8uKOCRHTvpnVfDHvXDZ2HUQcdUgylQg0paLoE?= =?utf-8?q?EubTzm4sLZyXfh4OQcpkJ10w4Sky/n54Yeca31zC7tm52jIROMT70BbWDzAp9+jSN?= =?utf-8?q?johD+ipimW/N/CdJPPhLYZj0aKdboXz/YVTbDUaZpamdYJmHLkPIOoiEd6NCz2uQx?= =?utf-8?q?z2vyfyvwkkNRILi53/JMidWRsORGinWLDtB1ceGGIfHTbdXXRuytlgjmMNmZlVMD7?= =?utf-8?q?f+r24Ldj1A9aAOK3HcpgHGLUHpn1l6TFmJWSTAWgC5llg1mCR3cH3MEHY8G/iNYjH?= =?utf-8?q?Y3LL6hvEwNRcg7ye3DfAtKjwOMxW1tD+iawddBy4EnP8XtCouUv1C8bWV/3GsNMrK?= =?utf-8?q?n0VAiw/7sNZX36iz5l1Q8bHPgsG1P9x8NCYNkOq0NEK6JU9VrVfLUO2z/tlNmjeKw?= =?utf-8?q?ze/O8RqOLd+IRx//rOiQLHTN+ZOfKVKu/I9UyC2/Q6G0xdcrSdKDZo9GN+WuQmEZP?= =?utf-8?q?13MG4kKNrAlcSCX7EgPSGh2MloVUhUitG+Yy9prKeWcSmAYSUw38+9sIiH7wLdnVW?= =?utf-8?q?jDvJxcWGtII6jW1nwrAKyc/alskPVQlqV2Dl3xy6Fu/LdNTR0VVfAd/uLQqbzNL3o?= =?utf-8?q?I/2P+tDvj+5KYwPPoIjWE03y5ldU9BxJitkMWtj2WlkEWVJ/fH6ockSKl3FBufz6H?= =?utf-8?q?7P7cpbY3ZkwhWr+UxN7WtDpFuauAHUjj4roOv7Z8aHFjl3q8i7IQtP6s=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)(376005)(7416005)(52116005)(1800799015)(366007)(921011)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?cmMrAeEEFong5d3lrzGvP5p0m39H?= =?utf-8?q?kIGNrPvNxVsQdlv2luYZ66XwTPBye9qMRnwTQYXZdiYKHNGMHrFgWSiWMBkdLr+Ff?= =?utf-8?q?SWx+Spny+4xkA4fTn4VDP4j/HnvfVDPjT0vLGX4dXOo/LMb+dv5BO1IH7ZQoy0sRa?= =?utf-8?q?IVOuTRL6aBAcb9GZLFBLnpacegVAOLw4NuuPEpm3FG+2MLBNXk9GlFN3fRxE7744J?= =?utf-8?q?Oy12ClRtmvxyNGqTsIhVjMI4X6Uoj07saNbleEzm1OFr9SpO8PHQk2AM0ezGbduhB?= =?utf-8?q?dOLo24ri/bsFNeHriB6Eu/4MH+1du/uCuIDBfBCk2tDs+PeIIJ8N0AN7aMnXsZX+U?= =?utf-8?q?wdHsUPCvzuVkA19G6vh0zekFfr2fjFF2aBfzzXAhZeWgRJMKSJ75YL7yq0Vhic2YL?= =?utf-8?q?HLGXI84LVIliPJnVudwWPVpqPQQiwtiVhriTyBEhwqTv3Sp+hKlu6a0RBA3BnT91J?= =?utf-8?q?+K9VS5/he3He1qr6aHbChTgDRmcw8XoQLDSlq181a+MOoEKCTAIVvQ3wjJccMquVh?= =?utf-8?q?h0Fu52AbpYKKmKGCjTSTD42S/sSteBD41ttxi2STRhuiENghHhGf63lmfwCwcfY+p?= =?utf-8?q?V4XVL7fMRlGMW8p7gQ5SloW3m174wd2FVjJISn3YEMsERQXyEfaG1V2DyJM7LwXIi?= =?utf-8?q?UpqFbxRz3LZMX7b9q7fiTehW0oJdXhSIV+ovloKekoqmR2uA636dSoRSXrmWFTn0B?= =?utf-8?q?RPuz0seMeYqnbD1kTRmeECORJ6luB9+WCHhgUIP9nYrbw+R+9JW0IEpbqCHl6tEQ5?= =?utf-8?q?+KV5lqvn3RYNwC3MwAbmpxxVRVB7aFy1y3/ihTsan9pKHp/WjPfPLJXj83d+a7TIy?= =?utf-8?q?loREVpRKxO9iR9k+EWstXL6VD6Ur09U6mzf3TkKnqFbG5B0l17A4UY4eoKLhvJ9TC?= =?utf-8?q?aVRPrHcBCymxul8ITBP23A0dNaPud3mHUm8+rlySfM6FBExs4feiy/bQPs5kWg7sN?= =?utf-8?q?ZnMSX64grkU+lK1YQOYX+RVZp+S4c8D7U82roEDa4eGKr6rFeVOjv8bgUwZeubF0A?= =?utf-8?q?zTuDnxYg1hTyqIP752EhFSoKRdgTxiUAnTiC9ThSobNZnxTPRF9lDzojQgqgtpZLh?= =?utf-8?q?RSzw80csjy5epalXPI/GqZipwAJiPTgBTdDKB/SvY7J/Nsd27EDVNjKTXA2pWD7pr?= =?utf-8?q?VYbyI+kpXxibhCPAViqjjypl2lGApFJdBUD9Bm+rlGLJxI4rh9sp9pyqve4ghAvHp?= =?utf-8?q?h+1MPKo2oXKakqkYRdQGNuerVHfwwAxLZmVELEFEoRt9xuUhxDS5vxswBwTYC0wbr?= =?utf-8?q?06ta+A/9dXfIgjO2oqSmR2jSqh4fvHgQFxlBYv9daF0rntdzljTlXg1KuMBGdBLb/?= =?utf-8?q?Y5CLCfuWBCFBXrJxid+29cNR7btMw/SqOlJG6U8C84eU2ysKLWqqcAVMtig15aFzN?= =?utf-8?q?wscxr9/b+p1Xz1H5uTyPrLn/fnqhSgl5FqAcnYmxYPTTcE76ioGNKHJBBaS6OAqoC?= =?utf-8?q?NEyIZRpC+uxx49KHxHTJndacYDlfTNxdcCnHzuiL2rxNDZXthDH4qtOAYpv32DzYh?= =?utf-8?q?9COHf/VGFMxv?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5b5c4df5-44d8-4c73-20b1-08dc6c3bfbe3 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:13:26.5554 (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: IsKCV3MzsPaHV6FuLQIUwE1z3AlbnmuFE+6k6bOen/PYAptY1ACmRlUrV16UCorDIjT5k+tijSoDho+Qyfas5Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8174 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240504_061329_873154_B62F1E73 X-CRM114-Status: GOOD ( 14.26 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org From: Peng Fan Use scope based of_node_put() cleanup to simplify code. Acked-by: Emil Renner Berthing Signed-off-by: Peng Fan --- drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c | 27 +++++++++------------- drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c | 18 +++++++-------- 2 files changed, 19 insertions(+), 26 deletions(-) diff --git a/drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c b/drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c index 6df7a310c7ed..27f99183d994 100644 --- a/drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c +++ b/drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c @@ -480,7 +480,6 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev, { struct starfive_pinctrl *sfp = pinctrl_dev_get_drvdata(pctldev); struct device *dev = sfp->gc.parent; - struct device_node *child; struct pinctrl_map *map; const char **pgnames; const char *grpname; @@ -492,20 +491,18 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev, nmaps = 0; ngroups = 0; - for_each_available_child_of_node(np, child) { + for_each_available_child_of_node_scoped(np, child) { int npinmux = of_property_count_u32_elems(child, "pinmux"); int npins = of_property_count_u32_elems(child, "pins"); if (npinmux > 0 && npins > 0) { dev_err(dev, "invalid pinctrl group %pOFn.%pOFn: both pinmux and pins set\n", np, child); - of_node_put(child); return -EINVAL; } if (npinmux == 0 && npins == 0) { dev_err(dev, "invalid pinctrl group %pOFn.%pOFn: neither pinmux nor pins set\n", np, child); - of_node_put(child); return -EINVAL; } @@ -527,14 +524,14 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev, nmaps = 0; ngroups = 0; mutex_lock(&sfp->mutex); - for_each_available_child_of_node(np, child) { + for_each_available_child_of_node_scoped(np, child) { int npins; int i; grpname = devm_kasprintf(dev, GFP_KERNEL, "%pOFn.%pOFn", np, child); if (!grpname) { ret = -ENOMEM; - goto put_child; + goto free_map; } pgnames[ngroups++] = grpname; @@ -543,18 +540,18 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev, pins = devm_kcalloc(dev, npins, sizeof(*pins), GFP_KERNEL); if (!pins) { ret = -ENOMEM; - goto put_child; + goto free_map; } pinmux = devm_kcalloc(dev, npins, sizeof(*pinmux), GFP_KERNEL); if (!pinmux) { ret = -ENOMEM; - goto put_child; + goto free_map; } ret = of_property_read_u32_array(child, "pinmux", pinmux, npins); if (ret) - goto put_child; + goto free_map; for (i = 0; i < npins; i++) { unsigned int gpio = starfive_pinmux_to_gpio(pinmux[i]); @@ -570,7 +567,7 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev, pins = devm_kcalloc(dev, npins, sizeof(*pins), GFP_KERNEL); if (!pins) { ret = -ENOMEM; - goto put_child; + goto free_map; } pinmux = NULL; @@ -580,18 +577,18 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev, ret = of_property_read_u32_index(child, "pins", i, &v); if (ret) - goto put_child; + goto free_map; pins[i] = v; } } else { ret = -EINVAL; - goto put_child; + goto free_map; } ret = pinctrl_generic_add_group(pctldev, grpname, pins, npins, pinmux); if (ret < 0) { dev_err(dev, "error adding group %s: %d\n", grpname, ret); - goto put_child; + goto free_map; } ret = pinconf_generic_parse_dt_config(child, pctldev, @@ -600,7 +597,7 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev, if (ret) { dev_err(dev, "error parsing pin config of group %s: %d\n", grpname, ret); - goto put_child; + goto free_map; } /* don't create a map if there are no pinconf settings */ @@ -623,8 +620,6 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev, mutex_unlock(&sfp->mutex); return 0; -put_child: - of_node_put(child); free_map: pinctrl_utils_free_map(pctldev, map, nmaps); mutex_unlock(&sfp->mutex); diff --git a/drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c b/drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c index 9609eb1ecc3d..4ce080caa233 100644 --- a/drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c +++ b/drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c @@ -150,7 +150,7 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev, nmaps = 0; ngroups = 0; mutex_lock(&sfp->mutex); - for_each_available_child_of_node(np, child) { + for_each_available_child_of_node_scoped(np, child) { int npins = of_property_count_u32_elems(child, "pinmux"); int *pins; u32 *pinmux; @@ -161,13 +161,13 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev, "invalid pinctrl group %pOFn.%pOFn: pinmux not set\n", np, child); ret = -EINVAL; - goto put_child; + goto free_map; } grpname = devm_kasprintf(dev, GFP_KERNEL, "%pOFn.%pOFn", np, child); if (!grpname) { ret = -ENOMEM; - goto put_child; + goto free_map; } pgnames[ngroups++] = grpname; @@ -175,18 +175,18 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev, pins = devm_kcalloc(dev, npins, sizeof(*pins), GFP_KERNEL); if (!pins) { ret = -ENOMEM; - goto put_child; + goto free_map; } pinmux = devm_kcalloc(dev, npins, sizeof(*pinmux), GFP_KERNEL); if (!pinmux) { ret = -ENOMEM; - goto put_child; + goto free_map; } ret = of_property_read_u32_array(child, "pinmux", pinmux, npins); if (ret) - goto put_child; + goto free_map; for (i = 0; i < npins; i++) pins[i] = jh7110_pinmux_pin(pinmux[i]); @@ -200,7 +200,7 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev, pins, npins, pinmux); if (ret < 0) { dev_err(dev, "error adding group %s: %d\n", grpname, ret); - goto put_child; + goto free_map; } ret = pinconf_generic_parse_dt_config(child, pctldev, @@ -209,7 +209,7 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev, if (ret) { dev_err(dev, "error parsing pin config of group %s: %d\n", grpname, ret); - goto put_child; + goto free_map; } /* don't create a map if there are no pinconf settings */ @@ -233,8 +233,6 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev, *num_maps = nmaps; return 0; -put_child: - of_node_put(child); free_map: pinctrl_utils_free_map(pctldev, map, nmaps); mutex_unlock(&sfp->mutex);