From patchwork Thu Jun 27 13:17:20 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: 13714398 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 88E84C3064D for ; Thu, 27 Jun 2024 13:09:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-Type: Content-Transfer-Encoding:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=rXSa9726LU2iufWruhMP/0XPEMaP5HzAdhAb8N1XeGc=; b=eEn/bBcu3vM4yZGFrK6Orf1uO1 pxH3+MTbU33G3kVsEB8tVHItIPUMgZSa8tYNFcB+5bLbDUGTuMnG/jtb+gqT05xuTi6K1OwBcx2CV zIUNU0rw8MyGJ38uIak99YY9yUHxuuBbl/aCREe13pZfYScyGM6N0bUPbDIcgant0IXWy6fhpU+vR cjveeJwdktFh0+FajnZaZ53dO4+muNmlsAzycRyHgrRlyZjiVo+pwzNzZjt+idF1D2QZONhE75NWD UlLSImTmgYag6+lPDg2PGuU/K0IHA8DwWwLkdcd+WPOj+WgOMJJF51mJUT3O22cePOqi04f+pUNxK empw5kDA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMosW-0000000AQAe-2tml; Thu, 27 Jun 2024 13:09:32 +0000 Received: from mail-vi1eur05on20601.outbound.protection.outlook.com ([2a01:111:f403:2613::601] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMorl-0000000APyW-3OF4 for linux-arm-kernel@lists.infradead.org; Thu, 27 Jun 2024 13:08:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D3gwatTWrQacJ7ePPMrm4nKgeMUQCR+69Ix/XQGYzuVLSEFHHI+YTkXgdE+VWwWxKWa2wMmTvVQN8osmVonh11jVZCFpsfycyMD8HOLKSpJnos3mdbfhMmuJXZFFap4TRHfAV+R0QyHj979TtsusCcxGAy4cE9/Jrw5AatjP2T5J6GqjJthZPMoLRZtkdX46NcdCQ9l468v5Xco796e2Q5rmYog9fpdxo5BEys0IqPQ+pNYFbIzZMsgD2d5LRazJ4KC75/2nsQMkpLc6QZv/sWhqFVhUAsgWSoLtQTVF0vebgoPeGghJu5WXAGfG9Fn30jRYVd/OSW1gBGvXcZq6hw== 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=rXSa9726LU2iufWruhMP/0XPEMaP5HzAdhAb8N1XeGc=; b=k3ZdZdB3JZievtsF7LamWHE8EOLNO8oYyAP5fcDeyGpTRhnZLlLEqxJz8B3zOlOe+6Ei2TYs3kmMyPTuKyrAScs8ufgN002dNPBWzLOQhune6BVXs6dc1/sLTL8B5Z6NWNLd79gpovN5GGb7Zyd6j14uf0ph6N2z4Hv7iPfA7tc6zZqGHdNTUIGkatAU1wJ1HFmo92mHsfNS8zzqbRWptHarDPaVrEMQVIr89JH4jYkQchz3MleQOyuSnKfD9t8EoQzCLGVxwYHE8K6Vjcx3ubFMnbkmjeHHbfAzNg8BysQw7Na+osRDm9YdbAQAtjBcTOsrSuJSbgcA+5QFA5/jAg== 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=rXSa9726LU2iufWruhMP/0XPEMaP5HzAdhAb8N1XeGc=; b=JOtETm4yN7SBTkW+z46E7yL2DzLBipMIYk9FSAcMF4Ma4s2QRm4Sh4/AEeRf36w7tNAAOO6g+gi8HP77wmcpBVswfWUsr1FcCzBvM5Wq8UlbWS9zA9Tj2Pn0u56Mlr1Z87Xm650E9A0uhBE4GomFF96uZECMMditKgt5e4g/S8Q= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AM6PR04MB5941.eurprd04.prod.outlook.com (2603:10a6:20b:9e::16) by PA4PR04MB7549.eurprd04.prod.outlook.com (2603:10a6:102:e0::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.35; Thu, 27 Jun 2024 13:08:35 +0000 Received: from AM6PR04MB5941.eurprd04.prod.outlook.com ([fe80::9f4e:b695:f5f0:5256]) by AM6PR04MB5941.eurprd04.prod.outlook.com ([fe80::9f4e:b695:f5f0:5256%4]) with mapi id 15.20.7698.025; Thu, 27 Jun 2024 13:08:35 +0000 From: "Peng Fan (OSS)" To: linus.walleij@linaro.org Cc: dan.carpenter@linaro.org, linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, aisheng.dong@nxp.com, festevam@gmail.com, shawnguo@kernel.org, kernel@pengutronix.de, u.kleine-koenig@pengutronix.de, Peng Fan Subject: [PATCH V3 2/3] pinctrl: equilibrium: Use scope based of_node_put() cleanups Date: Thu, 27 Jun 2024 21:17:20 +0800 Message-Id: <20240627131721.678727-3-peng.fan@oss.nxp.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20240627131721.678727-1-peng.fan@oss.nxp.com> References: <20240627131721.678727-1-peng.fan@oss.nxp.com> X-ClientProxiedBy: SI2PR01CA0050.apcprd01.prod.exchangelabs.com (2603:1096:4:193::21) To AM6PR04MB5941.eurprd04.prod.outlook.com (2603:10a6:20b:9e::16) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB5941:EE_|PA4PR04MB7549:EE_ X-MS-Office365-Filtering-Correlation-Id: 4c0b3c4e-ba80-45c1-28c3-08dc96aa4083 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|52116014|366016|38350700014; X-Microsoft-Antispam-Message-Info: XCGU89Z34IW0aHUOxaUC3jKtedROroR57fUwNimbzmgcCJqBS+JODsD05gorDH1q8Ecs06rgkoqhEY5XQnghq3rn3IkIOzRA187LeABQqUIGUunuzbLrQGhDysEYcS5yUNOKiClf0cw/6MtMqQ7zdI+nFF3lkb6yBohwONYD65VUj4Q49XS55kDP7/cmHbtzhRCS4Q/AZ+iEZuu1q+bQvrl+nRM8JzfsY8qtRu6PXaUR0Ha4lZM0nQR9GhxKZXXv6ZCC6Y4sPHBrikdxaH8WL1wHTcdmWZiGaRhYtNFR17+WfovanwG7mH5y4kn9pn6irLK1O/DQejEGuS0BF6y7zWtFsmyJxENupDFBATo9Brh+eUsXC0n861s04wv9/u6L/czekEL1fmUFZvqA1IEO8dmjAuXxYhq7YD2ryIO/Im8APC+HUeXZqTa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04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(52116014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LLSuCaQcBAKW084JQKjzWW/bmwVjdmdqhcopmiNBwFUzN3kVpBAA9sISdEaKLm2nBLX+/DyEJqQkApJuWdBFfj2gbWxCyYqVlaC4cjq2hPBBqJpj3AnIL/QPA47bsXXQb6OowSvwfvcajxKiJThjV/OJpXNVleSTxUlNYawwi44s6k4UjTVvZOkTB9iLlFW+Q2dQ/DbBEpX+9Qz7/AgNcZZ40iX+d6ahAFMW9qzSRU6XtuyZuIQazSkMFuOmuE0W/Ybm+EUsecWt5h0xIdJ3g6CXVf0lczB0+wjaGUp5St4i4HM/57V8XKC16sJgV2yvXqWMaFMdtESocfGnqVig4AQIjvrU6QfkzqzRSbDFAYp+N6pDF2fUHvkpd8Q/rvKioHN+ndpMhhbEf5P8sFggKfFktG2GYC/K8Cp+sgow4NrxVQwfP7X6gLkEBQoAZDfd2NbbLO7NBZrH4rJZq9hb5i+UIRViRntH5uRCaO+UGXynMjGHjkrYS2l47MaWaRJ1vQSkYr1w0PVMoyfd/Cs8n3HoYRPNyleMBFwGeYF31IClZ0SQBKrLn4/1m+NtMUZJteAdXESFYauh7rsZMZSXkcBJjeBZaQHps10bMmw7FGo3/yBTnQ4g6p6RaSe2PXSof5F/0LYk9rAMexIQbQWUC6+rB2MzRk7wMNfHbcil5BoBDFhRUTx0g6Moq9daGBHPeWo3siEA+DquxsUl7HAYA44/hSxMEV72tEvh3+uUFV3K1/x02nlQ6GxONz752OOE+J24M+8c7mPbvkBkLVcDm5cY1eL/PvZho4OWiwHTZxeXnxOtd1J4Lu/CGwY9qFG4eeGGP4tJVRccET6/0wzjlVE/+agH5BWuxntEpZtsfDfzFKlsiIpHnVHwIqdsJ25WCdbFDqLWyNFmBXzOlZfloXDwVeNq5VRwy//5wSvj+MrKvZAwehjgvGHXu0GrDjTJgnF49hAkpk/sdrM9H3Wcgf3/1BFaXtQOcVC8HkwEDALCBDkisLZq0SM+8M4qVash32AVblRL4bsTiXlrIIf5mkR7X/Vb+tz1VrwHD+FOZYa+IqBAdr9HOlMaipsU7JuiHZ02qcdGKetIdo8S9Lo+ezF34n2yuwsi3ChTU9L7NLBL/dzDzuX/0AndfoduhLEickjdv1iYFXkpIHGxFtcg/h4t1IPFOnrRXpaonLNkdqcTC2yUgT0vXlAfBkpUBL4MItNTBNAGjAeKw2PFtg0YcUyKR15SF1xtYwUJOJWQWV+7Pp9iWG8AR9OsViOse6TGjvdjw83dFHv2BgARE3ZRso5Zwv+Aw0RuscV91z1bFXEIg2HnqS7dMIdw/LtunFkCf6ejDxvBJIROfzis5VL8yhewydmhOedoPx3qCe7cD13S22YtKe4ej7PGgGAzpLYwrjUyLUZtTvuDTbYBaAqmySl6pJzyDft259GvEA25pnEW+yFih/XoJo7RgWo9FY9syuFeHPHb9ywqyz+yjtHibo2k+ucG2TWZacCrVMqgfBss1w3S90WEyZvaVEmO8pKqf9GHFpN/B5z2GtWShEkq2Isu3NkgfK0biuqKbnZ3rkB4xfjt3WYzhbq1wmXxy836 X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4c0b3c4e-ba80-45c1-28c3-08dc96aa4083 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB5941.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jun 2024 13:08:35.2484 (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: z9RNPTLo/U2Z+T2sk0unfJKLZ1Ykwc43K0WwVJCXdfVNlSwKG9s7Bei1aZTLHULke2L8mYGnkl7WPfR3yqIkLw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7549 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240627_060845_991102_915309EC X-CRM114-Status: GOOD ( 11.44 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Peng Fan Use scope based of_node_put() cleanup to simplify code. Signed-off-by: Peng Fan Reviewed-by: Jonathan Cameron --- 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 a6d089eaaae5..3a9a0f059090 100644 --- a/drivers/pinctrl/pinctrl-equilibrium.c +++ b/drivers/pinctrl/pinctrl-equilibrium.c @@ -588,7 +588,6 @@ static int funcs_utils(struct device *dev, struct pinfunction *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; const char **groups; @@ -596,7 +595,7 @@ static int funcs_utils(struct device *dev, struct pinfunction *funcs, 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; @@ -635,7 +634,6 @@ static int funcs_utils(struct device *dev, struct pinfunction *funcs, break; default: - of_node_put(np); return -EINVAL; } i++; @@ -708,11 +706,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; @@ -720,42 +717,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; @@ -766,7 +756,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));