From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 37B7355783; Thu, 2 May 2024 09:45:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714643120; cv=none; b=JmONAqOM+RmrQMLnu5V9vT6CZaWNXunjfR5TobAWdrmvMrgFKTyVJU6tipS8736IKVYlRVtuRegIwHpmYiR0sDiCs+IoyXOyGgcuGBEhMEDueMUDGINC2uDfYGZdU9fBdXdOrqfKkGRWX626c+/p3h10CCXcRS9KWWxjYRToi/I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714643120; c=relaxed/simple; bh=KMKmbjNxDjaQW/0y4bty5ahkkoXZGQdtL8KqJYUhwyE=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=jye0JU9wZma8jHPfRlVCgkwzVu6n+DQpIxCY9sZDFapxY2O6jRUBoSSr1MbvX33rsWrxPV5dYCjw+Qb+Ya3lHsFLcRo3AhkW9g0w6h++bd4VEcLxeJn4TpIV4BCkgT1S7Cgp4OASuPm+0D5g311Urw6qX2rif6Ri0Qz3CVRAUB4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oAfQwcFE; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oAfQwcFE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC6A9C113CC; Thu, 2 May 2024 09:45:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714643119; bh=KMKmbjNxDjaQW/0y4bty5ahkkoXZGQdtL8KqJYUhwyE=; h=Date:Subject:List-Id:To:Cc:References:From:In-Reply-To:From; b=oAfQwcFEFQ4YSvMqY1Xbh/lsc5LPNSzumgD/oGqD14ngGgVPaEs7MibpgzzKx9oki Zagn8sEO8gj46WZhp4lLi4tBXFTB+pnYiA73nYZaFmp60rxFnqFwc6JU+DjWzL67dG /MZ0o36PB32nJVFZyZuANe63Rb2438n1oBk0vqlifHQrplthsktdyd/SJ9MqUjTqSh S4MhcJVVnSWRNuZQtI579Q7AgypadRVel2Bn/9DPwLpuM9kooXWaDgrnlLnFOcgFi9 WcmGesxwuIsoxe8I2o27QKIei0xaWcNAItuJ4mp51iYpDI3BxfZTFiHOR9LfE7YUv9 8qqWoV1TVGUXg== Message-ID: Date: Thu, 2 May 2024 18:45:09 +0900 Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 12/21] pinctrl: k210: Use scope based of_node_put() cleanups 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 , 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 References: <20240501-pinctrl-cleanup-v1-0-797ceca46e5c@nxp.com> <20240501-pinctrl-cleanup-v1-12-797ceca46e5c@nxp.com> From: Damien Le Moal Content-Language: en-US Organization: Western Digital Research In-Reply-To: <20240501-pinctrl-cleanup-v1-12-797ceca46e5c@nxp.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 5/1/24 21:56, Peng Fan (OSS) wrote: > From: Peng Fan > > Use scope based of_node_put() cleanup to simplify code. > > Signed-off-by: Peng Fan > --- > drivers/pinctrl/pinctrl-k210.c | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/drivers/pinctrl/pinctrl-k210.c b/drivers/pinctrl/pinctrl-k210.c > index b6d1ed9ec9a3..2753e14c3e38 100644 > --- a/drivers/pinctrl/pinctrl-k210.c > +++ b/drivers/pinctrl/pinctrl-k210.c > @@ -849,7 +849,6 @@ static int k210_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev, > unsigned int *num_maps) > { > unsigned int reserved_maps; > - struct device_node *np; > int ret; > > reserved_maps = 0; > @@ -861,13 +860,11 @@ static int k210_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev, > if (ret < 0) > goto err; > > - for_each_available_child_of_node(np_config, np) { > + for_each_available_child_of_node_scoped(np_config, np) { > ret = k210_pinctrl_dt_subnode_to_map(pctldev, np, map, > &reserved_maps, num_maps); > - if (ret < 0) { > - of_node_put(np); Personally, I am really not a fan of things that hide code like that scoped thing... If I want a language that hides code, I would be doing C++ :) That said, I am not opposed to this so I will let Linus (Walleij) decide. Also, I think that "for_each_available_child_of_node" is a bad name... It really should be something like for_each_available_child_of_node_get() to make it clear that a of_node_put() is needed. > + if (ret < 0) > goto err; > - } > } > return 0; > > -- Damien Le Moal Western Digital Research