From patchwork Wed May 1 12:56:07 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: 13650752 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 D435AC4345F for ; Wed, 1 May 2024 13:05:47 +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=Lcu8A/q2mgCC2AiI3LUaxRgLBiU+uH4+S/TWobApnsI=; b=GlsLMoupecGQaBXWRgI+xhyM47 HNadQAT5prddjlAO1sxKcqJ6rNSNW5wiJ7L6fwq4dbLsHH4Uc59lgG/wsCg8dowtCraEABgq5NLxN x7i4dW2tt83K/CXL8DLJ0nRXf4ptRPlrSOgw3dhZO6N3yzllnALb91CwO8EKeTupUqtIDkcaBd/z6 ZA4A0LN2KjMfafQ5cGlC+yK7fSIp+FzC2oSL37A/egihCqfLUXPrTje6/FwObdzepj6xF1rTwogOb y4QlB4S/1z3sMxZYkr69nbgmF1SYPE/5eUiPMLl17pagOFW0UAEOy8I5AfeV/6n8c6LRcfpiyNmG1 bYBFfrhQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s29eY-00000009dFb-2XV9; Wed, 01 May 2024 13:05:42 +0000 Received: from mail-db8eur05on2062a.outbound.protection.outlook.com ([2a01:111:f400:7e1a::62a] helo=EUR05-DB8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s29eT-00000009dDQ-2JRH; Wed, 01 May 2024 13:05:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kTfCKx4cSQWZztbmuoS3CDkZmsJd6pJkp9KUN42/IRrqekpRuEXUNjnuQNtUp2A5TtNrvsAEBC7F9wLwEnlo4V1c+iATn53OlCqDXyac6NiL0+OZo+2OCpH4QG6KuGEJF/tW3GO4hw6ZbBiQQ7YALdztrJRXxlPkzKtzObPrfvFVe9cBTrXtOREZPYYvT+Y/iZQqKpD7cmWWbXmP4hmDX6p1MEjj7QfOuNylW65FZlIPW8LqaSf/4NBOoLjEqXF6BpxRBpKci3N5nAkFJQ6v99pHPyDAWs+gXAHaP0FpbJQ5K2HE+wvPNDPdw1/4KwykdX7FMgaUmd2PCSzVJfJoWQ== 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=UwLf//ulDgKGYdIslgc2mcconcEqLiM/aJbLmOr9R5c=; b=Wp35yQ9T0zgqXbj+1O2zlHGwK4gljsITTMatgAA2xUBsbtz+mrnjjEYSNNss2Xg5zqhNGwgNSzvO98hqNBS2fsBinW7iwij0QJSTasQLhUQ8rfdyE9bXDQYHrXbIve5Gk/CVJjIn8asNGXDK44/ZALhOdvH58x/k4HDlIU27/DiPMS/z1jx9+I2wQg1ukMRDhxKQTKrElgeXSKC00oa4QT5iB8YBI4Kye3m7ndqcp5tk0muDdcQzK1kyPs/rti+zsDy+OF6I5iIYLvjLH2+gydkgeoGaVkVz7L7iXyAFzc3n/7Z2lSei8L6UQvs4xXji/IbxWrVNFEEat9a9qU+V4Q== 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=UwLf//ulDgKGYdIslgc2mcconcEqLiM/aJbLmOr9R5c=; b=T4AuxXJzaFZv9OPj5JPUvQkK1dBLoFzSWv5wa78VfgVX7bUbOvxHJbvKWG0QKFPl7cF/h8jw4R282M03y8T+kVe4YKc1kJHwYJwpzwTd/yVkyQabrBfZrSYCrJmpMMk6m7u8RxXsDTibdxM8wus818FvydAO0l1G57bIb8YA4iQ= 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:50:47 +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:50:47 +0000 From: "Peng Fan (OSS)" Date: Wed, 01 May 2024 20:56:07 +0800 Subject: [PATCH 09/21] pinctrl: renesas: Use scope based of_node_put() cleanups Message-Id: <20240501-pinctrl-cleanup-v1-9-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=7968; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=K64zqrCbOC3rYAPmpNXeqloBPZKzMWC8Ln5phskDCDI=; b=SVSZB2OptEjixUVsBxQFlBLMyaX5ozL4HG2RhrVwKgQLHU+s64uygotTA6azDA6z8npJ4Ulj2 IlTLsI741+qBoolYUGSxm6k4Tb0gI94BPqScicGbaZ2GKveAWUAEHGf 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: 7332603a-25bf-4c13-196f-08dc69dd52b7 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?kbL/jGMQ5emKVei49fruJKYt9PKq/9c?= =?utf-8?q?R+hE/TxAwl/ShC5r/5oiasr9ptqMLr/adSIxA7nUpAkTcViSq2V0FyiiAZfYQNndE?= =?utf-8?q?WaVFORU6/OrKrMCeJjsLEgxuy8My3NCx7lZpq1NO+pwIqyvk5lrwMWlPiL7Na4Zyp?= =?utf-8?q?ZIrCS8Nazzxnz0pV9D30f3TXbNi5nk//pD0w+WVYl3CSJC4/shfoDFn9nt+4akX6Q?= =?utf-8?q?smQMG8fBZzL8bqc50HvyIY+u+1MdwKhqcCfU7Mjt2NfX4ibY+EJxXUHmnefrn2YaE?= =?utf-8?q?aYoskmfiRdPjdMOxSJv+Exyn2gfDcC/OBAutX9Q54UdJjPwcnZw6OlnDxtTvR4Yau?= =?utf-8?q?qllSD51sGuyfhKlLXvl3IoTSdykcKEyWkGfZzbZTT8C5De9YIf5xPRvLeeJOzws03?= =?utf-8?q?hL+5h9iMejIws1v9FG/ZmEVrcb4pZwM+LMUUiv7HNyUaujzQejbZzHX1pdNFTw5xs?= =?utf-8?q?sMFiFpTYpU9wYAYdQac+emviVXZ/hFt+hgZNGBMmRnnGwHOFKBO8i6fm6lq6OS80l?= =?utf-8?q?BVsuhRs5rnTOYKQBAoAUbwanFipJT1SYaIuuFUS4+9a5UswC6V289FXTGXrVomEp2?= =?utf-8?q?3hdn8w/90mSiHn5LgMC3zVBWi5Fz6bAq+cigZpETauftpxN/zEvdLftEOq0gKlLmJ?= =?utf-8?q?Z9FeglYLo+egPayV0YfjrDyEHR/KO/L8mSOfu1y7GB38KCnxbhyq/0Lz3ilG7xNKm?= =?utf-8?q?YYQWF1H75emOi4h75T3bEEnTbsMgO5F/2/waU3sdw4MYDnLSwBxxow0oXcXean+u0?= =?utf-8?q?f+p30CNLb3jYwtSBg3Oiyl4aed1eWRcCWfjVDYObtiDd/Ms/kfsl6hvYhxRzTtnwC?= =?utf-8?q?b+Jk6HVn/altxzJxKPdIHQQpkRMtNh8GzoxNV9dc6PC10+s9XxHZZlM29EQWGKAe/?= =?utf-8?q?6q2sudaNZ6apwhroGr7eX3mGwF12cT8hF+E63wihQaY7yRQE85AQ+j/XW6T4Ag8jd?= =?utf-8?q?NLL2b//SRpOo9JB2yvdEF1x3PUppDzyrTgfcmQpDfXBX20XCIJqjeVXZs3BGb3dIe?= =?utf-8?q?85y/yhLksrmXgg3WQt3mLb25ZqqLYWcHao1KCX2DTUD6NsaQcKIIOp1yhL1m8YIXZ?= =?utf-8?q?HloHFDc0C0UjE5sl/545I89PXn6FWrikUNqEiQmAvDbit6kzNdqvav5fiLJnU3YKR?= =?utf-8?q?RWXXTTjUDMtReXONGQcDJafyvyLx1JHNVHBiuyThfdwjFL6gQmky919J6wazu0lPQ?= =?utf-8?q?czQOwvtS9rKw77UKNAu5cvOzjH3EclKmpi6OlR93ewrpR2xxMzAI8Hq4FhRDaCmNa?= =?utf-8?q?lbBo5xfixfazqTPB47L4WQx7qq/stSGHV448X+2zE3JH3vvEEfPrz2YA=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?95jtY4aHlWwF+WAUE9SFYFt+OpL0?= =?utf-8?q?RW12qkPIyxNdw+mWfY7RPuB98OxW6Ikc1SdsKfwEvtmBzM+JoGVCVctfpLwhg8pa7?= =?utf-8?q?VOFjcXleoromEXRY0ey61Qy80gqVyhlbxAVpgeoWqoKXO0KmTKNdIlR5LkcOnDT8R?= =?utf-8?q?+SJ1SM+934gNOjfS7ooHhw/4w99K2l1NxSKOl/TNJqt1gbxIus8RAgSPe0wDakEh/?= =?utf-8?q?koWBSvfu4qeCqr3DaZKo5gD4XhHlqX9fxbCfjrqo/sA3mE4ngaz80XDLI83e51sy2?= =?utf-8?q?+NAMm5kpq2ru0DCsoQeg/xRzOJyiOIHN0hHZlzT4BjOHaMiIZ9G7SkVNaWuNCvm9B?= =?utf-8?q?8JsaU7tm4ysyR9YIksAbofl8j3vcHKA5pfP6AVgfQT1ZKPb1SijW2tHyqRBNQR4ro?= =?utf-8?q?emaI97QVMpkpHO1rIIKMx1QXTXG0VQuQ0ToFuvOL3hJo4r418j3D+qUdgf7xKqwRX?= =?utf-8?q?Azi7X8KZf+5k03r4DNXo8tULT3fOdSsB/GqqBuZP82ZLY7pdiUUUr7yobJv8Qj1pc?= =?utf-8?q?VLir2GJbk4nAcfMbSY24yrz71kAYq1ZmTbsI4yzoaES5FnqdNh4BdJIsbcX5lqcYe?= =?utf-8?q?HQItS5y3BNv17phs4NR85ht7SMHbniU9eUGgLRnDZQzJ8touVx0WiBPWjdEUfoi+W?= =?utf-8?q?8CTCadPiV5aDwRKzl0KcCAYrxLwGDB4hb5b0o92k8TfQPVCWevuNc/0kAMvL81kZ5?= =?utf-8?q?SxY+YUVs7PBow46GfqW0DSOVFzHvnv//QBeNZ46d9p3TM+HxIn2BiJ/cAC7k1QxjO?= =?utf-8?q?HM+iido3c3JGMAmXob0bCKaqxhVCf+XuMfrloSCz+vzqcrKH+4vcqY0cLQ7LY2LE1?= =?utf-8?q?UEznrMoz4fboj4K+OMb1atXEXIn7AsYC7cOIKZ/gGq92fZ5navBo0L9lHox135crx?= =?utf-8?q?AmYdOxf9ESr5KFEVuJgAlwOWZUpHz6+QC5P57x888KMIlfdE7AC4O8M2eqoT742Ls?= =?utf-8?q?GBt/SwLX6en3fvXEu4Ar37N0ihLFVHieggT5oU2Ri3bM/m2ewDL0jfKdsg/4YdMZX?= =?utf-8?q?/vDMYNDV8j3ET4aWG0aj3sV/tBalZ70fPP4cOoBdWF97lhqf+0Wfy7wBAE2UjZO+C?= =?utf-8?q?eYuVI1M7T8DXIJwnHjUtTymogtxfZA5GGpb7+5pHIzXFdA8BR1ui7agY06SEych2i?= =?utf-8?q?daq9A4DE1W/6LNw4UdyDXYLiR2SaC4SacuHpnznRt8BNR3DweEUVIDh7PGnv4vZjh?= =?utf-8?q?gzJp8k2HLJkC2S4ElSwEuHL96dS0wUeFSIHT8Ua3K3CnQeEG89HHLmB+KA4aIn2Qg?= =?utf-8?q?l0fpOTBqeb6GYjhuwyA0KcwJHAGr5eH/4/EB/7kgSjTqDrTRJLi8coUj9e/TYSruV?= =?utf-8?q?QD+Sw0iSP9yxeIuGTrFEfo1aNkH97WWcNWgQq7rsqFpY0QaZEzV8Hkm3oADlyoCdk?= =?utf-8?q?iNDcbdB0hX9x2jeu+4Lricl1iMPPf+gIWIesFMbCY/D8KDAbWNTw4aIyDt+UN5i0p?= =?utf-8?q?gB+ansZN4iITFIMN32/Nhm+oo2p9XP35NTPlrLIvTDlR0NJAYz6q0wt6dzZkR4JSq?= =?utf-8?q?p7z9lZUvCznw?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7332603a-25bf-4c13-196f-08dc69dd52b7 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:50:47.7704 (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: jgoF+yszrnD5AaOJsghO43g3qH8yKF0h0gMRpzeHEQQMg+zIOBVBqRnq7ye3+fpjloNfUHkXq1ug+XUNsY376w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR04MB7448 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240501_060537_767787_3908C615 X-CRM114-Status: GOOD ( 13.90 ) 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/renesas/pinctrl-rza1.c | 14 ++++---------- drivers/pinctrl/renesas/pinctrl-rzg2l.c | 10 +++------- drivers/pinctrl/renesas/pinctrl-rzn1.c | 23 +++++++---------------- drivers/pinctrl/renesas/pinctrl-rzv2m.c | 7 ++----- drivers/pinctrl/renesas/pinctrl.c | 7 ++----- 5 files changed, 18 insertions(+), 43 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..85a4f3c7d73c 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) { @@ -2201,7 +2198,7 @@ static int rzg2l_gpio_register(struct rzg2l_pinctrl *pctrl) const char *name = dev_name(pctrl->dev); struct irq_domain *parent_domain; struct of_phandle_args of_args; - struct device_node *parent_np; + struct device_node *parent_np __free(device_node) = of_irq_find_parent(np); struct gpio_irq_chip *girq; int ret; @@ -2210,7 +2207,6 @@ static int rzg2l_gpio_register(struct rzg2l_pinctrl *pctrl) return -ENXIO; parent_domain = irq_find_host(parent_np); - of_node_put(parent_np); if (!parent_domain) return -EPROBE_DEFER; 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. */