Message ID | 20240128160542.178315-4-jic23@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-41679-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp113697dyb; Sun, 28 Jan 2024 08:07:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IHcoobHD9UE3zgVm39oAyuGpnjjjq3GFDHhHedauyNcvoIEaNbEi4CAVHzX/PGJfv5FooZQ X-Received: by 2002:a05:6a20:4f1a:b0:19c:8fcf:97ca with SMTP id gi26-20020a056a204f1a00b0019c8fcf97camr1063519pzb.60.1706458079597; Sun, 28 Jan 2024 08:07:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706458079; cv=pass; d=google.com; s=arc-20160816; b=iaK0RpCOAKGcSFIs+AC8WRv1wrfcICghyNJ0/cbEDv2kwyjuroZgpPmW8LKUQsjkeJ iddxdZxR3mklNqx9Ryp0abAOzwuPtCf60Vs8VacLu7GmmBorjdFC4V1tBDcKBmi/nGqT 2IvF9e4EBelYKNq5O4ERrQlwhfA929xBA0lClKrEUlvIiYejDmv9O68mTb3qkVpDM+oT FJVJn1ZlKz/5dJZ90l7tOHz0QpMTp8T3VgeH7D0mSrxgJMh0CjJUerONWMSkVDEUbBRr RfJju9d7WTnIJyQYJQyv+0Zm9Ow6r3wQ0viJafXyTJCtDgVx2zRvJwJpz5HUDNLW6/Ft AaYg== 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=4Yo8UwhIAq4siYP/p423y2sZ0m6aCPJHiDDsaQqXCP4=; fh=QZniyVMMS+qc7OJnE11H0+VIi5BgZHbLL5e39gUA1jg=; b=apx8tOhp+4fyx06xXv3cYSSRAinvwlsLl171y9mMlRdAulMOBzaa84mIMGSBdctrZT Dp+KOcy09ZJxaHu4stG8IeIwcKqn18cPv8jtwUpne6eGML5AynZkeif09RvdVtgKvW6a pgLl3eQjid2/G4IeESCF9J8HXMFixuUD6tLgyITYb/Bz6ebRpKBDGiXtQDBtfgKGKMPm d1eYeo4Srpk1ROXji21gw+U1bpRV/3Qbzld/Q+wAGkn+EfOfaPSMdESHbCdW7E9AEKLa 4HzXTB1+xlEr0115qOp4W+ZKaLESI1CfAx7G4/WQhW4bhApodImk14cDnuLnBGA3S3yi L8pw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BThAZpoj; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-41679-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41679-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id l187-20020a6325c4000000b005d5aa5aad96si4206557pgl.539.2024.01.28.08.07.59 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 08:07:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-41679-ouuuleilei=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=@kernel.org header.s=k20201202 header.b=BThAZpoj; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-41679-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41679-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 DB2D8281A0C for <ouuuleilei@gmail.com>; Sun, 28 Jan 2024 16:07:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 548FD31A81; Sun, 28 Jan 2024 16:06:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BThAZpoj" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 98F7F2EB1D; Sun, 28 Jan 2024 16:06:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706457976; cv=none; b=jZv8d6tAm1eeznrd/QFU5y2+u8Ha2/5rtOnoXlUCymcjM9VIpFCSB/OENeOtcsFf8F34nC6iPb+dVUCi1x1B/cVqI4s9gKWM3EmBxKNvW7JqIAaqUj4WUoPpETk2YT52B0gC7pipU65ke9T7lyc8cp4rqYOx9rrjWpAAQfSJGKM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706457976; c=relaxed/simple; bh=tUG4O+PgRfdAjKLE8Z/uNA5hf36Y7t+Ym1/UMNDsPG8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Lx9M6dpqQf0KrFZDD01k5/l7qDzA+Xj0ekaDiUCSUyA0VUlSUSLcviG0Aho9vyAGS4qA9JBb7UT0vlZdfaZn/Whs2qptOpHLGqrN0++np5f7eseVI1e8gxQkmLXbaRcbKGvVeM0FkA8UJtgaPglMQdE7uy7VL7yKrW/0tOUplZo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BThAZpoj; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B20E4C43390; Sun, 28 Jan 2024 16:06:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706457976; bh=tUG4O+PgRfdAjKLE8Z/uNA5hf36Y7t+Ym1/UMNDsPG8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BThAZpojLE/4qW5yzHzRBtAaQ7rhFO+NUqYv44ES20PUvjB5NGz6RUOcWp2AZpJEi qh6gbkaCh1mhTHsXgcs6vFa9oIhl1NsB06Eo1RZMKuqES4qwTMgF4hJiAXNNX17XBG /FwgagQbrKgDiZaSaWoh5tsP+QZrOF+PssTTauB1B3OpK1a46p64iYEx+9Mv5BA0dp G4kV060SGIsaS6iCxRHsIPpPDahgWoLz9ro9uK5yiWO/NT22nOlDSabvhRobvlUrKm op9U9XtMFY79DF6z+ETw+paZ9C435G9B4tLCHCIcUB9HaAEEx4qo4edkoX2GrHqrPV gTQ5BaBELC9Xw== From: Jonathan Cameron <jic23@kernel.org> To: linux-iio@vger.kernel.org, Rob Herring <robh@kernel.org>, Frank Rowand <frowand.list@gmail.com>, linux-kernel@vger.kernel.org Cc: Julia Lawall <Julia.Lawall@inria.fr>, Nicolas Palix <nicolas.palix@imag.fr>, Sumera Priyadarsini <sylphrenadin@gmail.com>, "Rafael J . Wysocki" <rafael@kernel.org>, Len Brown <lenb@kernel.org>, linux-acpi@vger.kernel.org, Andy Shevchenko <andriy.shevchenko@linux.intel.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, =?utf-8?q?Nuno_S=C3=A1?= <nuno.sa@analog.com>, Jonathan Cameron <Jonathan.Cameron@huawei.com> Subject: [RFC PATCH 3/5] of: unittest: Use for_each_child_of_node_scoped() Date: Sun, 28 Jan 2024 16:05:40 +0000 Message-ID: <20240128160542.178315-4-jic23@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240128160542.178315-1-jic23@kernel.org> References: <20240128160542.178315-1-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789350987254862606 X-GMAIL-MSGID: 1789350987254862606 |
Series |
of: automate of_node_put() - new approach to loops.
|
|
Commit Message
Jonathan Cameron
Jan. 28, 2024, 4:05 p.m. UTC
From: Jonathan Cameron <Jonathan.Cameron@huawei.com> A simple example of the utility of this autocleanup approach to handling of_node_put() Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> --- drivers/of/unittest.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index cfd60e35a899..d353327767b3 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -233,27 +233,22 @@ static void __init of_unittest_dynamic(void) static int __init of_unittest_check_node_linkage(struct device_node *np) { - struct device_node *child; int count = 0, rc; - for_each_child_of_node(np, child) { + for_each_child_of_node_scoped(np, child) { if (child->parent != np) { pr_err("Child node %pOFn links to wrong parent %pOFn\n", child, np); - rc = -EINVAL; - goto put_child; + return -EINVAL; } rc = of_unittest_check_node_linkage(child); if (rc < 0) - goto put_child; + return rc; count += rc; } return count + 1; -put_child: - of_node_put(child); - return rc; } static void __init of_unittest_check_tree_linkage(void)