From patchwork Thu Jun 27 13:17:19 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: 808402 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2056.outbound.protection.outlook.com [40.107.21.56]) (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 5EC7818FC7E; Thu, 27 Jun 2024 13:08:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.56 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719493719; cv=fail; b=LoId+b320f8zfGBu3UNmkfuUBqb//AgHqZeMPGHbzoSynKY6OWbWV7CnKD3A0m3qg6j9kGVNZZJNZZcg3e2XGX1WFXUtjIje2aqxo8DpJrCn5IaZzdaVBfCWazJHCpKa3wUmZVWPzLQ+r8fFOmM0vBj7tNhgzj3iofa4FuNVYrU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719493719; c=relaxed/simple; bh=ucnk2lZEAD5gWnQd1rO5+ZsZzkIQwZgMlLuFm7vviys=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=GOq6kPDTmexhdgJaD0W4TNW290P24JvfDqKSauw5lZ8ypCBZAF+j7XJ8BOFiynTEbrs5cd2+hTB272fStW0wOYWFCiLg8R7SjirsEBtoylOx8T8lOPf1ylWo1La9OTo4Hcu6grrHELGTby2/Tw0BS9Atd52gjLftc5Z8//DR0Vw= 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=gc7udDbG; arc=fail smtp.client-ip=40.107.21.56 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="gc7udDbG" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KnlCr9ChYlI6kQUeaHoKn03fYNXeZ5oG6gsM+f2ZJtIi0U5SKzjJWjchyH6GsoJo1rmo41Z2Pb1H4uNq04tPGjnTS4RLH3c/h2pWY+0s4KID4RIAUwYf/TSY97/nJMkIP2LHruBuanhFlz+N7vMkbQr6zfJ8QOFzi08wchy+yDsK0Xynh0TJ8bXU5U8Ni7F2+muG0Ofh08eieSLADmiQ53RDZK15HDAxykDEEtOQJhx7NR2k2ViFWrQ1KFYevzeNuFB9rIiBZOYfMT18SEeRR1hNZ24TJ5tyb0pXf38tL8YT+9dTK7jTptDcmONwFgn6KPyFCAAnvhYAc7dz6DzoOw== 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=cEPjkbtopGPCqQGVhbKL63hX74x+Yp7vh2Xl01udzas=; b=IQdhUbfxcndDG86+Il3DjE4MPqvOKXHMioYPgU0naDG9d5bZQhnS2FXiV+MJvuMNVOzYYaiiKp9/+RMB14RcFzuJjykUyVx05ZS9GKoomkyROnq+Ih5ZZlKKOmRFhnY8yFbb0fWcEK1oypcrrwbheVmh9S6b8tYspk002X+HFOfAXnDChvJj1k4cpu1FpDb9lNty1a85/J1F7V/j8bi6SgGAvmSWFgLLuRI6FPXc4+kAKcWYJBhq4ncbELL/wgUr0zN1b13ps2+WO7mQ8RZmjCGcKS+SkfBGAmYmkvl9mXRNwqAue1JVoibfM8TrvNyM+byaQkgx14JEAq7D3PQdBQ== 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=cEPjkbtopGPCqQGVhbKL63hX74x+Yp7vh2Xl01udzas=; b=gc7udDbGhVucaJ+HkzEWnBzexEGdBweL4RBRJ0oM2MD8UGYAHoxTCbGQ9TEbNFc6oTNZRWxDHElUIJCwcGqV6J25z9QWKt6cz7kA8rEDS3l+tULhzxfCqtV+zKJ5vDlnK5DzHC/diD71B5GL+4LmgUuhL498JH8rhcjCaVNqRes= 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:33 +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:31 +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 1/3] pinctrl: ti: iodelay: Use scope based of_node_put() cleanups Date: Thu, 27 Jun 2024 21:17:19 +0800 Message-Id: <20240627131721.678727-2-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) Precedence: bulk X-Mailing-List: linux-gpio@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: AM6PR04MB5941:EE_|PA4PR04MB7549:EE_ X-MS-Office365-Filtering-Correlation-Id: 83d0d0ca-de72-4d2a-58db-08dc96aa3e0e 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: jnDrPcxcWOVkairHXrW/WUQj/4Hfm9NYOzmQzOXL3TLWqoBp0Nkn75AByagV8P6rJn9GukkV2BIgbJ2o15hWChnbgn2SyhcC44H7dhZ5TYMGcCohhNfpf9e4WX1ufeMenAa0Re8GUhu6I70AbFuAPYr/NLBYGKYmpPNq6Goh6QLnrTpa2YrHd8M+puKP95zlgxJl9Gwg9xPySIf0zsFnc5BilW/A7J+7OHL2EoDDyDt7XGGHhEiKVfqJoJqNqn4uE1Dbin2k3oU7XPhPQYDj7D2FzujDjGT+apyXLg0PYDrV5zClILeZsMfmxUxL62FMv7XAaiDRvmZbP8mHy0WxYlB2DO4lCYqeARji2QeXyY+dArEeMpz1j8v3ji9nZOIeuPspWqU1JsJu3gmnLOtVmD9368+5flL1F/Pl3ciRQ/djDfxasHJ/fhkzWv+XrE8LM+Xxpeihgj3yRuWfFVq3ANLrRlj/7nuefzbqYZSnvKXH2SvtsNF1534sBBpplFhdTtwbA+D1XqKq5his9ODMyBseW9SNAWj5NOucrzjotNBr7Ipcm4FqRP2m+O//q1w1lP9Iwt1E10rOT7IBtQuhhZRA0f3MOGUokimNM/wkTbixIOe9o1rjjoiNKA3792P5YAsaC+9Gm5hH+DF9pD298MP/mOyiBUATgXCTxnbgpUC+POeIwrDpcjoDSJmkTIAJpfPvSd+EyyFgLx3JXWRGFW2uZ3Hw9SydOtIJ8B12w5QcqCtB34i3XLiJyUNP3oztFsA8onYs28LYW4yXPSHc/bWPMHC6EkIdVF6F7KCUk2XhVTS8sjL5Rtyl0UuWylvMVdvmHTwh9G5vPGALz5fvqSG7N0uFhOpYnPWtbeVlaSlBoI6FMqQ6U2htWCAFQfvpxQOwqziXdkiq5lvXu13luh2MZbLy9odkEnGfEiBYA23foD1Ni1xDMQaK+da57DJ3IEUZo7itsHlIeh5drgiKimZ4/pCtoNKjhCKwrZ6SEzS6g0Wbjmms5U7x7vRXuU/YB2dsFW7RU9gSZ7crWz80545mPTw03OWqktVMX3kX3D/2TJxHHrW7KNIesIy1+NZTCkmN6MH1BkVScOnN5G5CT6neQaONbIxLU/AoxJ4me3XusHSNSe0+fkEztIw9fUgA/NjKaOqPjGrTyg2HDaR4gjEqZmChklXEAGOGiaOqv4NPEfVUz8mUq5mDCigVCMveX5ebOUdrZC0HdmHhWpIR5C3bWUQoMMPj0sERvJzS1PxXWxUE7bDS6umVqk4H/V+oIRSUD+FmGwttGD1GdduxrCXXPMsiiOW42x5ufEjK2hN+ESzyFPhhkg5hY+ic5zbqlzWZCz3AvAqMm8O+3SYgacan/kwuOttt69TYQgYsHgz0F+VxnulLvRdB3Zt5MZsZAjLoVWWVKFim8YItvNg66g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB5941.eurprd04.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: wMeS6pSoLvaU1Uon4luVGn7R3jkU9C0FPqE/nO/w+pCjnvuRT53UhTAqZFTwgx3bkMImSm0efyniXI9EYckSYBIVYQexKnpPewfyl1eUySeiwaYkkl/I8VYXcOXQIAgXIplfyDWOOlniAiWK1soxOIF//bBIzFpQrZU012YNwP+IjZ5cDt7mmTZnluLeA6/+mIjuv0j5Jn6WQ+cJVUObDjRJPqejL3D4Q3nwUMXUAeosZclG6ub79p/OYHK98LHd+3NSBeTJsXFz1YrXXeJgyXJIcHYxHGM0VaDt8ftqpt3HHicrmlvHErG4Bu3oHooGl070u9QcwOybyFBxDt2sVC1cF8xJnd80Qk630jigLG6yqbz8QWBvC5HJQTdxLoBWN2o4g/Nzr/RCB2I8IZKQm61jClltdViZmTafNWZ+Z6IDECKk8ZyOZ0sy0+dJKtOv0v4STk4EEGtm9du2vCGFpS/418dv/0D8pmhnXmtorqMtEhLqxYRaYBSXDCsNTtsPDs6PEgFbMiOiLhaaPsFO6dwIrUCfHpQk7iStnc1r0RLLTjUqEXtW0/FK3Z7xoY26kxkNg1UA4cksXnfckbRWPaiPlmpJVBEua3yLNvdJa0qEZ+i1WrruUnGrM20VPvXuRQoW+WsiYkhvQdqQ3/iSUIEEpCKViUZ1+tu8vhgzFa+umAVZL6ttjAPr4Jpg+jxB1ujhb/1t5ReKzMp+FOwyR/BCpNQscD8177E2Bcox8mxvGZ8XV1cbBZ4fkjF4nXMxUo4+VCrPYVO5kRzO6i7El9Q6B2LvXeK5QYp0rvXkPYcKAVaPLmqASq54wUUgfNr5sTL8yfC9pkpTQDkg4P1WyCNhJxxHHy9MxdupZ3OIuhjPSxHDv05lRSpfJvPNLHcdGuMSfP+aU+1KcvacIbe/EMj0lnsLkn2+97/Zbv/Q69QmdprVrpk499jiTpelinX/0BlRo8nnZpBhlmB3TmzlSiSwUc+pjlmSXhXIqtHBO8/GOyjqSqDbQIgOHGfuT+bXAiPkIUx9pf0eYyR0vgmE0tV9RiEBKqH3M2nMbOyfk9/aGG/URInueYIVPf6evunq2khi72ccfdxVpm1wMc56drQc96cf5nBpNkpzA8CQ4ls9KK9jy4uOhfI7ahfx+XQpJJsfopgx1+ERtoQsKOd9r+2W3qWC7yNUYp6Yv+AUIjkPgmkNoq1i7rXsjmLw0zmn9GGa9o4i/2ddOzv+N/mMduhvqTsz6jD1KuQSQjCXUOMWkizGiZvy4UO5P8OvBm/7YEAiKiMLHZDeUb/NEgMCI1VwuKEqpRD+YYxBHw+Y4J88yiVcCVwLhTR/TT6ceR2UFxd9lo2GllfZtrB48ltnMx/WWWF0qt05sRrcmZCjfAvZDTUScd7VbXAy+mdNJrG58m85TMJ5QqmEMZY1UNcXxuQS9xgsTc3ltDvoyDANijdjQ+gkgtBeuFpKkaYOTfAMNJk6XkxsGqgTjfzNYi6S3a48kPwtyE4b5+EKQxLkt7tvtodHI6knP93y9GtfHbGjW2lrxOFZ4gfYBVhDBbldI9OCvLHApEHDlo0OwNPAbgVYAaeKwIu4sFApSpwTw2EO X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 83d0d0ca-de72-4d2a-58db-08dc96aa3e0e 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:31.2361 (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: g2RT7p9iJhXzKkSfhn/SHUHqA/kQFMdviBF2L3EcfksBGqh3g7D6S1PworzeSzILZhp4H52HyB+kDYOD59NgJA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7549 From: Peng Fan Use scope based of_node_put() cleanup to simplify code. Signed-off-by: Peng Fan --- drivers/pinctrl/ti/pinctrl-ti-iodelay.c | 43 +++++++++---------------- 1 file changed, 15 insertions(+), 28 deletions(-) diff --git a/drivers/pinctrl/ti/pinctrl-ti-iodelay.c b/drivers/pinctrl/ti/pinctrl-ti-iodelay.c index ef9758638501..f5e5a23d2226 100644 --- a/drivers/pinctrl/ti/pinctrl-ti-iodelay.c +++ b/drivers/pinctrl/ti/pinctrl-ti-iodelay.c @@ -822,53 +822,48 @@ MODULE_DEVICE_TABLE(of, ti_iodelay_of_match); static int ti_iodelay_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct device_node *np = of_node_get(dev->of_node); + struct device_node *np __free(device_node) = of_node_get(dev->of_node); struct resource *res; struct ti_iodelay_device *iod; - int ret = 0; + int ret; if (!np) { - ret = -EINVAL; dev_err(dev, "No OF node\n"); - goto exit_out; + return -EINVAL; } iod = devm_kzalloc(dev, sizeof(*iod), GFP_KERNEL); - if (!iod) { - ret = -ENOMEM; - goto exit_out; - } + if (!iod) + return -ENOMEM; + iod->dev = dev; iod->reg_data = device_get_match_data(dev); if (!iod->reg_data) { - ret = -EINVAL; dev_err(dev, "No DATA match\n"); - goto exit_out; + return -EINVAL; } /* So far We can assume there is only 1 bank of registers */ iod->reg_base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); - if (IS_ERR(iod->reg_base)) { - ret = PTR_ERR(iod->reg_base); - goto exit_out; - } + if (IS_ERR(iod->reg_base)) + return PTR_ERR(iod->reg_base); + iod->phys_base = res->start; iod->regmap = devm_regmap_init_mmio(dev, iod->reg_base, iod->reg_data->regmap_config); if (IS_ERR(iod->regmap)) { dev_err(dev, "Regmap MMIO init failed.\n"); - ret = PTR_ERR(iod->regmap); - goto exit_out; + return PTR_ERR(iod->regmap); } ret = ti_iodelay_pinconf_init_dev(iod); if (ret) - goto exit_out; + return ret; ret = ti_iodelay_alloc_pins(dev, iod, res->start); if (ret) - goto exit_out; + return ret; iod->desc.pctlops = &ti_iodelay_pinctrl_ops; /* no pinmux ops - we are pinconf */ @@ -879,20 +874,12 @@ static int ti_iodelay_probe(struct platform_device *pdev) ret = devm_pinctrl_register_and_init(dev, &iod->desc, iod, &iod->pctl); if (ret) { dev_err(dev, "Failed to register pinctrl\n"); - goto exit_out; + return ret; } platform_set_drvdata(pdev, iod); - ret = pinctrl_enable(iod->pctl); - if (ret) - goto exit_out; - - return 0; - -exit_out: - of_node_put(np); - return ret; + return pinctrl_enable(iod->pctl); } /** 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: 807960 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2056.outbound.protection.outlook.com [40.107.21.56]) (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 14F131922EA; Thu, 27 Jun 2024 13:08:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.56 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719493723; cv=fail; b=QUH1/Dy9wOHbDOLaJ9mk3BhGbymwEB77IRej7s0SaNIEklkK3Y8aBXKmjuj06QSiYrMXI9aWOcaKjT8j6yth/v916J/gehlk7lS4U/8dpEnyRIguJz6Uhp4EXTB4UNWJm5IteCcJkvpyGm6glS60glcWnZHkf+09HwXw2RvaO0w= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719493723; c=relaxed/simple; bh=PEu5390W51O+dBL4pUKASiKHhOpoFDsy7jM2HmJJl88=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=hXKFaUURGEEMXdSW5V4U26iD1Fq7XmpESbr3ApgyM7+YMsOWTkl2A5IlhFYnJnSfOndWUWup2c1jgteKROyK/E2bRrEAlse5UcONsRO0UCMYgnIM57p1MCmEkiBWqulxFes8glwTrfwc9qwZbJL6uFfYiAH/DlyIcEjc1ObdXBU= 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=JOtETm4y; arc=fail smtp.client-ip=40.107.21.56 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="JOtETm4y" 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) Precedence: bulk X-Mailing-List: linux-gpio@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: 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+HUeXZqTaDJQD1/SHLAptp7oz9yzaQQC2gnqynmD14yUsn0ZmyqDMPJHZ0zoueV93atQQbgNF1nVc8snFkYQ7/CTFSqn6fYjb652zCgZPbf1QXF9cFVCOL0XdUK8S3qni7mbW2MWM/a1L7AmRo25kPXSUVMxTXdK9c4HnIetW0YTv2gZLKvP8eugSv9V1/ooEWGrZyQlELpL4Uz82SvUY5KZKIeOIhfHDjsGK9KJcIMdiD17OvkP6/aVq1AD7Txr56jHGXCdKXEjkezhxUrWBuqJHztfp0wq3Eb5fl/G2eJEkK2YmcmEo5K4uZF9BFeayRI2CLTldDQ10RsSTtwOtj657XYPjp//SiPOpcWZ45cUETN/QhMgufLF4VgAMnYhyZFdM++Yk66QAZQXON8NPzAfs+PUdY4cyGHKXk/yLl09umV/XAGIx8HavNDQ1OtuZncRmF6daaKJ9AotMG/yyLlRX+50QMjrBuFa/YRZZQn2BSjRM0Oxm4u09nHxk9jqUNv7Sv1WkIwNNUaoQLEoECGVnNXoyMo6aKFH74xRjbnt9tU1Jn6QdLxYD6pTGc4I/58PIZn7f2LdPHL2by9pL1ZSYWrTt69hJ3AibaccTSHaW/0+QDnYdOVQrFdW4x+SWlhRAHkBdsQeTvKeQmgOKUTgTwOzqDjqX6/A+o0R30x0X2TBkEvJjMzCSD8Plqdi89zggChv7K5MMnrnUN4X3RsMyF1VQPZGGHan21+8h1rgdY635751iGhHE6glywioMLrajVnB+zTXruiMv6Wa2vbSL/zA/xP3VIMhlazmvwq5QB0OO55pa2AxDXyJAC+kDtmG4xJJ3rKEhD09gZvZJsSsmvOmQsdeooxArn6JJg2M6qRxvBl9mwhK5G5Ly0cVb2L3nx1dAUSPtm5HdaqZll9fLe9bLL7poFVAx70icAqsid4nh9gPvdM1oMkdJnwUiiUzZtZWQHVEV3XZuSwl2Dsdrb1uZGmV5LcLvwjw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB5941.eurprd04.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 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 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)); From patchwork Thu Jun 27 13:17:21 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: 808401 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2056.outbound.protection.outlook.com [40.107.21.56]) (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 810E7192B99; Thu, 27 Jun 2024 13:08:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.56 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719493725; cv=fail; b=O39HMrBmcCi7yUGFUGV7kF5f/b/mr1FAa860PMqKdPGmFHtBHGqGBv4jjVL6EPBhEqiqD/bm5U8Y4FKCwlJFj/xaEATJKST3Of5MVo8kQTsl5+o4Qw30i4qYqz3OiWOCy8lN1rc8GGoflxKABlYLH/E4gJLlaNilpgmOTc27vi4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719493725; c=relaxed/simple; bh=ADvmole6JgJdYpXOlGO2guY6+veLL04d1JHchjxWXmc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=j/AbFQ7o9Le0G6jinU70ZX1zGpJNbRZptqrwKTv16NDM0AcFyDnztWcXx3ria/j2oU+f5hbWJPBjE52dHbiRyufwhkzLpDU4ZeGYNS3fhHiMHop38vo7pmq7HNv8ecAljnsRcoe0/Tisk34gV2GVSjDodhP1F48aMw6EOfhtgiY= 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=RcynVBZB; arc=fail smtp.client-ip=40.107.21.56 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="RcynVBZB" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MsSLckqx7h64EXU5K4rBhUwropADxYVILeo2B6pmdFodiohpCo3yqjR4c79wXHY8wzhHBBDAjgyzet7WzwNApxWAAjzBSgrO82lqApze70QeSdPSw2eEgHgcT4BEzw7rEDXZB0Qs1scU7UH3FpxyMT43SSPX+nEXMyB/7zJ/jePCY4kwlw8xiGbRNGoCMscr2IoR5vGq+RaHL1Z62akFh+qyJpqYjHXuZjz1i6SMDOJ4G20Qw/aQcsEYSyybqK/lIA+ZwGeJCZ/EL0qZT4XtTwhbH9E9OWGSYkXAv0ngEANfxrVDcAC5JKfwlW1vsR6+aQveWNaYINbbAgwsqVLdDw== 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=yr80pCQzIYp8i97HhnjiMCNfsEZ+FJnW1O/k3EO5c6Q=; b=hLEAZDFfkMaf/wRiaymSTCHk95hrg5Sa4y3yOLWwpaMREMDeL9nmD/RuT6e3omO3aKoPXYO6g/M7VfSvoKcR8U0/6n9yiXqerIVPSGc2M4DdDrsKT7N99IE6x/zjidw0/PwVcV7KayhwKyKDWtX3ajqKqUh9o+nu7c7QVe8x32P2+AIGHedWZ3hjEg4qcXr5nxRnSLDGOP8ht5/G2oftDhgh41d9168LOKO7i/fNFir+Cjn0Rz4/qleolzRBk1iAqPuppx8QGvl2zb3z6PFNn4F1X7AipflkwtZAWuJClrGBNEPSdkNf/0SDprg/BkdtlYGgYo7SqufoC4mJP4DBOQ== 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=yr80pCQzIYp8i97HhnjiMCNfsEZ+FJnW1O/k3EO5c6Q=; b=RcynVBZBzxd8pW6s7zOk4HY9GZ58lYFl+o6MlSmb4SW4gEZ/uwKSOVu7PZBsptZxvYD/CarkluHJ6T5l22IqDFG2Sgf8cC7/6/HkLs+Hi9fnzUF1tIP5mxKaMu5ffA8vttMUOyyfXnPF/22UZGQaAIqQ4soLqA9BgHDzP4/AbYU= 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:40 +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:39 +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 3/3] pinctrl: freescale: Use scope based of_node_put() cleanups Date: Thu, 27 Jun 2024 21:17:21 +0800 Message-Id: <20240627131721.678727-4-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) Precedence: bulk X-Mailing-List: linux-gpio@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: AM6PR04MB5941:EE_|PA4PR04MB7549:EE_ X-MS-Office365-Filtering-Correlation-Id: a823f49d-7519-4192-4d78-08dc96aa42ea 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: y034Y8qI3fOVPluZrs3n/Fo4YmGOMLNkF3nhiB0xOVIj4+O5BvyBkso+unhGxI83B3xfeeOG1mxSmmPAh0uJuXgDXf+25zjxiVjZau+5a/HuC1I1LTDbUjgJGE8sstQ5j34nDoz3V5M3lJj29+9LJ7iSdSDIxsnk8wDVqNJr7fNRXWCqGBvVdAY9475tX9V9FgGz2jNq2RFVYTLpzteqGmAP7GVyJ8QMQGxQyJPMTXZSTd3wXA/+a+kltFxiA6QY4yhrLAWNd9wRt8i6cCNzCbQxdecrJUtZ28LNvygGcLIocTJyA3wHTQuFDk6VjmxBBelid9dn5dexpZl64yX/ra7+bs6iIUtTwGhMzqFMmMu3azouw3GtTmgKme6f5u5HTRN7MLWtlK30Bes3ocJTe2vUgAAV5MhMid98Tu9KT77pse5/oioa+9J9FI66dNF+WLxwq14evg99RKB5U1I6Sgog6pTiXOYv8Io17V9teL5xfju4Nn0YQhkh9DfqTV0fLVvwhlQhKlFGVVxIY660A8Kp+dDz7zOGgLGIDiyeE6F5ttuWB7gdq3yVKV09dTL0qf7rTVibd0dmejbqAId6H4xc2CZm23VkfC8+3uDqkuXtOPm8o5DwFtkxnLG6kuX7zvczxesSqswnr5RrOe/o4FCBEnmGi1ThxCvtJ0pxjOwdSwINv9FQaef6BBfCU7yavWK9YiUNkeFghe4ANNM8yoxiboI6zeNhwIA3rQqSYmya1ylLUtpwQW46wT1Dxl2Kpnc7h7+XL9UJghYlDPHxynjgPeujtTd9VZc9yxjFpfxfZIyqbEBdwRCFaZLtI7BNECveVr+HKxBvZGkdpyzO8zAVAkvb24DFylHdAOEkUuS+IViyngNi/snH5p3qsiEJdBFcKNR1jTyq1hYo+m26It3X141QrTIy9PdZUdQj6sHObzw8YN1HP3kppYrbmEznqzie6Qpbj/A3yi0mTbeeaM3jboo5+DR7CWnxoiYG5IvVbxV3+WxZOHl5CgW1wtZwOd/j8UbNKppM1HY3WfYtsma32jh8uzD+ba+Q2OaK1R3cp9ShpC9C5ASZe+v/6/tTwAmDL5/GNVj5LTy280mRdw6y7RGosA356wzXChH0CDMYN40xP3zGKAU1yS/HdIvJ/+SRHuvPRbco2l+IsAs8PXUgos8dU5paYCfKa4Ki0gdGpuvq72l1D6hiBjj/Iaj5mz9LCZ3rrsQOVBm5QXbDj43oo9JZi91cP07cW4bA6hEybfi31QykNMjP9iAa0A10MZrbsUD+KeJ81NoT3y8v+MaTqF83aw8Pvxb+HBwc11iBEjSR/0qq/h12YAgsDPRUCNa36Xjfqj9uftORXBvTr9BHuROkYfR9etfeBi3jsYpG8pNjOWoWm63LysFnlQzpcPxQ28ci88tJ/TmQZcQaUg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB5941.eurprd04.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: SVKo8UGGi0BL0/mRolNi9bjr9IDI5/T3wmVS4Gh6/aHDeetLREWlZCm0POf2R+7MTGFLCQuqBnWFxaLWY355zO01pIuH1PgJqVSHUweTCV2hcSjgFMV9TyUAZwpV3b9XxbYjNNNgRGsjOiFZHKAwBjVLqVhVI5Ubg87HTtbDB8oVgBOUh7LYog0hZWC42idbI3VA2A80bN5z9e8OQ/IxhpS9eZ0AV8yzsvCFKSkbyoCdiv6X7OG+5rvvaoSPNqnFiA3RnAmmXPIB+uHClbzJgmuF4VbjALovX1TrkNKqvp1skAWEp77UQDkE5mVtJ3u35EJu0rdlE1pcOhUt6ckau2ZzL71JPZdAdcafBDaEoN2wUiOCniZd2Yo2j+ytFijMZ3u6ajMUh2kBv6GylfKJ4mKMotsrXWvyr6fZST8WDBvSlHI42vcWZEKZSiug5ABivUio1R683arU2qrWedu6Bk4ruoxRBqo/ARONHYE4sqN17Xq6HLzRiKLzZlmLaFZLw98aeAirRAEoKAtb6t7Zpg1GjsHukvTOUWkSVmomoT1x7tRl+y5d0ZGtb9SAXcT/LnXjuHANkovVeFu2H9RoiVCrzqFc5seN9eg07ul8VkzsSU9sjmXOYOLxL2N+84I90BkbvY1aTxbq9jicWghtBwBp6LBp6jyuWGxTR922wJLI7i8pJcaqINnZFixfljDhZbbm3dP0RMRjUWz3Lnn3z7AiO5dnDONUw1HBhYVrfJdeH+RXtzneTxqnZ7D88qslQ6E/pyN4ExmCqGHuaUw5fEG/YLP7HC7lLwlNZDnL7tCTYqE/AEzOHcV9mwUB5PtBou14PpHLl3d8Nuj1vvhHM8JJRY3KnoNTZjiPr7NX+qeljvfVbV1dUzrEHYodIvXUumrADbD2c9zveWZCU1w51vtmf1HM3Z+gEZ42dtA7G5DmfwsAjlIdQjqLSUxofJwuPQR3YF73H80GphwCCAd0PIdPOJ0nJ5Aa+xbVrME9ZFaPfMGVGBh9vKDEJJJ0u9fOa307qQOFKEVlBk9NkI1XScSFZ60rTo2L4A8QmSlZcEGgdV/6xrl3/FnACge9eUclkjPDCYSiIGU4MIm/BF0CNLygQ2AxfAd4tWmWdhnNTiCZt9fcnFz801ehEppSaP7ZRYtOg2k8YvuUzgW5hf/rgR7pyOMUnn8Mcrz6VxNhqyqIGL9O6rP3lIAHzA9DkKSDp6zFi4yZETZDOUD9E2v1rLay/Ts62r1E9/F79x4h21SgDOJNDAm9PqEQwAGP30tlM+kFn5QZATolNvrnb+IUFyH0dClXzY6kgbG0VWt3XeWNdvKTQCozhmzcrW4qbosInkLekl5JpdAJgAxizmxA3ZK1Mx/zJRYZvMYp20zirpXy7hdtbtvsp+OM0r5rRMhiV0WIIYfamJ4eUfgjEKrqmYH0smFxQuN7SxDMugWSgR4xMkRYL5WPUjygad3gcBpwYL57uKI2OmUQXRNhOI/J7x8Bzcn0/IW0EWe9llryNR6Wy1sVepGld3msKEK0Pg/ON0UiaTa1XDUlAftfcsJ7xF2xhy6xaauTZcTrFm3ZZL7nFZ6Cz5RRVEsViPw53HQY X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a823f49d-7519-4192-4d78-08dc96aa42ea 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:39.2858 (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: GzOptCBbzqh209xZKp5uZhm8q1HrGqDQT+JoDtjM/CP9Qv4pQtAaIuIZnffOyfsZ8eWU7AWuV9qeEenLGvsQJA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7549 From: Peng Fan Use scope based of_node_put() cleanup to simplify code. Signed-off-by: Peng Fan Reviewed-by: Jonathan Cameron --- drivers/pinctrl/freescale/pinctrl-imx.c | 25 ++++++------------- drivers/pinctrl/freescale/pinctrl-imx1-core.c | 16 ++++-------- drivers/pinctrl/freescale/pinctrl-mxs.c | 14 +++-------- 3 files changed, 16 insertions(+), 39 deletions(-) diff --git a/drivers/pinctrl/freescale/pinctrl-imx.c b/drivers/pinctrl/freescale/pinctrl-imx.c index 1ccdeb86d8a7..9c2680df082c 100644 --- a/drivers/pinctrl/freescale/pinctrl-imx.c +++ b/drivers/pinctrl/freescale/pinctrl-imx.c @@ -580,7 +580,6 @@ static int imx_pinctrl_parse_functions(struct device_node *np, u32 index) { struct pinctrl_dev *pctl = ipctl->pctl; - struct device_node *child; struct function_desc *func; struct group_desc *grp; const char **group_names; @@ -605,17 +604,15 @@ static int imx_pinctrl_parse_functions(struct device_node *np, if (!group_names) return -ENOMEM; i = 0; - for_each_child_of_node(np, child) + for_each_child_of_node_scoped(np, child) group_names[i++] = child->name; func->func.groups = group_names; i = 0; - for_each_child_of_node(np, child) { + for_each_child_of_node_scoped(np, child) { grp = devm_kzalloc(ipctl->dev, sizeof(*grp), GFP_KERNEL); - if (!grp) { - of_node_put(child); + if (!grp) return -ENOMEM; - } mutex_lock(&ipctl->mutex); radix_tree_insert(&pctl->pin_group_tree, @@ -635,21 +632,13 @@ static int imx_pinctrl_parse_functions(struct device_node *np, */ static bool imx_pinctrl_dt_is_flat_functions(struct device_node *np) { - struct device_node *function_np; - struct device_node *pinctrl_np; - - for_each_child_of_node(np, function_np) { - if (of_property_read_bool(function_np, "fsl,pins")) { - of_node_put(function_np); + for_each_child_of_node_scoped(np, function_np) { + if (of_property_read_bool(function_np, "fsl,pins")) return true; - } - for_each_child_of_node(function_np, pinctrl_np) { - if (of_property_read_bool(pinctrl_np, "fsl,pins")) { - of_node_put(pinctrl_np); - of_node_put(function_np); + for_each_child_of_node_scoped(function_np, pinctrl_np) { + if (of_property_read_bool(pinctrl_np, "fsl,pins")) return false; - } } } diff --git a/drivers/pinctrl/freescale/pinctrl-imx1-core.c b/drivers/pinctrl/freescale/pinctrl-imx1-core.c index 90c696046b38..af1ccfc90bff 100644 --- a/drivers/pinctrl/freescale/pinctrl-imx1-core.c +++ b/drivers/pinctrl/freescale/pinctrl-imx1-core.c @@ -508,7 +508,6 @@ static int imx1_pinctrl_parse_functions(struct device_node *np, struct imx1_pinctrl_soc_info *info, u32 index) { - struct device_node *child; struct imx1_pmx_func *func; struct imx1_pin_group *grp; int ret; @@ -531,14 +530,12 @@ static int imx1_pinctrl_parse_functions(struct device_node *np, if (!func->groups) return -ENOMEM; - 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++]; ret = imx1_pinctrl_parse_groups(child, grp, info, i++); - if (ret == -ENOMEM) { - of_node_put(child); + if (ret == -ENOMEM) return ret; - } } return 0; @@ -548,7 +545,6 @@ static int imx1_pinctrl_parse_dt(struct platform_device *pdev, struct imx1_pinctrl *pctl, struct imx1_pinctrl_soc_info *info) { struct device_node *np = pdev->dev.of_node; - struct device_node *child; int ret; u32 nfuncs = 0; u32 ngroups = 0; @@ -557,7 +553,7 @@ static int imx1_pinctrl_parse_dt(struct platform_device *pdev, if (!np) return -ENODEV; - for_each_child_of_node(np, child) { + for_each_child_of_node_scoped(np, child) { ++nfuncs; ngroups += of_get_child_count(child); } @@ -579,12 +575,10 @@ static int imx1_pinctrl_parse_dt(struct platform_device *pdev, if (!info->functions || !info->groups) return -ENOMEM; - for_each_child_of_node(np, child) { + for_each_child_of_node_scoped(np, child) { ret = imx1_pinctrl_parse_functions(child, info, ifunc++); - if (ret == -ENOMEM) { - of_node_put(child); + if (ret == -ENOMEM) return -ENOMEM; - } } return 0; diff --git a/drivers/pinctrl/freescale/pinctrl-mxs.c b/drivers/pinctrl/freescale/pinctrl-mxs.c index 4813a9e16cb3..edb242d30609 100644 --- a/drivers/pinctrl/freescale/pinctrl-mxs.c +++ b/drivers/pinctrl/freescale/pinctrl-mxs.c @@ -490,16 +490,14 @@ static int mxs_pinctrl_probe_dt(struct platform_device *pdev, /* Get groups for each function */ idxf = 0; fn = fnull; - for_each_child_of_node(np, child) { + for_each_child_of_node_scoped(np, child) { if (is_mxs_gpio(child)) continue; if (of_property_read_u32(child, "reg", &val)) { ret = mxs_pinctrl_parse_group(pdev, child, idxg++, NULL); - if (ret) { - of_node_put(child); + if (ret) return ret; - } continue; } @@ -509,19 +507,15 @@ static int mxs_pinctrl_probe_dt(struct platform_device *pdev, f->ngroups, sizeof(*f->groups), GFP_KERNEL); - if (!f->groups) { - of_node_put(child); + if (!f->groups) return -ENOMEM; - } fn = child->name; i = 0; } ret = mxs_pinctrl_parse_group(pdev, child, idxg++, &f->groups[i++]); - if (ret) { - of_node_put(child); + if (ret) return ret; - } } return 0;