Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp824492lqm; Wed, 1 May 2024 17:54:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWxqmfbYC/BkATPZ0uEG6Hy12OITPZT6R6Wh/8U+AGblzzcvjejXM5cNmwim8G6e7EVAX2sla7LdlwxdRq1hImv2vZjV/mYd78xN7wvmw== X-Google-Smtp-Source: AGHT+IFcRUl/kgVGwcNTylBzli4xUHeE1UaUg91dd+it3dv8y1DuJJdJG0capFYMuvHNFo3NkssN X-Received: by 2002:a05:620a:4614:b0:790:95cf:c784 with SMTP id br20-20020a05620a461400b0079095cfc784mr5111355qkb.78.1714611269538; Wed, 01 May 2024 17:54:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714611269; cv=pass; d=google.com; s=arc-20160816; b=RA0CkcFtciBMWAEBPH20R+8XG6RxB7jPjhqEIzRIvnIPkTMBrCJ19qN8N9Qm5/9ZTz wCyfklE1GF5vJZMw4NGCxsPLlQdYpn5cHbOL0BkTtdjaxnUX/I707/4YNjSrzI4/REjn /3omIJcjtsWMgWcDdF9jW3ynk4zLRAt2xrrLlaGJcsSw8Quh97sYMvF7Ja9fF5Pp4fCJ 9P6wh8ZKcHCZsxnQ+EpV+C5Iu7WrpRgOhAuIAk0CIWEfmTOiEk2HGzDWKXuR6H5o1eq1 oJRQBleCdlvHUCT7CHlxc6anczEwOiL1s9WgXCkd4IqgfC1RqtWqoSog0NaCx2Othyc8 XxEA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:references:in-reply-to:date:cc :to:from:subject:message-id:dkim-signature; bh=2UKQhOigrDLEgeDWGD84hTlrB50inUdwvmzSWDEPPvc=; fh=KHy8al6B3zcEG9jHM5QR85LA2RdkKJllU66Y1E47dP4=; b=06QoyAga1Pas8UsOWUfagLCOqmiiZhjpdPvYiaj9m/RkyozpYdaZnlllAO8XaGNbA3 Ek2xA8SsZEQt86p8LRbw0cGy5I4lxzuPEvgxSMtD33rwxqCTqsel+yojgQoQVBwwJ8fQ md1Zr0SQLWVK9+kb/BeDP3FpXZxjy3q80gOCl51dpdvapskppGYJgXzUtaHOFd2pf/D/ vbj6usPeNOn8j/eMx21EV8i/Iq3tKSqsZoTQAQ2NN+HeN4Lhh1im+Zr1pV/8HwOEp5cG AqXL+JNS/xYhqmxhtELJZOtFGuf0s9ECeX5G+pQTMrmHpfpxbO3a01+GwowWQArQf2Wy NpCg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@codeconstruct.com.au header.s=2022a header.b=mEGxVQnd; arc=pass (i=1 spf=pass spfdomain=codeconstruct.com.au dkim=pass dkdomain=codeconstruct.com.au dmarc=pass fromdomain=codeconstruct.com.au); spf=pass (google.com: domain of linux-kernel+bounces-165887-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165887-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=codeconstruct.com.au Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id j2-20020a05620a410200b007906b86a35fsi11162034qko.351.2024.05.01.17.54.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 17:54:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-165887-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@codeconstruct.com.au header.s=2022a header.b=mEGxVQnd; arc=pass (i=1 spf=pass spfdomain=codeconstruct.com.au dkim=pass dkdomain=codeconstruct.com.au dmarc=pass fromdomain=codeconstruct.com.au); spf=pass (google.com: domain of linux-kernel+bounces-165887-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165887-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=codeconstruct.com.au Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 453651C2173F for ; Thu, 2 May 2024 00:54:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1CEC812B87; Thu, 2 May 2024 00:54:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=codeconstruct.com.au header.i=@codeconstruct.com.au header.b="mEGxVQnd" Received: from codeconstruct.com.au (pi.codeconstruct.com.au [203.29.241.158]) (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 3118F611E; Thu, 2 May 2024 00:54:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.29.241.158 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714611262; cv=none; b=Or/tjRaNuOz0eAdkfvtx1HS9BMm5ikCJy7kv44+Li4+fFdAl+TA9fahcsQTcOZGhiDJmA/OAQ11UzIaY9Qn2KHvW39alSSi0CcThbPww2pMmPppbiIZUkHJNi4RP4Y7g476nMcoZo9Bd4+bhnWsEd+RmWo2XZIE/t0k7ccYq9Us= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714611262; c=relaxed/simple; bh=/YwyotRKUK/USAoCPHCklE6Bj9At5c+Wq8hXs0E2ZMw=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=keMKbhXmt1OkDsJ7caZUcfXwF7EHVopzo/G5z8vhdv5H+XgMDzRo1tY78thkdLL/wyLT7fwOAdjfA9e8YbvYL0n+zEK+ydZXi/FyyDHAvWiOg9kqoXmVgBfEm023XhD91K4QwE0+YBW1LR2O1HOH36/xNR8Ut2EFr1iYztTGgCU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=codeconstruct.com.au; spf=pass smtp.mailfrom=codeconstruct.com.au; dkim=pass (2048-bit key) header.d=codeconstruct.com.au header.i=@codeconstruct.com.au header.b=mEGxVQnd; arc=none smtp.client-ip=203.29.241.158 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=codeconstruct.com.au Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=codeconstruct.com.au 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> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.4-2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Wed, 2024-05-01 at 20:56 +0800, Peng Fan (OSS) wrote: > From: Peng Fan >=20 > Use scope based of_node_put() cleanup to simplify code. >=20 > Signed-off-by: Peng Fan > --- > drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) >=20 > 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(st= ruct aspeed_pinmux_data *ctx, > return ctx->maps[ip]; > =20 > if (ip =3D=3D ASPEED_IP_GFX) { > - struct device_node *node; > + struct device_node *node __free(device_node) =3D NULL; > struct regmap *map; > =20 > node =3D of_parse_phandle(ctx->dev->of_node, > "aspeed,external-nodes", 0); > if (node) { > map =3D 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(stru= ct aspeed_pinmux_data *ctx, > } > =20 > if (ip =3D=3D ASPEED_IP_LPC) { > - struct device_node *np; > + struct device_node *np __free(device_node) =3D NULL; > struct regmap *map; > =20 > np =3D of_parse_phandle(ctx->dev->of_node, > @@ -2660,7 +2659,6 @@ static struct regmap *aspeed_g5_acquire_regmap(stru= ct aspeed_pinmux_data *ctx, > return ERR_PTR(-ENODEV); > =20 > map =3D 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@kern= el.org/ > } else >=20