From patchwork Sat May 4 13:20: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: 794666 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2041.outbound.protection.outlook.com [40.107.22.41]) (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 0C4C83AC0C; Sat, 4 May 2024 13:15:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714828512; cv=fail; b=G0fgLjKR/eRBHNDp2CJhIIlUW41QwEHx4ppxzJ75xGzUpRI4iSagfCVRObl1mZ43/yZvMtrtHptmTKixxqjcQ9H/8xyaK3LpnPp7nukAPAsWSS5Zsw/tvIZl6J/u+Kle/3DHPe1T5hJipPady7W+FIPKjVhl0xNhORhxT2fqqYI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714828512; c=relaxed/simple; bh=E6ik9M6/qhOWxdXMSi5wfgwa6MozB3Zte/4KB5unPbM=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=fP07JKr0G6x5MdEAKWwKd2aFDmDHYhhmSY+4FfiSdFlf+d2q1Mx0ZG0tiM3LTQVIJ/KB/I+VTpl3MCqEJSXw07r8UH7dcDj7mroNWzKJ4IPEANfO7OMYJ2DOd1HkcUFYYshYiuhu0BVgmSFiY3nl55jkusOI6YYnha441jO/vS0= 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=lZr7eJvK; arc=fail smtp.client-ip=40.107.22.41 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="lZr7eJvK" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oWcs9F6D1cAInFj0HNId55OgFiP/mkBRJdDBth1QPgZ5CaKgqIAALcgcQA1NjWptsksyVAzXuhsB3we/2egExl9uYbbVtaxdsq0leD3umqoNBu+9Ccxb8izBxX0JQ5w2zPGyFCIG9XcR9h6EXqpY9B2EPYkqz1V/CygsdPAe63ZvpD3Dk8JuG9HlU5X2ruOSETUaCKiZQEW253cf5Cl9oHzq5xhhjeYZR33/Siq5yx3CO9DxCQUZN4xP9Uos93z0tmyzcRg52dcbHPDW2YDrx6viOehHk+dnvXdGsJS7iqL209vw/qHQhIAGk6ML/9vKar82r7wkfCYgoO50+FPaUA== 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=h5aiCFA3yIhGGeDVFZp9kTNSwyd475ryEOK/SwQEGNwyuf8nAUKXiAKpeWOtGrkrG/DAkGmwU0FmaxJJ/Qh1ToPDh8oAQCYFNqzdxmG4x4XkI+CnQsToa3zZzW0z+Y/5kqztve3wax35JxlgJWPRQn4Cj1p84j2V3kd47RIp/pQr40bX/BY68ySZ4z7ZxdMDbCFd8EbpPEOLzCm4qeSjfrQeVc2esgF6218qpIGtcad4RckxyhOxOnng93HiR+/Vm/o3J5TAJEiDNV0Jwip3eEaq6gcIi1RI6108Cm7yMH84PCPm3puWCkSFF3Q7LIEUKhJ6cEUQ7cK9iu1lQSsOPg== 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=lZr7eJvKLCQzJZDvJgt7Naxc5QoUcJvqDpm0lF9CZdP2zjbsNCbQcGc2VU0uaTeQ1RX0b3Mq05FEoza+cTb1C87bIBo7Ud/6+Gotll2gHMQo0KA/svrXB2TElm9iznEQIx28QiSe8Fzb0dRRnqVsvZ9l0QoJ7H4RinW3AYeTC4k= 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 AM9PR04MB8633.eurprd04.prod.outlook.com (2603:10a6:20b:43c::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.34; Sat, 4 May 2024 13:15:07 +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.7544.036; Sat, 4 May 2024 13:15:07 +0000 From: "Peng Fan (OSS)" Date: Sat, 04 May 2024 21:20:08 +0800 Subject: [PATCH v2 10/20] pinctrl: equilibrium: Use scope based of_node_put() cleanups Message-Id: <20240504-pinctrl-cleanup-v2-10-26c5f2dc1181@nxp.com> References: <20240504-pinctrl-cleanup-v2-0-26c5f2dc1181@nxp.com> In-Reply-To: <20240504-pinctrl-cleanup-v2-0-26c5f2dc1181@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 , Tony Lindgren , Stephen Warren 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=1714828815; l=3196; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=HA5FdeU3k8hXGIzvGdYVmDetKxvVIH+CQmWTQZMAMaY=; b=5/9X9Qk9v/w+LR87FogVZNrWJ/LbCFJXvedVd7p6cKDdq763RoRF3HqVmtqSayI+ZxqnUpTVv 9nppgP1puY4C3uChQOu864GCcusz2Mno4rh5TLaHidULc7StN8ugZY1 X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2PR06CA0230.apcprd06.prod.outlook.com (2603:1096:4:ac::14) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) 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: DU0PR04MB9417:EE_|AM9PR04MB8633:EE_ X-MS-Office365-Filtering-Correlation-Id: e5a5311e-56df-4041-119b-08dc6c3c37ca 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|52116005|7416005|376005|1800799015|366007|38350700005|921011; X-Microsoft-Antispam-Message-Info: =?utf-8?q?+e2HdoprGVrzXrmOHx/a9GV3vTDOPXH?= =?utf-8?q?Zdz6s7oS2f+/3S7ypA7czwD0e7r4deU+DWrrBqaDsAMxOzpVpqtlnNtAIz9L//lSw?= =?utf-8?q?jjNq4tOtk8KgzZ2iMxAqcG0gGtAH2hu/oxs8lRrIG5Ppm/zi6Nn7xNtmkD59eQjM4?= =?utf-8?q?8X70cHa6cJp9CO5dlqGMdf7OwtZZuyclij0oqgSHOho+XRynK4fQaUTX1mC/z4PrA?= =?utf-8?q?aR7K5aBQEjUSoMoee1NpafJXpxnplDnmQj5OETVRUoEz0M8lr9DZDxGXZ4EPcPuvI?= =?utf-8?q?RPSDfzPinHtj66PGLVPdHesqztTwII3y68npDcqWPmWbufwzXyKDg0m6+zyrturdy?= =?utf-8?q?F9JEQJen9xzLegGn3XoOoGWlpyoNsXRUjHAjh0X71MoGYAlzqDwr8r6d+OHO5cR3p?= =?utf-8?q?ixmH+kvVxacd7pauFij76vFIUysB5siUkFocDTz9rUEPIqonoeeJ3e53EU6N/6y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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)(52116005)(7416005)(376005)(1800799015)(366007)(38350700005)(921011); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?188QvLyzi8N8AubEdh+Jr2QYA6uS?= =?utf-8?q?f9m7n7AMlXqW2RPxpbqfdFqSv3hqKvNMKJdy+Gn4oOi/sq7N0T9l6xBI4obziRTv/?= =?utf-8?q?Nhqmsfp4VWzxmuOY2VdLUA3hO9WdpYBcn/y6xWdroq9O4RGs7WOmEF22MndyPG1b+?= =?utf-8?q?mspjEBltzQExwSPXsLXwtgy3gqzNrnvBxQux06D0GnADYY52ST+xhflF8hrrsyqdV?= =?utf-8?q?CWaBTywTJwzhtf+sYryKxmnJTOA/A21uWZ6t2Q704WQhx/MbGwbZ9HUn761lvGA+f?= =?utf-8?q?dekB77d+FxH5WfXbLSgB+if8HuaMASlmjZB94QDR8nhFCYX6Gbiv5Am+jwwUrJEFE?= =?utf-8?q?c3EpxZ/hSg0vxMfUkph2YFSb37o96iZAXSIFkkvlit02FkuvOq0VgpanvJO+tOVou?= =?utf-8?q?lxjY7UMZLj409kwwmtwwV4gMrVKaZ4CXSQpr6idDiOYKxfyFa01nNnIlAIYcBP3sv?= =?utf-8?q?d3f3XaA5ZlqDxsRN5xCtb45dNcen1sap2lP1bkPlLyW0KrCYQd93K2zHsCAxoERaM?= =?utf-8?q?rpDwlv1w13SmHmBK4J9OLNgeV2mxAqcdj/doyhxScCabxHWWMYQ97CkRm4J5z7q6p?= =?utf-8?q?OHCiLDJL2UxQLizeNuAr/Nwx/tuhEMz13OQ/ZtaVRqwqJjQZH7GZHDVmKc1tanKaU?= =?utf-8?q?zME6x0HZmxVnIRz3mwQyYizGdGq2SEUFR2BHznz9r1TSZCH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CrossTenant-Network-Message-Id: e5a5311e-56df-4041-119b-08dc6c3c37ca X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2024 13:15:07.0565 (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: tgqzsjFOhmoOiJr4CQutCoVr54qf+mNdPaAiocqwbFYANx50RD96f41YT+/5iD2RuPK65b/qDDXMDb1ZrTn3Ng== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8633 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));