Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2141939lqb; Mon, 27 May 2024 09:07:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX5EmaslnN83HiodwvRVX2t070BJT1EMef7dvMYMT0l+/I2/juK2F/ra/OgXWD6YeuU2dS1Ib0BJ8+fZ6+HIo/pkl8ih7KS5fU07oO+Lw== X-Google-Smtp-Source: AGHT+IGzv/GxaGaTHsNTwvKTx/sjcpue8JycVPfxLbVUcauOT57Q2hI5Ah3hyNJS1R0NOrC4qYYM X-Received: by 2002:a17:902:e5d1:b0:1f4:a026:4888 with SMTP id d9443c01a7336-1f4a0264a80mr28916775ad.21.1716826032119; Mon, 27 May 2024 09:07:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716826032; cv=pass; d=google.com; s=arc-20160816; b=HPJ2xGCWFjJ3coxmphgkMAxPNDtn9sSgwZhqfT/RHye0cz3BQk8cMY/8H2euvUzq+O 8AYR9ngpJSVZsKe0pjMj0ek/zqO6RXE6u0HazgJxHDnuh+Ol4gbeje3/MGTT8Q7inrkD EqOoXZT+OL0o5B4MiKQ4I8Gk5s5Lw6o3gWjphNJGkznRQEt6BddM2J3SNNfgcr1cnOjo jMk9A8st8EbqOguVsGOmc8CSy/ac2f0boixq9RFvcZzJ5gILnl3Tgi0M42WdFZhBrDVA wmvny962oGec0N0dUy+9tjMP2GPkDrboOoMOxSGrKLssDUk5vDXcRZmEcbtQ7x65t/nE EggQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:in-reply-to:from :content-language:subject:references:cc:to:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=WBD5fZbJKASRGqCVJjwjF0/sBlA3tJ1is50PhfAuexQ=; fh=KbU6pMcEdiv8A+sVUKspFn8WzW/VkVnHeTugfOmTQr8=; b=WcOX5NbvQ5qwG3EeD0NLtnnz4ccjrXw6FXP+vSfa+t1hfFHWpZTl51S8n7fIQD8spy b8tv0QEK221aK3Eueq6YQxu8dOhQRbla3T8NZHpAj7nr2exdF2+ZQW5X2Cl4Bj1M1b5w kbB8ahm9ARQsv5WDrLyYVYMd80bJYa9AFD91fJLMeMIYpcj4fxM2Sn6lprXmQsY7E0uF smL58P9b9ixm4jfzy3m5tiq/+qfIN9KBHjvwVJW53zyUwHZOAaIyFqy+9CdUowTg1bQ9 0fZk1gLcXD0oSw8iYJnuupuK0/jLpHaggo64BaTpL2k+/Ow2eSUg7ArA5nq7kY6SGiJu qb3w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@web.de header.s=s29768273 header.b=vX3VhVkt; arc=pass (i=1 spf=pass spfdomain=web.de dkim=pass dkdomain=web.de dmarc=pass fromdomain=web.de); spf=pass (google.com: domain of linux-kernel+bounces-190976-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190976-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=web.de Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f44c9733a2si63987505ad.215.2024.05.27.09.07.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 09:07:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-190976-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@web.de header.s=s29768273 header.b=vX3VhVkt; arc=pass (i=1 spf=pass spfdomain=web.de dkim=pass dkdomain=web.de dmarc=pass fromdomain=web.de); spf=pass (google.com: domain of linux-kernel+bounces-190976-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190976-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=web.de 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 8C33AB31CF4 for ; Mon, 27 May 2024 15:00:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9EC871649B3; Mon, 27 May 2024 14:27:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=web.de header.i=markus.elfring@web.de header.b="vX3VhVkt" Received: from mout.web.de (mout.web.de [212.227.17.12]) (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 4395D17E91B; Mon, 27 May 2024 14:27:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.17.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716820026; cv=none; b=XoG28LPWR6+ZGGkpxD/Ct6ypPiMMwVyVHTPHc78R0nXiZ6lAswM88paNw1Mrux2LwExOutFOu3dm0zUsdwUe/QB+jR4rTFiT/UvT74yjEKv8zaVustNJWos69fIabdu4mZQztgGV9Q2aZifGM2fPu4whT69mwGGSL9mGdbtNogM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716820026; c=relaxed/simple; bh=TgeovkgpeOWUAlJ7eOdHzTn1cFUm/dVzU2NqObmFObU=; h=Message-ID:Date:MIME-Version:To:Cc:References:Subject:From: In-Reply-To:Content-Type; b=rDWMMLz/FvwD0GuHTRuOPt0uWEScp+8G/YcwkLE70Ps1j61uDD5MRsF4pW6x05qE7ovPnsEbQmbG0AEC1Hs/poZ/p+wNXNOToHuAW/b2f+2Wjq2F+6ANZ6f/A2a1C86K8Rhc1z9dikVKawp7z68X9SCJNskzr+MSOBxw5E4lzbE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=web.de; spf=pass smtp.mailfrom=web.de; dkim=pass (2048-bit key) header.d=web.de header.i=markus.elfring@web.de header.b=vX3VhVkt; arc=none smtp.client-ip=212.227.17.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=web.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=web.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=web.de; s=s29768273; t=1716819939; x=1717424739; i=markus.elfring@web.de; bh=WBD5fZbJKASRGqCVJjwjF0/sBlA3tJ1is50PhfAuexQ=; h=X-UI-Sender-Class:Message-ID:Date:MIME-Version:To:Cc:References: Subject:From:In-Reply-To:Content-Type:Content-Transfer-Encoding: cc:content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=vX3VhVktvAsC3VEpXA8voazwMQsxjS3krCXirqMDaKAZ3hS5dLEBLJJcYH/CnQUD LX884yPHk6T2CjcYkXrEWl3j7h+qjsuQr6krfiSjSbT9o7hELP6R1MOL3ePslfGIM nUn+Cno9/WCN6Qt7tnw9wJkEH43RGHNxZEMJFx1wgs5oyZoUK9bL3MJfGys243Jnt RWe1fGAwlia3NmWKjA9buWb62mNSN4PEffNKdBdV4ee2XJY9EETUDzwTlBNTo8KlT kv2IvCfd4sTrUVWvA5STc6LBECDk34micjPSbDUs3ES7nw1m899uLKkS35frEPwr4 gv2XA0CeWBiz5oCAtw== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.21] ([94.31.83.95]) by smtp.web.de (mrweb105 [213.165.67.124]) with ESMTPSA (Nemesis) id 1Mtgyj-1sV3WP3CJT-017EBc; Mon, 27 May 2024 16:25:38 +0200 Message-ID: <96beb071-ec2c-475f-8fa2-d519a1b1dc28@web.de> Date: Mon, 27 May 2024 16:25:18 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: Peng Fan , soc@kernel.org, Alexandre Belloni , Alexandre Torgue , Alim Akhtar , Andrew Jeffery , Angelo Gioacchino Del Regno , Baolin Wang , Chester Lin , Chunyan Zhang , Claudiu Beznea , Damien Le Moal , Dan Carpenter , Dong Aisheng , Dvorkin Dmitry , Emil Renner Berthing , Fabio Estevam , Geert Uytterhoeven , Ghennadi Procopciuc , Hal Feng , =?UTF-8?Q?Heiko_St=C3=BCbner?= , Jacky Bai , Jianlong Huang , Joel Stanley , Jonathan Hunter , Krzysztof Kozlowski , Linus Walleij , Ludovic Desroches , Matthias Brugger , Matthias Brugger , Maxime Coquelin , Nicolas Ferre , Orson Zhai , Patrice Chotard , Sascha Hauer , Sean Wang , Shawn Guo , Shiraz Hashim , Stephen Warren , Sylwester Nawrocki , Thierry Reding , Tony Lindgren , Viresh Kumar , Wells Lu Cc: LKML , linux-gpio@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, kernel@pengutronix.de, Peng Fan , Emil Renner Berthing References: <20240504-pinctrl-cleanup-v2-4-26c5f2dc1181@nxp.com> Subject: Re: [PATCH v2 04/20] pinctrl: starfive: Use scope based of_node_put() cleanups Content-Language: en-GB From: Markus Elfring In-Reply-To: <20240504-pinctrl-cleanup-v2-4-26c5f2dc1181@nxp.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:+RyPoq5wWT0ZiaKtbHEM7oUjpYEVZsaQY6N7Y3GqAcCCbvu/2JH u2A1o9G2LZb7XdHLU3H69K/ZAgfhJvU9jxdpYiqAnNWG9BA1SqA6BdADoQmnmuaRrP6fAil 8Vj3+benFoPx5AOFPUxJJt7XUQwXd4D4fxOV2u0S4nMX3GZIShaRs493PFfPvepvyAbRCtv sA0TyVvmVIL0Nk6+KE4zA== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:31oKYLNiYt8=;Hxns51jU3fPbLxYZhS6Zxy9O8BL qcSJkc+8tI81FYEgYUDEjPFyxO5CsD0G4Yr1KM0HiJM1RAdO+budqXdzmwIJQJO5p6Qgg2nVe YKgM7j5yLFrWsSzyaik+NFTvY+PW6VUe11QHVHkDricbyYHE5P9qzbTg86+yeRiFSOOQZksg9 Xdrs6r2eTX9AowMfEJqKIKNofU6TcDdmBmEh2hd5cMEugRlaO/xU/ubiYD/XRmfkiGEw2Tk9X NW8zaQg81GL2PPwft4f4poEafCoYwl+CIrmPHqURH/2YArZiC4UDm9VTu3lTVR8WSADgs2juL WzjmfuF3Nb/H8VSJqqzY977EL7BYu0JfjXhqczsj/AJHIU8x7U9FkHQwVLD+/aW9Q5b/a9OPw LI1zUhjAqpzjkl9ILHME5dfhA7gkD4YfqDP0iVyWu+VnmZh/pblaybHt4rD5ZI5OfaaxJKTej VGs+IMuQBrMttXj/4DWsuAy6tL2ASvq9ajbc+W4PfJFRO8eiyAiXlRr8A1ilG3Wwi2usEs8x0 pyhK5u8Ye84ZDNXC0xiObkf3AMdCBhIc+0OAJbS7S/lr4Wa88XoId5G8Ib9v3q3Danb/+yyUK 5YECHUaogBhuwKJTAPf6awFWX25sWIKFsuMiL9bOP098OSKsVamHNvrpo4VNiI2KTPlO3jYMF m4zC6H3fMiyTT6q5AwrZQbBuPo5FStw2mq46jULp/VkrI2I5mP81da+ZdY2nuNi0JHqnAsXYb nCNKXCaTB/N8hkFz1ZJ6BaXlj9tzCbHQ/4RlK/pJC38X/hUvhfMryOHSpF+68/zEebizBSnT2 Xmop5HdbEWKcl91rEpyYcoeHY0XK5F3NVihbciHAlOag4= > Use scope based of_node_put() cleanup to simplify code. I see opportunities to improve affected function implementations another b= it. =E2=80=A6 > +++ b/drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c =E2=80=A6 > @@ -543,18 +540,18 @@ static int starfive_dt_node_to_map(struct pinctrl_= dev *pctldev, > pins =3D devm_kcalloc(dev, npins, sizeof(*pins), GFP_KERNEL); > if (!pins) { > ret =3D -ENOMEM; > - goto put_child; > + goto free_map; > } > > pinmux =3D devm_kcalloc(dev, npins, sizeof(*pinmux), GFP_KERNEL); > if (!pinmux) { > ret =3D -ENOMEM; > - goto put_child; > + goto free_map; > } =E2=80=A6 > @@ -623,8 +620,6 @@ static int starfive_dt_node_to_map(struct pinctrl_de= v *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); =E2=80=A6 > +++ b/drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c =E2=80=A6 > @@ -175,18 +175,18 @@ static int jh7110_dt_node_to_map(struct pinctrl_de= v *pctldev, > pins =3D devm_kcalloc(dev, npins, sizeof(*pins), GFP_KERNEL); > if (!pins) { > ret =3D -ENOMEM; > - goto put_child; > + goto free_map; > } > > pinmux =3D devm_kcalloc(dev, npins, sizeof(*pinmux), GFP_KERNEL); > if (!pinmux) { > ret =3D -ENOMEM; > - goto put_child; > + goto free_map; > } =E2=80=A6 > @@ -233,8 +233,6 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev = *pctldev, > *num_maps =3D nmaps; > return 0; > > -put_child: > - of_node_put(child); > free_map: > pinctrl_utils_free_map(pctldev, map, nmaps); > mutex_unlock(&sfp->mutex); 1. Exception handling is repeated a few times also according to memory all= ocation failures. How do you think about to use a corresponding label like =E2=80=9Ce_nom= em=E2=80=9D so that another bit of duplicate source code can be avoided? https://wiki.sei.cmu.edu/confluence/display/c/MEM12-C.+Consider+using+a= +goto+chain+when+leaving+a+function+on+error+when+using+and+releasing+reso= urces 2. Will development interests grow for the usage of a statement like =E2= =80=9Cguard(mutex)(&sfp->mutex);=E2=80=9D? Regards, Markus