Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp1466618lqo; Sat, 18 May 2024 04:41:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUoLFEUAldbYS/uiHnIC0FVGPA20OmqIsomxAeyJ0h7hdMD3eyGvc7tcN8AVFJV+DLwpa6f8cPHiLqeCRCyR+Qo9bIxGhVHXbba5pdmmw== X-Google-Smtp-Source: AGHT+IEL80jHeGeBgpvmtsGYky81BIgxBami+vUSTQNd9497Tts+3NVPEpSGEJ7iQMJ7k1fs0pQY X-Received: by 2002:a05:6a21:9216:b0:1b0:25b6:a75d with SMTP id adf61e73a8af0-1b025b6a9bdmr9115388637.52.1716032509766; Sat, 18 May 2024 04:41:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716032509; cv=pass; d=google.com; s=arc-20160816; b=scEPbBswHvYNXtKwshiQJLmfUVk1gH+bamy55se5K1Edpry23azIvpr8oHxT5emN/s qBnzSDajCJZ262yy1gDOQFYEVfiOyfpDFaIuxB4FnkgdzmSTWTwH87ohsbNQaeqx463X WYP7jhG8tBpVRiyGPM3Ji6u3DeIZfjkYGDCBF57dQF1f87fn0tgWMFt1E9M7FaXKux6N jwaLI+6fmsMqAfIk37eI8D3MyMHp2mb6uhGZ5/3tVzeow847cB9EYBCTMqW5LAa+kgcy VYKBcSOeeApgQFRCDjKnl23JG1iZk/NhBLn230r+Un0BV2ARpIIe39zpCdv1WujRV7JL 2dqA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=nGZELmCIhJ0Llb0Ot0Pxzsc4Vz/WbJAcy06wKqjrN/c=; fh=UGoWGGoDRXt8Y/f+mpcg4IjCZkNg+v4EaiOAeAGE8Sc=; b=X9G63PrtSJhFSaB9TRQ/nlL529DQfsj4bnBcmtGTeXy5ElXrT2uCuye3cn8/Gwelcw h1oKn1GRBWmDAyedSQpbsMUy+/3GT7ER4ICGfd8ypbENPawPqKaAhXPT0+vSSgDQI9sR DRuBVY0ACfMrucd7BtdDYVQZgu0Nf8Lb0iqxp++oZoWHPh+wjEpt0KY09LftsGo5ggJo BS6syksKxqo2g+rLdSzF7uM0am00ju2IVAJjzu94RGxEXHa+yFX6feVITmRUTo6VpXjL GhyI6HiT/YQH3YDkOrBvRxexY0Vuy5sd4kc6fZ3xA43P243VvipCzt/R+tSB5aquCNmw Vl/A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="LQidwy/2"; 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-182835-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182835-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 d9443c01a7336-1ef0bad7ffcsi183667805ad.142.2024.05.18.04.41.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 May 2024 04:41:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-182835-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="LQidwy/2"; 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-182835-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182835-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 09AF2282B44 for ; Sat, 18 May 2024 11:41:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ADE2B2E62B; Sat, 18 May 2024 11:41:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LQidwy/2" Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (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 63C3639FC5; Sat, 18 May 2024 11:41:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716032500; cv=none; b=qWFw8Rb1ZQIslgosxd86OPTsg01xm0cXIOwmGCvwKBqcH8812lUkec/gP2V0xMl3ya5GmpiH4Odm4zzVWlU0hBsFrGi+XST/SUlTaZSNqq1huw6xLWFTOXN/8YDkvPdl11ZF3DPV34fIvUwlYJYYCSboPvewoTSCwzB/zYTueiI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716032500; c=relaxed/simple; bh=ur57ZY+2aICTIPOpezi/vJnYRMVcdjk1kendQiZu52Y=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=BwFYUJqmSKDw/W/7UylPN6lSVKKV7UsbOWpjSF7bwGMzvaL7OvAuvgcGe9wojIesP7faLJX4UWjdyhk+AacfYi8u2006kCAX0uW57md5zKRa+rx0Qrv9lhJRE1IicX+NdytQM2OCsJAY3yPbeizx7p/8y9femsZf4np/Nowvr1A= 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=LQidwy/2; arc=none smtp.client-ip=209.85.214.181 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-pl1-f181.google.com with SMTP id d9443c01a7336-1ecc23e6c9dso33170665ad.2; Sat, 18 May 2024 04:41:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716032498; x=1716637298; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=nGZELmCIhJ0Llb0Ot0Pxzsc4Vz/WbJAcy06wKqjrN/c=; b=LQidwy/20EWzDPdF5hI9iXbcDBJQwm5SQpdk+k2IteyN17Afgik0iBcz0+soW7eF7e SGKYK3oqJ9pSmjLgFIDp9B6jFFfb6umHPvpZSvFq7SAb9W2zQRGTrG1d3czCKWGgXUiB 0X6rq2/l7FbW8GxTRvEuV84QGHmpMl1vdtAWIXmFJwabRiadBkIWet8/H7AbA6rIu4NN 0URj39Qnb9mqV3fzFo8LmDdT3O3nTTy1Iq+8YdZUAOef4nzOcRM/mVb2g3Z8aNZRd1ik pEdkF29WeHZ3dETo0CmqXGrnsj/0yQqWKg+3ZEd8CN+TfITDZCpKy42Tcv1+bbSvGCne tQuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716032498; x=1716637298; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=nGZELmCIhJ0Llb0Ot0Pxzsc4Vz/WbJAcy06wKqjrN/c=; b=EW3mTrthNyJDucjW5vzGbZvW1b98NqogpiUWT1dWhS/ogw1P5jIn1z796HCl46ODJ6 xBdEYVnKr4GCP1F65j8jJu75aq7+9f3QKoGA2P5BzDa/J0DckJkLFS4lYejv3KgLa1Dc hgiXfr9KGnmTSz31HVgpnKNEkhoMKNdIlCbb77aHGgihtiF7fS9uAtfeUZKovrkFWPsK CbZeCrvHaUMvyLqYLcmpJK0mwlSPy7vXe841leVJqkwo9UGXeuS1V1OITcf+y77oyldC cUMC9xJaaGrhZgDkJoDSc5OeRbYhAwNQeJIf/qknMFRrRjAIK5lMnZ47QXMLGRb7zwFM I2lQ== X-Forwarded-Encrypted: i=1; AJvYcCW4FrpXGevclL+6/7+/DI9rRlsVYQypZdGs9GBVjE45XbsrV+aMzHLScZCAaMM+zRJmbd9uh477f71z4ll4hwEYlfkE7/MaLz4UCuoG8CbttHu/jktSV5YEjbQrkH+2DSCq2jO+wuyQYffp X-Gm-Message-State: AOJu0YxMtt93OyCek1H5/tB2hdt3YxJ3mz9aSBHW+LrQ/ubhbAy16/Uv Fz6QcZ5CsKYuHvrOJzFmitnaIN54oqjRqSlRRzkcR7Dq+P262sxQ X-Received: by 2002:a17:902:fc4f:b0:1e8:c962:4f6e with SMTP id d9443c01a7336-1ef43d27f6fmr274274915ad.20.1716032498514; Sat, 18 May 2024 04:41:38 -0700 (PDT) Received: from localhost.localdomain ([122.161.51.212]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ef0c035d8esm171800655ad.199.2024.05.18.04.41.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 May 2024 04:41:37 -0700 (PDT) From: Shresth Prasad To: davem@davemloft.net, gregkh@linuxfoundation.org, jirislaby@kernel.org Cc: sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Shresth Prasad , Julia Lawall Subject: [PATCH v3][next] tty: sunsu: Simplify device_node cleanup by using __free Date: Sat, 18 May 2024 17:10:53 +0530 Message-ID: <20240518114051.18125-3-shresthprasad7@gmail.com> X-Mailer: git-send-email 2.45.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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. Suggested-by: Julia Lawall Signed-off-by: Shresth Prasad --- Changes in v3: - Remove incorrect testing statement I've tested the patch by cross compiling it for sparc systems and booting the produced `image` file in `qemu-system-sparc`. --- 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) -- 2.44.0