Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp994733lqm; Thu, 2 May 2024 01:56:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX4t69wPixH7EVDX40UACZRrFXhKht1/XfOiTIdTd1y/SYjo0nhlmk5lx8QUXsgcilDJXDbGBWbxE6pBGdFIq1jYkb1vfkwMAv4c9ThJg== X-Google-Smtp-Source: AGHT+IHjqf7mOlZsmREqcI326AWFzdFU6SKg/LVZ3fn6YJCxYhKPr4ZLEWjaDbMS02FV9nIA3RBd X-Received: by 2002:a05:6871:6ac:b0:23c:ca14:bdd with SMTP id l44-20020a05687106ac00b0023cca140bddmr6090094oao.47.1714640162855; Thu, 02 May 2024 01:56:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714640162; cv=pass; d=google.com; s=arc-20160816; b=XAHX+mWWzX7w9YdhVJnOuqr2Fq0HC1tZcXxoj52IrDU86RBK9tYoEkIkgM1pHwVf2d Zxi4EJeE3Q+/DDabBC/pGB66Ykl1uSj7DqS6+43PdqJc/WfDQz8Zwx112kEHNrrXoHv5 rA6A8z9hK3kRuKF8QKLb6ufdtOnmbRNrn6VbAO76UPhPKpzpRaFQ8RagE32cQvyYhB0m pkDlgR0YGv+prKm5mG9TPBYF3UUImIZ/1xxn8tFY6MArYqYU1fHfYKOh1zQusWeoboAr S9InBMTxXmrhVrkAp1y96TqAAMOd8rmqF4NIGCC40yPigWTcp0VFRbRKWNBteU2rNFP1 suhA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=/1qq9S2aGRtwilUT9y/lJAq9N983piKfJAV7Zk6wN1M=; fh=/tPJ0QN90+Rf77dLXT9/yAVG4fd6fZBcP7gTg2sM47k=; b=PdmVWDAuwOlof8eO4ey6DCLQe+cNN5DOF6sRnItQzUr4GiYel0n7Cfo0muDWWXe9Jr N4m9jtFa+7u/YzsrXYNRsKTgfFsgODItZaWKfPVR8umDA1uVZY6nrFn9FbRmh7/cwsu/ LyUw5D0MTrARErtFV1wpEZ574fYvhiO13hTMLWNz3SBv3qGbb56LwBMvLsfymfDMVhfa E2w6ML3mUqbyJ0i9jR4tKrFDKRglvmeyWiOjVkHmI+yeaYMK/sSYJW8G4u1DBDl0x9g/ kALg4sOV1IZaQZZcptMFrKNRgzyEMk4K9s7UGfQBEOK6obBgHvR/nuF9aQ2eDTZCJT88 LspQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=T27ZpsYG; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-166160-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166160-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id x3-20020aa79a83000000b006ed0c9751d3si638475pfi.324.2024.05.02.01.56.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 01:56:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-166160-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=T27ZpsYG; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-166160-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166160-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 633ED282BA9 for ; Thu, 2 May 2024 08:55:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 90A3747F51; Thu, 2 May 2024 08:55:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="T27ZpsYG" Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 491C353362; Thu, 2 May 2024 08:55:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714640127; cv=none; b=Tcx+8xBk8Tf0qR412AxVfMvt1Ib8vm6QWi72hX4bWCQLyer+6G3mIzIXil9qZCFF7IkbW7gZz/4fqbqqNcZdH3WUFRVJb2b/F2UDpcKF9vIJ03//l2TMEOAJg5rOx2EI+Bzaq8crco7VUtfbLrDjQXJ4nl1jx08JxgpZxYho9u4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714640127; c=relaxed/simple; bh=Yg56ikL/SLLyAKrOTSpxjb8Cuea3ldNSUoH4sMs7lUY=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=Rj2kvHKi+SH8JZFvEePmJAl9fFjJljKLjl7zyWuCf8NlSkb+knt5/T0T0JODx6xRebYZrnjt3voZ76GB2uxWyiL3sk3bG1YbEsyQ1D/AG3+qvwf83KGx1E6n7RL24+6CP8HuH0rIw/YJYAaq4v8Tjx1FMkyqLEzzFp91ZaE+duY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=T27ZpsYG; arc=none smtp.client-ip=209.85.216.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-f52.google.com with SMTP id 98e67ed59e1d1-2b2769f017aso2137171a91.3; Thu, 02 May 2024 01:55:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714640125; x=1715244925; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=/1qq9S2aGRtwilUT9y/lJAq9N983piKfJAV7Zk6wN1M=; b=T27ZpsYGSC7AbRT+wZE/mkfPjogsK6azZcYHQPSVZKANx6/oKrXKY+ciWtjhu5Nj7P o5Y/N46pZAaxK2KAiByFLMsvFIWDjyt7a/tkqg7ofoW0GqSXN4l0bKhwK0+x3URbURuw 9SarYhRl6QaV066W1juPTjleDk0EHG9bGvb0wjLufx5o75suZnRm2KLq8+xnaakHKxNb EDIR7dBGnPJI1nsvFSbCzSDv1jWITySGTtp6/JV7PmLNY0U0DdQUwEnpL0lMARc3czaE DTRtiWV2IXDfGaLOgmFqq+bY3dwvJXmkoLxXjAw9NJDM8+P0n/3yZKvH+mvaXkSH1CTn 9Z1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714640125; x=1715244925; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/1qq9S2aGRtwilUT9y/lJAq9N983piKfJAV7Zk6wN1M=; b=ResGPgoYyEIOCP/KivnxakmQAiydH79flPtqRxn5niNqs/JivK/CnuDp+olgXYT1XF 6Vpx5WI+lqTgt9aX10hadRHLAwt0GVLImh39mMe6N3oFTZ+Y0wKJsdvo4WbJAVobE1F4 G/S+C/TRg0j/XpkZMJ5utc2XDJ4uGBzYLrG2EN30zLBX0edCmsHNu6X3IAIIybXCGkbl WAWOkJRyBaeqvg6qcitx/IorQkVyrNynAv16hDMQgqQmcXUW6K9Q0H3lx1vXje1Rh4Uv YmtQXf7sYtLtCDCgJmIX7nbbuMfChZhUr9kGqqYmHNXrPlf3SB8vxfJtzHiufkc+MYTc D41Q== X-Forwarded-Encrypted: i=1; AJvYcCV+JLEC6UwcoRlSXyc0YATCtm4tN/1llRHi8Ohlu79ReX9nMn8VuKQxdCoNB4JWzJI8jJSCEkcLoDJbX+5SHXT8KF7d5ylJOAVEA2L2nvK3CIYms1W5V2iUIDFPTScnk7agVqL/9xWy3JBtHo+W7XdgkjASSl9dY4LVDsIj3/3lnfvci4a52g== X-Gm-Message-State: AOJu0Ywzntgfqq0UjMpQg9bHcKK0ivoGDL/0qy6JTyyg5n5EueoGfftQ D+jViVQNWGUn9dpAbYWcrsNg5BRJKyG1DNet0F6KdzkAzZV1LmkUIE9yqp4Pe4UMV4KqF1iOJne HedyzM/HNBrZSNwec8klCWI4ds/8= X-Received: by 2002:a17:90a:e68b:b0:2b0:8497:1c57 with SMTP id s11-20020a17090ae68b00b002b084971c57mr4710346pjy.27.1714640125591; Thu, 02 May 2024 01:55:25 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240501084110.4165-2-shresthprasad7@gmail.com> <01cbcdf5-8a7a-4b47-a2aa-05c041e3cab2@kernel.org> In-Reply-To: <01cbcdf5-8a7a-4b47-a2aa-05c041e3cab2@kernel.org> From: Shresth Prasad Date: Thu, 2 May 2024 14:25:14 +0530 Message-ID: Subject: Re: [PATCH v2][next] tty: sunsu: Simplify device_node cleanup by using __free To: Jiri Slaby Cc: davem@davemloft.net, gregkh@linuxfoundation.org, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, javier.carrasco.cruz@gmail.com, skhan@linuxfoundation.org, Julia Lawall Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, May 2, 2024 at 1:26=E2=80=AFPM Jiri Slaby wr= ote: > > On 01. 05. 24, 10:41, Shresth Prasad wrote: > > Add `__free` function attribute to `ap` and `match` pointer > > initialisations which ensure that the pointers are freed as soon as the= y > > go out of scope, thus removing the need to manually free them using > > `of_node_put`. > > > > This also removes the need for the `goto` statement and the `rc` > > variable. > > > > Tested using a qemu x86_64 virtual machine. > > > > Suggested-by: Julia Lawall > > Signed-off-by: Shresth Prasad > > --- > > Changes in v2: > > - Specify how the patch was tested > > > > drivers/tty/serial/sunsu.c | 37 +++++++++++-------------------------- > > 1 file changed, 11 insertions(+), 26 deletions(-) > > Nice cleanup. Thanks :) > > > --- a/drivers/tty/serial/sunsu.c > > +++ b/drivers/tty/serial/sunsu.c > > @@ -1382,44 +1382,29 @@ static inline struct console *SUNSU_CONSOLE(voi= d) > > > > static enum su_type su_get_type(struct device_node *dp) > > { > > - struct device_node *ap =3D of_find_node_by_path("/aliases"); > > - enum su_type rc =3D SU_PORT_PORT; > > + struct device_node *ap __free(device_node) =3D > > + of_find_node_by_path("/aliases"); > > If we used c++, that would be even nicer; like: > Destroyer ap(of_find_node_by_path("/aliases")); > > But we don't :P. OTOH. can't we achieve that with macro-fu and typeof() > magic? Perhaps not really exactly the above, but something like > Destroyer(ap, of_find_node_by_path("/aliases")); > maybe? Hmm, a macro like that could probably be written but it's more convenient to use the GCC attribute like in the current implementation, IMO. Jonathan Corbert, who introduced this, wrote about it here: https://lwn.net/Articles/934679/ Regards, Shresth