From mboxrd@z Thu Jan 1 00:00:00 1970 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 3D383C4345F for ; Thu, 2 May 2024 00:54:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Date:Cc:To:From:Subject:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wSup2xGjVVPuDd5us7bcyZaqx2BtZfsPWvDN/LEkNcA=; b=JRaCZSURi/qa1E 30PjZxppfk+UTddzDtmPcBpTLgCAXevCodii0UhlJHUal+sdEQT0ruEk7ZtXN4+yqvglHRQw7MOWt sYKnjQATqUfzT8U9FsZH61fpomFT0X39POUuw0Rk1BzwIsSY7XhZQAJdI7vIDsXiTMdey/QhZ56vx UiWunOknBmZqQzcgIxTz4+agEakfkSkmNYIB2Gw6lWq6TZ0XC0AqyJLX65J7M6evny+GszG4GayxU E6p8HI5QzYks/YlzRN3xW1fVnsOhpkZfJCW9jSw2pNlPs7IKw95MHtWXT8ma4nhPZBJBj7HgBl3EX OD9av80r2VgjeUTxbr9g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s2KiW-0000000B4Po-3j9C; Thu, 02 May 2024 00:54:32 +0000 Received: from pi.codeconstruct.com.au ([203.29.241.158] helo=codeconstruct.com.au) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s2KiP-0000000B4Ma-1SS5; Thu, 02 May 2024 00:54:28 +0000 Received: from [192.168.148.88] (unknown [120.20.105.107]) by mail.codeconstruct.com.au (Postfix) with ESMTPSA id 088B420009; Thu, 2 May 2024 08:53:58 +0800 (AWST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codeconstruct.com.au; s=2022a; t=1714611252; bh=2UKQhOigrDLEgeDWGD84hTlrB50inUdwvmzSWDEPPvc=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=mEGxVQndQ7eIpM8jn5g71jdxtIHcuCBHuXLX3t5HOduXT6G3KWhFZnai5E2QWPjpt xUbxUMw8Z0D7c5pD24vc3ZzhGQXYfLHWVGmOrlPgPRJmKshV4rf1+Spnba3BnjBf4l 8kLrN/vlnSlI42W2LzZcE2L6SrWlkinmiVnj3Rl3LhPxwTZqfRHyGa9k6V52F+FI5F O5UUH9X8QHzbu1WEy+dCXTrm0/I1k7hs6S6p0FEuot7yADPKouHcSE4oy6JC/UkbhR coiTMdEGtIg1BQPHt0NyDzVrbhFKr3BlOwadA5+C73I61sUw6Ujqb07PJS0zHw2Vf1 h9752xRr1Wnyg== Message-ID: Subject: Re: [PATCH 20/21] pinctrl: aspeed: g5: Use scope based of_node_put() cleanups From: Andrew Jeffery To: "Peng Fan (OSS)" , 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 , 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 Date: Thu, 02 May 2024 10:23:58 +0930 In-Reply-To: <20240501-pinctrl-cleanup-v1-20-797ceca46e5c@nxp.com> References: <20240501-pinctrl-cleanup-v1-0-797ceca46e5c@nxp.com> <20240501-pinctrl-cleanup-v1-20-797ceca46e5c@nxp.com> User-Agent: Evolution 3.46.4-2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240501_175425_797208_B68EFCF2 X-CRM114-Status: GOOD ( 16.06 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org On Wed, 2024-05-01 at 20:56 +0800, Peng Fan (OSS) wrote: > From: Peng Fan > > Use scope based of_node_put() cleanup to simplify code. > > Signed-off-by: Peng Fan > --- > drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c b/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c > index 5bb8fd0d1e41..61fbfddb5938 100644 > --- a/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c > +++ b/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c > @@ -2629,14 +2629,13 @@ static struct regmap *aspeed_g5_acquire_regmap(struct aspeed_pinmux_data *ctx, > return ctx->maps[ip]; > > if (ip == ASPEED_IP_GFX) { > - struct device_node *node; > + struct device_node *node __free(device_node) = NULL; > struct regmap *map; > > node = of_parse_phandle(ctx->dev->of_node, > "aspeed,external-nodes", 0); > if (node) { > map = syscon_node_to_regmap(node); > - of_node_put(node); > if (IS_ERR(map)) > return map; > } else > @@ -2648,7 +2647,7 @@ static struct regmap *aspeed_g5_acquire_regmap(struct aspeed_pinmux_data *ctx, > } > > if (ip == ASPEED_IP_LPC) { > - struct device_node *np; > + struct device_node *np __free(device_node) = NULL; > struct regmap *map; > > np = of_parse_phandle(ctx->dev->of_node, > @@ -2660,7 +2659,6 @@ static struct regmap *aspeed_g5_acquire_regmap(struct aspeed_pinmux_data *ctx, > return ERR_PTR(-ENODEV); > > map = syscon_node_to_regmap(np->parent); > - of_node_put(np); > if (IS_ERR(map)) > return map; I think I agree with Krzysztof's feedback on the Samsung patch[1], and that I prefer the existing approach for the Aspeed driver. My reasoning suggests the existing implementation does the right thing. That said, the code could be adjusted to use early returns and consistent variable names, which might make it easier to reason about. I'll consider a follow-up patch to address that. Regardless, thanks for taking the time to explore the cleanup. Andrew [1]: https://lore.kernel.org/lkml/34193501-5b7b-4ffd-8549-a04c6930d02d@kernel.org/ > } else > _______________________________________________ Linux-rockchip mailing list Linux-rockchip@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-rockchip