Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1373608lqm; Thu, 2 May 2024 12:43:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUMfamT4Bh5UojlDkFiCdLs8yzlsWoTJICQCAnmDkjBjsdvtRavMWAAkbac6UIsI577ZljXr8uBajtdtP8iegxib6Dwpg5HLlstmEnTxA== X-Google-Smtp-Source: AGHT+IFcOcP3+Wtk7toJGl5zxVSjgUCawg+NK7hZrMUkElO+qBtn+RKzx4Criwmiww5Ur3NqiL5b X-Received: by 2002:a05:6a20:12cb:b0:1a7:4f8b:6439 with SMTP id v11-20020a056a2012cb00b001a74f8b6439mr896201pzg.34.1714678998166; Thu, 02 May 2024 12:43:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714678998; cv=pass; d=google.com; s=arc-20160816; b=TjFu19rVKNYImZewpJDbCHYqA9tIjTZzfI9hExWWgNmx1FtTQDTC8BmEAMTX3Uf9LP //Sa5oDc8OO0EdF0NLwVKBHSs2Op2FSFnim8fwHaWv+fsZLMdmhYdtZy+h4AHicxB+Aa NrS4+f5MjA5lcKyjkrDIoN87+BxImmXQ5Z+IH7BzIn7NxB+oaTOz9A3QdqC0FOpiz4AW 00Ib0x5hwrhD+J1iXw5q4f3JReZz6FZVs/kxO52xVJ/uB8fxjQPLr94zgQnAKOzS0StD +MwIjV8j/xSGSmSZk93F5lUh0SzySEgY4OvoS192xrHdRM1TisXO+xXayeHwowRIXPYw nxsg== 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 :references:message-id:in-reply-to:subject:cc:to:date:from :dkim-signature; bh=pLUpOYMb+cu4z9pQk/Vj1Blu+z77LM+RxXytEX9Ml6E=; fh=T+cpLHtoK4GmKUd3793Rf5e33QL0fdydvCz7onAUT3Q=; b=oEyL+PhKaONinwDZEJ0mY3EWrFIEOGMAsd4Kc5LqgzsvjLNKBk0N7waEqGopfzS/EH uAYWEIsrMDshYcaUlNLHs34scTck0qQId3ABozGIpSxcLVV6NO5vcQsowWSAyrQBW/Rt 8eaWmu7f59mCz9VPGTVoRkYcoRUxbk/pG9O9Qd1IImA/zrM95F6ejuUEnjspJ2evSofU Xx3h4IAugn1ZxUaxXOZyGoHdaEgCcOKXwUkukPjiR7igGwj2vrY7Dt31LnSAgwI/i2Nm zHWV5CCrrGaVTO0NVIXHwiXBHbP0osfvRPSOWxWKDxk8mMezZyNFxfN2MznTOXpD2F4S sjlg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DCqaaOI4; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-166685-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166685-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id v15-20020a056a00148f00b006f2e94df727si1612062pfu.297.2024.05.02.12.43.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 12:43:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-166685-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DCqaaOI4; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-166685-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166685-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.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 53395283022 for ; Thu, 2 May 2024 16:05:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C155615D5A2; Thu, 2 May 2024 16:05:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="DCqaaOI4" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (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 46DF915359A; Thu, 2 May 2024 16:05:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714665950; cv=none; b=ethDiv3BSBuswi9vHNOFQXwdV00J6M7mIsFfE+3rqD4d8ZSsqxcQf9EaS/funz+14Cysd7tbZbqFWFcWyfsBIBLo8vrBugJws3wbaQVqCc/Hq0PntQ93jBWz7ASlNMYSPtBl9xeG/Rw/d5N57VRWHdkYMnj0KB56VGG0I+26hfQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714665950; c=relaxed/simple; bh=liNJpqZaUusEYaet5+AZ8QmE2V1rDP/SCGnddJWnXNg=; h=From:Date:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type; b=nwTnGcDCByU2EgATjK+4odkPAf7wICjLQLnj7cLCTrgVnQ1aKZsj53jci4nHtZFJWOLRfTvz7z++QHqGVN4awfma3QIssd9Cuq+WOgG/0bbX066b71jA7pN1mPVUNYLmM8QLc7Qgi2EZC7ukxSbrF7fmoBbvG8ZmcqGIO101ejs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=DCqaaOI4; arc=none smtp.client-ip=198.175.65.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714665949; x=1746201949; h=from:date:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=liNJpqZaUusEYaet5+AZ8QmE2V1rDP/SCGnddJWnXNg=; b=DCqaaOI4SxpvTEmveF/UnfOdQ7Uek6XSnLcKsxj6Jj8IitMPS+vz397J sfyj3QuJT2lQpFIEsg7i1+6Snx0aVszcoHpIGNClyD1tzOB+TLPbVLnuy 5FqUHtur/Ajf07Pk4/hGiHWNUAJVsGfMns5e4KdsfT4rJpGZr1gwFZW3R l2FH+JK40mxXVm9FXYI/+BFobwTkj/NKXoAC2qJUlIot06FmAyyYvFSf1 VYT7vMPIpTpUzWrv0rMxpgjwBxh1zDT7B/9vQltCMucwQZapODC56vNBW SamN4Jx0FCWIkA/6NdpUv0vjQOHWCGmOMVw1YJepoZZgaumza2TebnuAR Q==; X-CSE-ConnectionGUID: G9xQVcqaSA+/5yPn+P9v1A== X-CSE-MsgGUID: vNDf5q9SRlqAcGN1UdcKQg== X-IronPort-AV: E=McAfee;i="6600,9927,11062"; a="10374567" X-IronPort-AV: E=Sophos;i="6.07,247,1708416000"; d="scan'208";a="10374567" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 May 2024 09:05:17 -0700 X-CSE-ConnectionGUID: gWDa5TmKQPuG2RdMmF7q/A== X-CSE-MsgGUID: IoiQcfODT/G8bTRHDEkG9Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,247,1708416000"; d="scan'208";a="64606203" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.247.54]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 May 2024 09:05:10 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Date: Thu, 2 May 2024 19:05:03 +0300 (EEST) To: Shresth Prasad cc: davem@davemloft.net, gregkh@linuxfoundation.org, jirislaby@kernel.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 Subject: Re: [PATCH v2][next] tty: sunsu: Simplify device_node cleanup by using __free In-Reply-To: <20240501084110.4165-2-shresthprasad7@gmail.com> Message-ID: References: <20240501084110.4165-2-shresthprasad7@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII On Wed, 1 May 2024, Shresth Prasad wrote: > Add `__free` function attribute to `ap` and `match` pointer > initialisations which ensure that the pointers are freed as soon as they > 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. Eh, how can you test this with an x86_64 VM ??? config SERIAL_SUNSU tristate "Sun SU serial support" depends on SPARC && PCI -- i. > 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(-) > > diff --git a/drivers/tty/serial/sunsu.c b/drivers/tty/serial/sunsu.c > index 67a5fc70bb4b..0f463da5e7ce 100644 > --- a/drivers/tty/serial/sunsu.c > +++ b/drivers/tty/serial/sunsu.c > @@ -1382,44 +1382,29 @@ static inline struct console *SUNSU_CONSOLE(void) > > static enum su_type su_get_type(struct device_node *dp) > { > - struct device_node *ap = of_find_node_by_path("/aliases"); > - enum su_type rc = SU_PORT_PORT; > + struct device_node *ap __free(device_node) = > + of_find_node_by_path("/aliases"); > > if (ap) { > const char *keyb = of_get_property(ap, "keyboard", NULL); > const char *ms = of_get_property(ap, "mouse", NULL); > - struct device_node *match; > > if (keyb) { > - match = of_find_node_by_path(keyb); > + struct device_node *match __free(device_node) = > + of_find_node_by_path(keyb); > > - /* > - * The pointer is used as an identifier not > - * as a pointer, we can drop the refcount on > - * the of__node immediately after getting it. > - */ > - of_node_put(match); > - > - if (dp == match) { > - rc = SU_PORT_KBD; > - goto out; > - } > + if (dp == match) > + return SU_PORT_KBD; > } > if (ms) { > - match = of_find_node_by_path(ms); > + struct device_node *match __free(device_node) = > + of_find_node_by_path(ms); > > - of_node_put(match); > - > - if (dp == match) { > - rc = SU_PORT_MS; > - goto out; > - } > + if (dp == match) > + return SU_PORT_MS; > } > } > - > -out: > - of_node_put(ap); > - return rc; > + return SU_PORT_PORT; > } > > static int su_probe(struct platform_device *op) >