Received: by 2002:a05:7412:9c07:b0:fa:6e18:a558 with SMTP id lr7csp768342rdb; Sun, 28 Jan 2024 08:07:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IEYmIMgaheH+bL6uKrFJTSUtzFGHqSnrj8qD2GgtAjyzCpZz1qRptIJgWfSAxjxoPDqeE9b X-Received: by 2002:a05:622a:452:b0:42a:8723:6bc8 with SMTP id o18-20020a05622a045200b0042a87236bc8mr4087531qtx.90.1706458028675; Sun, 28 Jan 2024 08:07:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706458028; cv=pass; d=google.com; s=arc-20160816; b=E+S3JRx5JfAXAp42C7DSF3wnPcm4eHNJwYn3bnVw3U5k78FC3tt0YaxmhG46Aimh2E 0+5Gkvbw9sXtjJFJmtJVVyhhh6KbfSCEoGylsEr7YFc5Xxab4k4u9gpKvt1LZiTCtygn 4Q3I8LLoQ+JeJGLf2tVBJSmfS//Qe2VR2eiGPmmQas+jxjVVnS4QcqCn/6RjRXslDgjP SKMVQutAV0E6VMFQJXUgKCBE5V57iX4dSu8lc65H5RklaJ8S5Bazqj+tNZ9ShBFsNQF7 st6/FLERL35zvLevP79794T3N5pWjxO+Gz+wU6oF4m/ZD55y8OoVaOgaDQHE9rDF89Yg 7BgQ== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41679-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id x10-20020a05622a000a00b0042a8618d999si4859730qtw.648.2024.01.28.08.07.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 08:07:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-41679-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41679-linux.lists.archive=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 700291C217B6 for ; Sun, 28 Jan 2024 16:07:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 781112EB0A; Sun, 28 Jan 2024 16:06:17 +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 To: linux-iio@vger.kernel.org, Rob Herring , Frank Rowand , linux-kernel@vger.kernel.org Cc: Julia Lawall , Nicolas Palix , Sumera Priyadarsini , "Rafael J . Wysocki" , Len Brown , linux-acpi@vger.kernel.org, Andy Shevchenko , Greg Kroah-Hartman , =?UTF-8?q?Nuno=20S=C3=A1?= , Jonathan Cameron 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: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Jonathan Cameron A simple example of the utility of this autocleanup approach to handling of_node_put() Signed-off-by: Jonathan Cameron --- 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) -- 2.43.0