From patchwork Wed May 1 12:56:03 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: 794039 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2084.outbound.protection.outlook.com [40.107.8.84]) (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 763327C082; Wed, 1 May 2024 12:49:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.8.84 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714567789; cv=fail; b=j12Wz8GUS2p9JLSgpng854lwNdSa5u9FwhDg/llPgjFm9vqzfIWksuL4bHX/kMM9jgD1syLON240sg4EC/LtKQt1U/ZNLpEG5bn2xb3qBwrNaN6J1RrTjh2pEjJUljFY283KizvtL8F2w8yFW9oRZd4i16i8mQBSKpymyXE92Rk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714567789; c=relaxed/simple; bh=ZoFezlHrLhNH6VNyCapJyxPF8IHiuhLM60d0IZaK3P0=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=LHePeHmxKTGlYRMFE4WSzGzwkiAwm4MDOktUrY4+kX8FBOW2HKI51MMdTvazn+IBXlrr+TjkGtRdBpm3aq3oX3w0k1R89w3b7VqL1VNewwdWTcVNbx8/AVMLQx74zIG90xoTt1mWO/NKp9rBMS+dE15J7gCRFeLY/inO78fXfOo= 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=I4jnerqd; arc=fail smtp.client-ip=40.107.8.84 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="I4jnerqd" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ve29h5h8BcMVkb+1Je5Ycjsz2hAQoJQAfcpoCPU02rQDiyi6eMWbgVqmiWH4CRT1p62sO9E19JP4f25oOEsmIHGpAz4ku6WoIq0YUio1YmVW/b5ARmtMuVhdRHK02wVhdfAWpZAK0nJ5DQxIdNYzvXifSpe6KGckHIVHXoB3YNhXRGwHyjAgiHT5gK6lKdqVozw+aJyCK9KvXfjvM8hn4ppfeZyQf2IguSj9M3b7hQZIMw1a8Z67jLJkG49b2FU74tFuugnZa/QV2Ig7BGqdnZf8LQxATKJCYNgEMK4pJBxGfVeyapd8HpLIISzOPdCv+F6QbyvUEysCq8lkLCbeuA== 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=d9YUvofIdVB4JzzWI0NRmFDL50mIRPG79od9oDhnF78=; b=PPhfLsW7SuP9/IvAj5c89Hoi0/EXWbKMLgY7B1VIvBQJrSFz+yJ2h3I8OCIEpR9P5B3upMAK7wRGfRw0cFThZvo1dxhwm1ikWlIID7Vu4U6R8qCOHKvZLejQf90xt/PX8uVOPJuK8RcUWMJ5TV6NquI7WSVxAp7yESb3PFHSv5JAH+tBc5DBM7NdNxdFWdE+TkrKQUX4mln/1/8+o5FisgMwQP2BXPm5qEyX0207BsDr9GVsWH60V3unBlYZQtailGffEbkIA4KD/mko7Q+RiBlTDJf3y53dCRWEEgsPRQV0MqmXePiV2RxD/URSZQmE+APkfHC2FSEEek2Bc7y1rA== 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=d9YUvofIdVB4JzzWI0NRmFDL50mIRPG79od9oDhnF78=; b=I4jnerqdQYo0PtLUHhRdWVFBJn9zKyabdPh2sFHr9ErIfFjM4EJAx/AfwpKuCgOWapMfbTA7kiB2d7vu2v23jbN9ACMwe4V1EEew196pVQLukDvdMKqca8QzxuKP2g8hk3SCMyOwVFL5QxYNdnE1jeZcPCkC20Rc0O7isVHd8n0= 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:49:43 +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:49:43 +0000 From: "Peng Fan (OSS)" Date: Wed, 01 May 2024 20:56:03 +0800 Subject: [PATCH 05/21] pinctrl: starfive: Use scope based of_node_put() cleanups Message-Id: <20240501-pinctrl-cleanup-v1-5-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=6656; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=q6W94Hjdjjw7xg0ybaSa/7rYn9TOuVxzheASMuMVWPs=; b=oeYu4Ud4YU5lBztSso/rf0zqe1lgwaHPiuNrD5LA72yGh5Bng1xSawl8uORrM5WFZwafQV+S2 Y5SNiNdKNvaCP9Ni25D/AlYfbPj+Btc+9YyZx4MFETYbweNVA8teD7Y 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: a0db37d7-54bf-423e-011b-08dc69dd2c5c 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?oUCenlbZPPdCsuS0TC4XsecKdLSrq8U?= =?utf-8?q?ICKFMXROKOoFXZmQNOHynLfXAwY4p+MpGZFVFor2yCos4zcOhqg8+PMeoW6X4gzt+?= =?utf-8?q?YR2GX5sBER0bFAV3qNiTKW0/9iYDKHDUIjJ+L1IF+mkDFfpdCPlvBzLASEyBGhedB?= =?utf-8?q?qKPLXRtTj5GF70k5oDOlplFWh/UdOUxTaN9Vjl+p2vHEFv+2jdiJWvZwuHBQN4JQR?= =?utf-8?q?n+HqTdVBUAtWl1lYnQQCdUT/AUUnY/nT/RGgXnxwMEpqCUexFXMWJhuJHMWY+DkXn?= =?utf-8?q?euz6PqjpO+oy71TdFIThUfSawGflULoTwW026Wn4WvVY+bjZMhWc75movg6eOY0w0?= =?utf-8?q?X5IZccw2K0bEjxVLTv7JyoAJExjfbSpmEDQSyQRibPGZwTB710kxlKT6RoF7jAdRe?= =?utf-8?q?DHqyuCSyhNHLzGfN1OXbIfEJid/uPq1zT9HR/Huy6pZ4sZ66lBPkCsAjvtFn8039a?= =?utf-8?q?fJEevd5Rsf3hZeFySGSIfrhGcx/vOItnVB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V: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?jtzVL6ZIIpJKMXZw8f8FZKflyBTw?= =?utf-8?q?O/eaOqtFm9eovq8exIJ/Qg3SgXoUG0bjWGazuFsW/OxAaapBdXmtk71cp3geBU5RE?= =?utf-8?q?BM5nw0KYiFguW87dnBUoUWhIAYvl7wnXzO41SaQocrWEcyF42uahpLn2FuCHMv5rV?= =?utf-8?q?+ksGWOtNOOCXr68gjsFM+0bwDI15zQ3sFmT50gd85UZ2VtY4d8RS1w3VK1uU1MUm2?= =?utf-8?q?WhHXnFpZ5i78H+FtzjpDd9QdDlwUU0OYFovm4Xl4ba+Oh3MQ8RY9KiE3LlguJ8jjo?= =?utf-8?q?CmJ4WX3QNybPL7n9cPsvu7wNFtVsgbUgEU3sqGGp20egwMytqSg/sXfQXpUXMEf6n?= =?utf-8?q?I04FaZioTxrVdvEi4/0fSdJ6UyypjUwqauP3/FbGFIKeP2h+8icuU4KPp1yR5P5mD?= =?utf-8?q?ajAF65YSjDemscjfL9Vf7Xmg0ICwMwtP/cs8c91Ezt96Ubd1FYtgJbfHIWJmNIe0C?= =?utf-8?q?P7OnMYK6CMl6z0UWXf1ypdjX0O0R11yRk5ZQrurxyfgT05z+9mafqgKvrLDhW+TCY?= =?utf-8?q?9nA2OmRHGOJGLyfr3OLVqIOftY8mrYF0mRH1TAIyAMMIO+ohQzvaJKfcBLuPvsExX?= =?utf-8?q?sYzJco/ybUNO9MElzS/JsXV+GO6V7Z1hs9xucY4Y+gQ/TfJzL+P2mvmjbh5axuY8m?= =?utf-8?q?CCExl9nlb9NnxOGOyWbGhfLjTCEoMzNT9vg+dEB2MrbqXJlE7vkXzMZqeTGcRZxc2?= =?utf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d7-54bf-423e-011b-08dc69dd2c5c 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:49:43.3920 (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: a8VMXjN5tnTZbVk5RTJATfV4WVyud8UqeKUIyvYzYSsszFnA3M3VjRSQ8h35vE1kbq/I+796vLW9oWOt6tBpLA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR04MB7448 From: Peng Fan Use scope based of_node_put() cleanup to simplify code. Signed-off-by: Peng Fan Acked-by: Emil Renner Berthing --- drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c | 27 +++++++++------------- drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c | 18 +++++++-------- 2 files changed, 19 insertions(+), 26 deletions(-) diff --git a/drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c b/drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c index 6df7a310c7ed..27f99183d994 100644 --- a/drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c +++ b/drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c @@ -480,7 +480,6 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev, { struct starfive_pinctrl *sfp = pinctrl_dev_get_drvdata(pctldev); struct device *dev = sfp->gc.parent; - struct device_node *child; struct pinctrl_map *map; const char **pgnames; const char *grpname; @@ -492,20 +491,18 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev, nmaps = 0; ngroups = 0; - for_each_available_child_of_node(np, child) { + for_each_available_child_of_node_scoped(np, child) { int npinmux = of_property_count_u32_elems(child, "pinmux"); int npins = of_property_count_u32_elems(child, "pins"); if (npinmux > 0 && npins > 0) { dev_err(dev, "invalid pinctrl group %pOFn.%pOFn: both pinmux and pins set\n", np, child); - of_node_put(child); return -EINVAL; } if (npinmux == 0 && npins == 0) { dev_err(dev, "invalid pinctrl group %pOFn.%pOFn: neither pinmux nor pins set\n", np, child); - of_node_put(child); return -EINVAL; } @@ -527,14 +524,14 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev, nmaps = 0; ngroups = 0; mutex_lock(&sfp->mutex); - for_each_available_child_of_node(np, child) { + for_each_available_child_of_node_scoped(np, child) { int npins; int i; grpname = devm_kasprintf(dev, GFP_KERNEL, "%pOFn.%pOFn", np, child); if (!grpname) { ret = -ENOMEM; - goto put_child; + goto free_map; } pgnames[ngroups++] = grpname; @@ -543,18 +540,18 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev, pins = devm_kcalloc(dev, npins, sizeof(*pins), GFP_KERNEL); if (!pins) { ret = -ENOMEM; - goto put_child; + goto free_map; } pinmux = devm_kcalloc(dev, npins, sizeof(*pinmux), GFP_KERNEL); if (!pinmux) { ret = -ENOMEM; - goto put_child; + goto free_map; } ret = of_property_read_u32_array(child, "pinmux", pinmux, npins); if (ret) - goto put_child; + goto free_map; for (i = 0; i < npins; i++) { unsigned int gpio = starfive_pinmux_to_gpio(pinmux[i]); @@ -570,7 +567,7 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev, pins = devm_kcalloc(dev, npins, sizeof(*pins), GFP_KERNEL); if (!pins) { ret = -ENOMEM; - goto put_child; + goto free_map; } pinmux = NULL; @@ -580,18 +577,18 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev, ret = of_property_read_u32_index(child, "pins", i, &v); if (ret) - goto put_child; + goto free_map; pins[i] = v; } } else { ret = -EINVAL; - goto put_child; + goto free_map; } ret = pinctrl_generic_add_group(pctldev, grpname, pins, npins, pinmux); if (ret < 0) { dev_err(dev, "error adding group %s: %d\n", grpname, ret); - goto put_child; + goto free_map; } ret = pinconf_generic_parse_dt_config(child, pctldev, @@ -600,7 +597,7 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev, if (ret) { dev_err(dev, "error parsing pin config of group %s: %d\n", grpname, ret); - goto put_child; + goto free_map; } /* don't create a map if there are no pinconf settings */ @@ -623,8 +620,6 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev, mutex_unlock(&sfp->mutex); return 0; -put_child: - of_node_put(child); free_map: pinctrl_utils_free_map(pctldev, map, nmaps); mutex_unlock(&sfp->mutex); diff --git a/drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c b/drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c index 9609eb1ecc3d..4ce080caa233 100644 --- a/drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c +++ b/drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c @@ -150,7 +150,7 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev, nmaps = 0; ngroups = 0; mutex_lock(&sfp->mutex); - for_each_available_child_of_node(np, child) { + for_each_available_child_of_node_scoped(np, child) { int npins = of_property_count_u32_elems(child, "pinmux"); int *pins; u32 *pinmux; @@ -161,13 +161,13 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev, "invalid pinctrl group %pOFn.%pOFn: pinmux not set\n", np, child); ret = -EINVAL; - goto put_child; + goto free_map; } grpname = devm_kasprintf(dev, GFP_KERNEL, "%pOFn.%pOFn", np, child); if (!grpname) { ret = -ENOMEM; - goto put_child; + goto free_map; } pgnames[ngroups++] = grpname; @@ -175,18 +175,18 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev, pins = devm_kcalloc(dev, npins, sizeof(*pins), GFP_KERNEL); if (!pins) { ret = -ENOMEM; - goto put_child; + goto free_map; } pinmux = devm_kcalloc(dev, npins, sizeof(*pinmux), GFP_KERNEL); if (!pinmux) { ret = -ENOMEM; - goto put_child; + goto free_map; } ret = of_property_read_u32_array(child, "pinmux", pinmux, npins); if (ret) - goto put_child; + goto free_map; for (i = 0; i < npins; i++) pins[i] = jh7110_pinmux_pin(pinmux[i]); @@ -200,7 +200,7 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev, pins, npins, pinmux); if (ret < 0) { dev_err(dev, "error adding group %s: %d\n", grpname, ret); - goto put_child; + goto free_map; } ret = pinconf_generic_parse_dt_config(child, pctldev, @@ -209,7 +209,7 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev, if (ret) { dev_err(dev, "error parsing pin config of group %s: %d\n", grpname, ret); - goto put_child; + goto free_map; } /* don't create a map if there are no pinconf settings */ @@ -233,8 +233,6 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev, *num_maps = nmaps; return 0; -put_child: - of_node_put(child); free_map: pinctrl_utils_free_map(pctldev, map, nmaps); mutex_unlock(&sfp->mutex);