From patchwork Wed May 1 12:56:11 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: 13650658 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on2052.outbound.protection.outlook.com [40.107.13.52]) (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 E38588627A; Wed, 1 May 2024 12:51:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.13.52 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714567917; cv=fail; b=Jqixu+weRrWhcJkMI9XUCUcCN2ivZsl0H6+sorFNKu017XzebCxoC4p3X0RPM2xDzR7IUA3L431d+BI1FkyXoEyXDUwrudtr4mOO3Vr0nwyJKVghE/D/6FEtr9BlhrKLud2gcR0a8/3vpa4YRYRUsuV0ayKprBuadrNlW4NwECw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714567917; c=relaxed/simple; bh=E6ik9M6/qhOWxdXMSi5wfgwa6MozB3Zte/4KB5unPbM=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=gSN+PmW6aBIAQdLNdsODjLA8MfCHZ8IPGMqOsPB/LOInznJ6F7LblkZbI3vFMr94EeOAZ+tnKpxSlcMc/U8bMNLZP/d/6ShhH2cu9Cpb3guLR8VX+TWszmjtRKmtcA9lubPhDG7fPnwPp/l94CEzYhqF0svYqkIe4d2iA8Soxps= 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=MdQSrfNQ; arc=fail smtp.client-ip=40.107.13.52 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="MdQSrfNQ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Jw5DDCtv7NZU3tK78HqPTOg3osCjCcgpGtQyoc5BjkZuBtztM1Vpw/WJu5QEDY4OXrEcsf/m3quDk9+9KtpW0iR+klqQB+7vHUVX4Ih5tbS4gRBARYFjEbFqr3c+5aA2x2Vz1V5alZcatqFLjaD7K6B6H06z0MfkKLaK3XPlDElMxkQmGDNiidtqkbuLOipr0ImlsdnEjPg4qYkqoCk1TPTqdkig7Vdh2f2sd1rg9U0f4Q2J9A0Fct8BqGaoMhF1rqFq6q+g6DD3zFStJM6nPylspzMgANwgU6iAP7hKlS6tOkp9MxsZChlcEA/O5T01+PjGpfZ1y7mQY7QsAmwh/g== 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=RKzscdFMbKHIkbo5TBU/zyPoN0zmGs6d6fVNhcTfxjo=; b=Lfgfo1eRxEbatyER+bmKgMu/dCsVHLw8K6gcs7ETBz471Kr51+W50R6pohvyBMwy0bKFG6g9Q+5/gFhpdoXoF/9nu+Q0Ta4JRA4Lss/kzqW2e8TXreaLEnIWduS+wAhcWl3U4133R9EaCVHLVmek0hbNphYvbyEvZ6aSJiTI6L9RWZoJKm+RnDVqjtmJ4kUVFFGsr+5NalFTfLs5JeFhz5yQkWxWatc6sHtYzpbaDQfYP5hs/F4dqNuqKofaZMXbhll8rJ4bvHMegPBHn7lgKKn2FHJfXya7xfoaW7yPDT6V5EvIgIEwAMnuFAmU+119+879wg67xXVEC/MNhSGtBA== 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=RKzscdFMbKHIkbo5TBU/zyPoN0zmGs6d6fVNhcTfxjo=; b=MdQSrfNQLjF5mR8tb1GBjL2yNGByTmi3tyWpA1AZM+gT978FSATk9tOjVPM4dFIVVff/z+XBLuf3GC55RgiPSApG/kLqbTj6iKeaf1N92FLF+iU6AJm4CeG1JR+dzJ+VlmWZ3zSIY7jdGM+o5zt3kkDomYegwJizAyqqhdf4Xy0= 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:52 +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:52 +0000 From: "Peng Fan (OSS)" Date: Wed, 01 May 2024 20:56:11 +0800 Subject: [PATCH 13/21] pinctrl: equilibrium: Use scope based of_node_put() cleanups Message-Id: <20240501-pinctrl-cleanup-v1-13-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=3196; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=HA5FdeU3k8hXGIzvGdYVmDetKxvVIH+CQmWTQZMAMaY=; b=lfIj3/spF8jGcz47ZvLuHp/k/UAG8bMzvdE82ONJ/bR1g1sJUKqcbZhnpbj2LhbltExEhtYGn fwAWX4c8JfCCz2+JBRdYekK/IHu0QInM17+/HxBCQRu/jEpaYiPq74r 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) Precedence: bulk X-Mailing-List: linux-samsung-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_|DBAPR04MB7448:EE_ X-MS-Office365-Filtering-Correlation-Id: 92041057-bc4b-46e9-af55-08dc69dd7975 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?ZgiSAayWdBXVSk14HD/kC7zRi/aFFuf?= =?utf-8?q?KnHNO35K2itukwo2uBNLYlyrY62QT9ZvftXKgWJOwakG7tO/KPKwl8XmY9oAei5xQ?= =?utf-8?q?vrBDPYj0bXTVtGpxKYSXGVR1T6GZfeRWsMbMCT0xPkLvFGvic3JiU6CixdWk7Pkli?= =?utf-8?q?V2UDqJq3m0Ld1HpY5VBeQAe0Sjs0aUOdNMraayxSOtDOSsHiX8vT+LW9eKR9BJMyO?= =?utf-8?q?iHf8EJ1SiJvCrAgY02DZ0RqmIj+C08YxynJax6fZfV32021pdU0v1cBicqXxyCY6c?= =?utf-8?q?i4TZKhwWT0zJlbnMKaCl3t6AXJ1riDVXOJUXWo8S+mRgLXPDTiZi6EdMCS+dR5G4B?= =?utf-8?q?hAGq1/MDbzihfZcD9eYAVUteyPAnpsVTAGH4oXFfJnttyCQkzRTyCZjxTs+PdPyEi?= =?utf-8?q?CaRrv6NXwCif+c3YLr5H3EcPg7IHxiHEwNjYpj22UpSR/XrPwfBFgSOZsXH2LdF8M?= =?utf-8?q?HNm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: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?XGclJIPnHASPu98kRGny/gY4sriZ?= =?utf-8?q?AMDorZ4cp94zSw2rt2IwpJKjJo7qVvfX6cBtN3wqtZoqvEWV4LD5jlPZPzgURn2b7?= =?utf-8?q?Cz7A+eZlQpGy9tWXipDvYUuKECS/Pgy8Ll46aw4ipb08dd0nnmHH9ntu8y8wFEHac?= =?utf-8?q?H6sFn1uySJFHbj00ufR4+XMr3SMz5A+bWNiTehkwZyoTVLlOdmPPxk4iv8yS3bUgj?= =?utf-8?q?fEyfou3+PYRd+dl0jsXwpf/XC+WfuMZ6TrVJnLI7pPl5aNkaYQ5m23F+47R/mhF7Y?= =?utf-8?q?M0zKCYNUjL8c/343W+/shcpfBrEWEb7d8dI6LawnZWZ/oOn42jtzG+IvasDTnvR/d?= =?utf-8?q?rM1fJ15eVPokIDIOD6FDEh2IRL5kJ72MtPHBOSTJzChNbDtLgzj38LTEEW8PwhmEX?= =?utf-8?q?TqJd8b9qX9DN16OU5oqXJbonjqM3kxghg4sR4ZZFX431wfJtoOHgT1tPLfeq40GR+?= =?utf-8?q?d77+8N8J1phzgoOMn3SD6dyCtj4YG8QpI5bVumt5XP+oDOq2IeceGv+0+KomlDzSM?= =?utf-8?q?FPvdH4hgkVIj7b6B9Zg+j4W4+cNbpHBcNjngaFAVjF7bW6/YwfM/XR9u8A4fvjgVV?= =?utf-8?q?OYqIjWN4nVo8OLQYODyE+cwxiMB5XHxHaFpIHwnbspashyKc2vBj2EhSfD6iMou88?= =?utf-8?q?xVPpGUD/n1NR48jliMyrUnr6QB+toTTJExAKPEMOKZAZ1LyYmS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rossTenant-Network-Message-Id: 92041057-bc4b-46e9-af55-08dc69dd7975 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:52.7250 (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: s+rfEts3EMc81tIw3DREulmqQte0GY3zYwWn916xq0atBwEVif9bJ2z+UIQZvnefYMON9VG8LKaqgf6P9Ep3yQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR04MB7448 From: Peng Fan Use scope based of_node_put() cleanup to simplify code. Signed-off-by: Peng Fan --- drivers/pinctrl/pinctrl-equilibrium.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/drivers/pinctrl/pinctrl-equilibrium.c b/drivers/pinctrl/pinctrl-equilibrium.c index 6e1be38865c3..e727257bb697 100644 --- a/drivers/pinctrl/pinctrl-equilibrium.c +++ b/drivers/pinctrl/pinctrl-equilibrium.c @@ -588,14 +588,13 @@ static int funcs_utils(struct device *dev, struct eqbr_pmx_func *funcs, unsigned int *nr_funcs, funcs_util_ops op) { struct device_node *node = dev->of_node; - struct device_node *np; struct property *prop; const char *fn_name; unsigned int fid; int i, j; i = 0; - for_each_child_of_node(node, np) { + for_each_child_of_node_scoped(node, np) { prop = of_find_property(np, "groups", NULL); if (!prop) continue; @@ -633,7 +632,6 @@ static int funcs_utils(struct device *dev, struct eqbr_pmx_func *funcs, break; default: - of_node_put(np); return -EINVAL; } i++; @@ -706,11 +704,10 @@ static int eqbr_build_groups(struct eqbr_pinctrl_drv_data *drvdata) struct device_node *node = dev->of_node; unsigned int *pins, *pinmux, pin_id, pinmux_id; struct pingroup group, *grp = &group; - struct device_node *np; struct property *prop; int j, err; - for_each_child_of_node(node, np) { + for_each_child_of_node_scoped(node, np) { prop = of_find_property(np, "groups", NULL); if (!prop) continue; @@ -718,42 +715,35 @@ static int eqbr_build_groups(struct eqbr_pinctrl_drv_data *drvdata) err = of_property_count_u32_elems(np, "pins"); if (err < 0) { dev_err(dev, "No pins in the group: %s\n", prop->name); - of_node_put(np); return err; } grp->npins = err; grp->name = prop->value; pins = devm_kcalloc(dev, grp->npins, sizeof(*pins), GFP_KERNEL); - if (!pins) { - of_node_put(np); + if (!pins) return -ENOMEM; - } + grp->pins = pins; pinmux = devm_kcalloc(dev, grp->npins, sizeof(*pinmux), GFP_KERNEL); - if (!pinmux) { - of_node_put(np); + if (!pinmux) return -ENOMEM; - } for (j = 0; j < grp->npins; j++) { if (of_property_read_u32_index(np, "pins", j, &pin_id)) { dev_err(dev, "Group %s: Read intel pins id failed\n", grp->name); - of_node_put(np); return -EINVAL; } if (pin_id >= drvdata->pctl_desc.npins) { dev_err(dev, "Group %s: Invalid pin ID, idx: %d, pin %u\n", grp->name, j, pin_id); - of_node_put(np); return -EINVAL; } pins[j] = pin_id; if (of_property_read_u32_index(np, "pinmux", j, &pinmux_id)) { dev_err(dev, "Group %s: Read intel pinmux id failed\n", grp->name); - of_node_put(np); return -EINVAL; } pinmux[j] = pinmux_id; @@ -764,7 +754,6 @@ static int eqbr_build_groups(struct eqbr_pinctrl_drv_data *drvdata) pinmux); if (err < 0) { dev_err(dev, "Failed to register group %s\n", grp->name); - of_node_put(np); return err; } memset(&group, 0, sizeof(group));