From patchwork Wed May 1 12:56:08 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: 13650642 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 BFE8DC10F1A for ; Wed, 1 May 2024 12:51:17 +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=DVaemn8wGKQn9nMqBJN82GAPsZaiz2I/mK96c2o5o3w=; b=DuVbQYEhXK/H/Klk+8uDP8+KD3 EXGybGzKA3PIEI1VBOB05xZVcXTudfUE9v7OQSNLL6nYSzIbFKSpmOlkO+FoFc6rzs5GYMDrJ5J8f /NKMJsvqWGAiGhbVDXVPD3hl0ArePz4rBcug7leKoLnGJnGj3sHm5J4cMjYAlESOVWtscPZD/D9Vo KMzyB8Bw0o+TJukgY99U/nQKOqPRICOdGRCtTSxyUuLqvI+u2kfAhZiVLVUsdjxxecHsFgMEngCiS EzE+KKx+0+1w2lrmMCGdVeIiEJHkSJ/h6ACqzlLVlo0pgj2sa0swayZvieMbGAUuVvjf2bMez6CVq ApvZGAUw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s29QY-00000009Za3-1NX6; Wed, 01 May 2024 12:51:14 +0000 Received: from mail-he1eur01on0620.outbound.protection.outlook.com ([2a01:111:f400:fe1e::620] helo=EUR01-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s29QR-00000009ZV6-44Xl; Wed, 01 May 2024 12:51:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mx2AIyIGzfd5Q77t/6LKVx/pkHtkuA2Yj0BCsuwrQVDHwErQBzHCXeXnqjYohlr3QMElIR6WaLBzrn6wDFgMN2/o7kyNeGkBirwKGPTKRbGx4qDcbY/qWfjZ/HgLidONo7R2mF02FD2MW2+WlFwbUMdWSBTMAJb+BcW4HEbaF6JhNyTqqBoE9ACTKBlCXjNENbd2z55sc+LWPiMQnZcXJnd8dRRVRT9q4mVEsYJcDZYCzuwA++YRz5ESw4KUJ2yctoeDpSykjgtwf5Xf2E2H4vaFYpF6ygESZO2/Ex6elMMwkmB0IjKr78b9FALhVuF9S7mmwyAaqjZdKIaCfc17Pg== 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=sKdrrsLcFbXA49UIlhYel38tScIuaU0cV37+EwKMmJc=; b=jWJIiTtQ2JWx1tXUI3O/a+3V4flt/DVMAVhRT9e/oUUR3d8sLCGsR49oPGzLJEcaPE2XgAqq0wQk5foByxskM0c1vBtfr2LSDG4zpTtRvRylt9ZeHpFsgoptWwW0sTPX/KPIfRieHn2qNTAjIuJL1kGrq3OQQTTjIWnXtdt8N//1aqtXiCFBTgaUDsZI0fueepUQFlLNQyQnKfwuHZapZE6f4+KcLpUXUQiUUKwGcqNJmmz7RlxinXZeYGObXK9uriPebFBJhqwVn1HdzGRQgIE6mnlZbz+U952vQX5Nkxj6xtYe2UmQDeiHoEbJUyE54wCsZ25Ug7rWmSFSuMpQ6Q== 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=sKdrrsLcFbXA49UIlhYel38tScIuaU0cV37+EwKMmJc=; b=J2Oo6RqI3waIqz8/6pJE5VIjvbMXZSe5gUN6zo25Gx2wRaUYN3JXtAC7WssgiIVDpRHrMpNXfPVN/IOqJkvmJI0vAVG7VqGK1VpTktBlB9Z+s3qmpAcohAoUsisgnz/QGmQAAxIrC7PvIy9KaMJvF6Z72sok1m3zgN1+94QRUjU= 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 DBAPR04MB7448.eurprd04.prod.outlook.com (2603:10a6:10:1a6::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.38; Wed, 1 May 2024 12:51:03 +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.7519.031; Wed, 1 May 2024 12:51:03 +0000 From: "Peng Fan (OSS)" Date: Wed, 01 May 2024 20:56:08 +0800 Subject: [PATCH 10/21] pinctrl: st: Use scope based of_node_put() cleanups Message-Id: <20240501-pinctrl-cleanup-v1-10-797ceca46e5c@nxp.com> References: <20240501-pinctrl-cleanup-v1-0-797ceca46e5c@nxp.com> In-Reply-To: <20240501-pinctrl-cleanup-v1-0-797ceca46e5c@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 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=1714568179; l=4898; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=VzwfunaS6oe6w00xXDeMo+Rdw8rpK6f5f57ZNP6p+Dc=; b=YiGY2Rbt/DyQTdPhzE0bccyp3SEualuIWcMVbzLs6lRVW3PSd10C6Ggee5a8mAP3Fy9euQt33 dt4PDc3LBg3BrTeQEfKFaGCAetnU0PJZf9U8UlJdlsGdqeAQHUFcjkh X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2PR02CA0064.apcprd02.prod.outlook.com (2603:1096:4:54::28) 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_|DBAPR04MB7448:EE_ X-MS-Office365-Filtering-Correlation-Id: 14565aa8-5af1-4eda-0f3b-08dc69dd5c53 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|1800799015|376005|7416005|52116005|366007|921011|38350700005; X-Microsoft-Antispam-Message-Info: =?utf-8?q?mNzP/IPVwmMsCAwETAl5wsOwgykWjjP?= =?utf-8?q?c+jVI7Tg071dU3f24pzQ1X4RbfnQrxzSHXjvXcfUdatCDy78Q0MiMJwSH3PTL6H3+?= =?utf-8?q?EUAMjLLLnWbKverdmEHU9UJZmoVeECnNb/bPJv/HuXOJmDxF5Bie1/NFGyb4Y9t0+?= =?utf-8?q?GCc5dUvIT6P7Cu8zlAK5F7SuEU0PnZRRUY3G3ETom2DFBxCzxVCOOqb1VkAfLYYoj?= =?utf-8?q?xH4XP4bqXA1/9U6KKMCSJjz5hZteMDcOjKldtBAprUlQzmHe7R5vmd8j2a6rX/EVH?= =?utf-8?q?EWEpK9vzaKseIr89ngn/WSTOs4qvC4zq4XqzXnltbndUYRTKRXTHaqfwh0JoK2Luc?= =?utf-8?q?TNmTISJaIFcvPOhRQcIo/VIiBGAhstxQz8NyqFFewfXrk6ulVdsspWzlCYQGTS0b5?= =?utf-8?q?Z4jnfYowCs86q2NeSnMsBXkS1X4gswJdayVHrRqsV327udNA7dtJe5/T3bF+p+bXL?= =?utf-8?q?dtFD/8GsAPEPyYvt80gnoxWPrzbehS4l5e6C6GK6Wy3+Wns2APMFv7dhFExSvDxy4?= =?utf-8?q?TbhGognVb/f2DwyQxYRs/GnAYILDREc0PMS0TtSc6hx+970elYnOu0d2FjX2tk97Q?= =?utf-8?q?97fS4vRA2BgFpprac1nToW3nY9U8zNpo11MAiqYAxEL4E1DHWnOhzGXD7Uefx62mE?= =?utf-8?q?0FaG560tR8txtjqwpW9/hb6c1XZJHdfGBGCW/ivT/CKpEcksEfYiXb/eGQ+EOBu4m?= =?utf-8?q?rknBfh9h0SzqcEpL7+6NniPAcBhJO9579SJWXIRQWjOWckDkf2114dn9dAMFEUn9F?= =?utf-8?q?XFf+MosjYHQ86ggxO5dZU3NZZZZerj8+LR4P9MyxvhL1GOUMVfh/eFco55lSKkiYB?= =?utf-8?q?Q7pbNs5BQWxiTnnFmbwjC4jU0j6DDupWE97eEMMDWvrkdaNVDvBvWC7HSwLN1xnDD?= =?utf-8?q?UMUDyH4Y9/KXyvr/GelKIlT2/Xj1aqJ4FfBk7ji1dZsNWWcXDHqIY6683xbf/Df+e?= =?utf-8?q?NG+dxs+hJj9uLtsAkN9fj4rLD7srFilHma+3jVxUPhcn5EDWUAn2tQDeEYaBua7c9?= =?utf-8?q?RqFX9MuYuovtzVmHiAat/ylLUmxThsrKqMLpNlfCo9yaAUBv4jJ10oa1iTDn9/Ng7?= =?utf-8?q?G7s3RYECYPnZA/J5yARfHndKG3jqDnDKkRr1RJHB5j4FnghWDHwGN1mxGdhlL1p3P?= =?utf-8?q?6DMnuYjlGPkLSTAu95OuJVAijf4gk4+kF/0eL61p3qs7SCDV+WIzkM60yGyOcAwG3?= =?utf-8?q?8xZeeGTUj7yMIyjfBhR1xSQ0AuzEgG1YELiuGxckg/eIvOgrqQ09V2JmgxK+mB1ab?= =?utf-8?q?/xGdvbsr+GHiiBEjT6UFp5i67KJAnTJbFGNEOaKDpzC9uzZnDDDKVjOk=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)(1800799015)(376005)(7416005)(52116005)(366007)(921011)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?eR/XMZXiU5kpiRxCJW8xGK++Vx0b?= =?utf-8?q?OeEEtivU7T7numAm+FVoM93lYbr5pIZ3MLvUkyssiLwWZIpN3dl1P+TF5pFL5JjEI?= =?utf-8?q?zIUpOZwskP+wuLkn7HZdN0pXrCA4R7V4kCagPzulWj22jB5DcYlsZp/5P5jylpUjd?= =?utf-8?q?ikaMTnlVdL0yI7fbxnge37i04NFObfqSDyuumFxUQRNAVkOUrhGE17f77B95vYzHY?= =?utf-8?q?lx0vq7JPmlOOjsw7rp2cRWjad2A7204yLoAc5KBGsK3lxh7AJLfq3mxqyETAbaCNU?= =?utf-8?q?Ae5h3ovwANHwbM65DCRgdJQEt4dePce2STApCOE9GXwFSFZcF9nJEiTyIuX4lXX6H?= =?utf-8?q?qUJ8q4efwMijK8cl6gUkCRdLlPvQKa/VTB55yX/Ku+63U58uyCpbucqp5zuHelC6h?= =?utf-8?q?wkwojLJdf/VhTwvPBf3TFJdnEYrZUpnOkit5z3xQb5FK6TsK4BPvnUv3M5Qz5C5kx?= =?utf-8?q?gasQ1OezgJvSvJ9a1sqrPqj1wYqp2OhoCqpPPJhOkS4CxISAxnSHNmgGE8/4ccXJZ?= =?utf-8?q?DUWWHCBI80eLVaKpuOG+6enpLQS9QeBR4H58fmDPXNPPJnyLqsz7fY/3AYdNyunNz?= =?utf-8?q?OsNIfDQCaVaozXK1/NwP2ppihXQuZNXsR69ZcLuupbRhGwMgx6EoCmkwkuqWdNXz+?= =?utf-8?q?EsTy2mA7qpRxt6sc7j/Zx451Jzu/QemucB6cjMyl9k44neqA9r6jjJrILkjDxuU5a?= =?utf-8?q?hqQHsPr/nBb8KgQMdZZR6XOyPFZGpxjXogsc023jmEOTJ4xgg73+Vt8tFRO0gNl8U?= =?utf-8?q?JDCyZx/QdnnRTmALNJLZvYj8xYJneVBuZBVBiTjjVpTspoCztl+hZkXqEbtUb358c?= =?utf-8?q?tkTFRI90bk1cZL5NcaWujLh/kZN5M44afXSRn1Xb/30sWy+AoprqnrepYkZgev3xO?= =?utf-8?q?QnUGmqE/k0hVG1vbNPof8fv7UQ4+92/yOStZw3j4YwQXdIV6Mgtzc8RvdTYPuGRig?= =?utf-8?q?mK8+dcQguZGt5Kft+F2Bjem62Zgf9zjcs5QXR15ocfUDi6aWh5mTuRgQWVbB5tDlY?= =?utf-8?q?exK4Dii+SqRly4WFFasD1wp+kM0ZIWd9/8s8dpUWLwaG7l2z14xJ7sWqcomJv+AO9?= =?utf-8?q?T0bf4nYmqLyQVqMCpFpq6EIrAo6VOWZ6TCoNRH5oMa1W65X58CTGUHi08KZ1BekRq?= =?utf-8?q?wo4U0qfdflIOM191Aeje2uSzUJIXrb90liTqKvMJA+Y5KHzPWKFdW+OuOI/pvx1Z+?= =?utf-8?q?UGw7X/or+yVEl5vINb8gGYzsvyb1DepmFgDbjaYoGrGv5QkZy1G9J6HlYefXMhFPi?= =?utf-8?q?5cgT/QsWVGK7kKWLSLddbb9rZv5qDLPOVv33LQIBUesoOzWj6mdkJLKdkFeQFl1zx?= =?utf-8?q?3xPOfUMPastvexDBJDEJeNmBZcP2wH5zTyhD0DUu/GZ7dJr6xcDBQPf2uqDcEwo4A?= =?utf-8?q?YYYlFHFDsj8dfzjjhYRbicPltkmneiJ+NBSDTrhMvoqhtaG3XigTLLcQaFBIgPZ96?= =?utf-8?q?m0GCqY7yWHmdfYjHVDZQSZuRhuxwlzTbBwBXj32XO3T75SMxwk7BcV3FtoK5eTfi3?= =?utf-8?q?+DDa0l+d/V2g?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 14565aa8-5af1-4eda-0f3b-08dc69dd5c53 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 May 2024 12:51:03.8718 (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: nw4pC/jn3hWGaBhQpXBQx9748jz/R/WAXvIar8/EH1DUCFNqD6AUSWNmbXQlCObeEqGpzymgQdNsgseCwyj+Ng== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR04MB7448 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240501_055108_354612_EEEECC13 X-CRM114-Status: GOOD ( 14.05 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Peng Fan Use scope based of_node_put() cleanup to simplify code. Signed-off-by: Peng Fan --- drivers/pinctrl/pinctrl-st.c | 40 ++++++++++++---------------------------- 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c index 5d9abd6547d0..2d77160f3654 100644 --- a/drivers/pinctrl/pinctrl-st.c +++ b/drivers/pinctrl/pinctrl-st.c @@ -812,7 +812,7 @@ static int st_pctl_dt_node_to_map(struct pinctrl_dev *pctldev, const struct st_pctl_group *grp; struct device *dev = info->dev; struct pinctrl_map *new_map; - struct device_node *parent; + struct device_node *parent __free(device_node) = NULL; int map_num, i; grp = st_pctl_find_group_by_name(info, np->name); @@ -837,7 +837,6 @@ static int st_pctl_dt_node_to_map(struct pinctrl_dev *pctldev, new_map[0].type = PIN_MAP_TYPE_MUX_GROUP; new_map[0].data.mux.function = parent->name; new_map[0].data.mux.group = np->name; - of_node_put(parent); /* create config map per pin */ new_map++; @@ -1161,7 +1160,7 @@ static void st_parse_syscfgs(struct st_pinctrl *info, int bank, static int st_pctl_dt_calculate_pin(struct st_pinctrl *info, phandle bank, unsigned int offset) { - struct device_node *np; + struct device_node *np __free(device_node) = NULL; struct gpio_chip *chip; int retval = -EINVAL; int i; @@ -1179,7 +1178,6 @@ static int st_pctl_dt_calculate_pin(struct st_pinctrl *info, } } - of_node_put(np); return retval; } @@ -1195,10 +1193,10 @@ static int st_pctl_dt_parse_groups(struct device_node *np, struct property *pp; struct device *dev = info->dev; struct st_pinconf *conf; - struct device_node *pins; + struct device_node *pins __free(device_node) = NULL; phandle bank; unsigned int offset; - int i = 0, npins = 0, nr_props, ret = 0; + int i = 0, npins = 0, nr_props; pins = of_get_child_by_name(np, "st,pins"); if (!pins) @@ -1213,8 +1211,7 @@ static int st_pctl_dt_parse_groups(struct device_node *np, npins++; } else { pr_warn("Invalid st,pins in %pOFn node\n", np); - ret = -EINVAL; - goto out_put_node; + return -EINVAL; } } @@ -1224,8 +1221,7 @@ static int st_pctl_dt_parse_groups(struct device_node *np, grp->pin_conf = devm_kcalloc(dev, npins, sizeof(*grp->pin_conf), GFP_KERNEL); if (!grp->pins || !grp->pin_conf) { - ret = -ENOMEM; - goto out_put_node; + return -ENOMEM; } /* */ @@ -1260,17 +1256,13 @@ static int st_pctl_dt_parse_groups(struct device_node *np, i++; } -out_put_node: - of_node_put(pins); - - return ret; + return 0; } static int st_pctl_parse_functions(struct device_node *np, struct st_pinctrl *info, u32 index, int *grp_index) { struct device *dev = info->dev; - struct device_node *child; struct st_pmx_func *func; struct st_pctl_group *grp; int ret, i; @@ -1285,15 +1277,13 @@ static int st_pctl_parse_functions(struct device_node *np, return -ENOMEM; i = 0; - 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]; *grp_index += 1; ret = st_pctl_dt_parse_groups(child, grp, info, i++); - if (ret) { - of_node_put(child); + if (ret) return ret; - } } dev_info(dev, "Function[%d\t name:%s,\tgroups:%d]\n", index, func->name, func->ngroups); @@ -1601,7 +1591,6 @@ static int st_pctl_probe_dt(struct platform_device *pdev, int i = 0, j = 0, k = 0, bank; struct pinctrl_pin_desc *pdesc; struct device_node *np = dev->of_node; - struct device_node *child; int grp_index = 0; int irq = 0; @@ -1646,25 +1635,21 @@ static int st_pctl_probe_dt(struct platform_device *pdev, pctl_desc->pins = pdesc; bank = 0; - for_each_child_of_node(np, child) { + for_each_child_of_node_scoped(np, child) { if (of_property_read_bool(child, "gpio-controller")) { const char *bank_name = NULL; char **pin_names; ret = st_gpiolib_register_bank(info, bank, child); - if (ret) { - of_node_put(child); + if (ret) return ret; - } k = info->banks[bank].range.pin_base; bank_name = info->banks[bank].range.name; pin_names = devm_kasprintf_strarray(dev, bank_name, ST_GPIO_PINS_PER_BANK); - if (IS_ERR(pin_names)) { - of_node_put(child); + if (IS_ERR(pin_names)) return PTR_ERR(pin_names); - } for (j = 0; j < ST_GPIO_PINS_PER_BANK; j++, k++) { pdesc->number = k; @@ -1678,7 +1663,6 @@ static int st_pctl_probe_dt(struct platform_device *pdev, i++, &grp_index); if (ret) { dev_err(dev, "No functions found.\n"); - of_node_put(child); return ret; } }