Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2067510rdb; Sun, 11 Feb 2024 09:44:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IFl7P0BWW1bAVjSS4CfmUByVVUseOP9295cbikbAg3/YIUH3Vw+Ews1EjRHn2LXjKgH8Y6Q X-Received: by 2002:a17:903:1104:b0:1d9:c367:2032 with SMTP id n4-20020a170903110400b001d9c3672032mr5382169plh.10.1707673447066; Sun, 11 Feb 2024 09:44:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707673447; cv=pass; d=google.com; s=arc-20160816; b=w0Abe4otJLZDo6au/X1ly62SjldwIVXesc8Nd5cFhE9ArqeZs+qKv0UlCX6r9Bdmia hwHF7cQFyJdeJtzY0UMg3tMOtLnJnvf9LPtDuSp6V//8B4ojVTmEL8SHV3IHphRPBeEj DQvVoM6a/Td4/v96ZEZCRVqDcbF2oBQ5Q01iaGABTRBMafXIgCePI4XqxmvFnYEPpomH Kvl4HkzJacD+TnIx/WEU7WQu3/QbwUFcM0XdmphyBKMMBZWW0qYz6fLgJh/aDic43Aj4 Z4ZRYoSuAvbZQpYp8CWO6LKFZYRtAFCV8eIzHTbGMDvXsQaGcf2oIL5clmVV8Mmw+8a0 rnLw== 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=sJPCWKBSX+6lnC9wnsLv1sD9T4P0iwOH5PegSMELXLc=; fh=gNaErO+iILO88RWsTtm138ChEIDWKU3Qg3g6yHzWKnc=; b=TQUAB5DzipN9aUY7guv5CQsAQJ6ofSZ87Mns5tz9+VjgrgcxCZ24YjHXUEjdb1jGgn Bro2YkxNEWYC6s+TKjH45j8fo5gFgeb8VEC44GtALzlXfI4ngAU/lm+5AGeBpETb6ZXf jwY3XDtXV0zqyrkMCddp6N8ePwfYiOE/KIszj+7GA+BbVzQsL09MBCo1DjGQFRO0RkCG rrmUI1y891tDGWEwTIMN0lc8JoKksJGDr0x22BPlzisX0am2i8jchp6fFKKCkzpiYCBN aAV/74BAU5V40NluHQNSZH2fDLhoRr0PcT1cnSndcEaBpz3IPQF9M28ufycGqiyg+zuC 4Cyw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FD5NkYJL; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-60888-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60888-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCUdbHaR/hoskrw+GCxQ3qx4RRoYfMIl1Jb1KAo1NB1RiW3+l2Few6Oxpf1o1o3bJBG4Xu0V7iTuus199pO1riZuPaldB/bnIxLyqPzlFg== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id c4-20020a170902d90400b001d944e92bebsi4837405plz.326.2024.02.11.09.44.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 09:44:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60888-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=@kernel.org header.s=k20201202 header.b=FD5NkYJL; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-60888-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60888-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id B3495283727 for ; Sun, 11 Feb 2024 17:44:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A23885D8FE; Sun, 11 Feb 2024 17:43:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FD5NkYJL" 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 B39EB5D758; Sun, 11 Feb 2024 17:43:20 +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=1707673400; cv=none; b=hurKDcSI22D0231wS5HSK+5kDAjoZ40TRigMr8+KtsODHP+dDaSTpprQuhGA/jpCC1+jk9cVHaovW48BEZrbBTTuA4ooCWh+ih1HOZwWW0GsziZzwDs1RjpcbxsYAt4ThTBLxuDH5dcRslGgDdBNsjRP2bKhZTHBf50BORH7wdI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707673400; c=relaxed/simple; bh=ipeQZ+LZe5XilwqeMPmR4IQ68fkOcifsuM6YVshivis=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c2cRYyCxZsyZmfqXCOWPoJdBk78cIFaZ5jxnqELW+s94utl2j2RmacSYzqS5mVRvmZ2fziNOTzfYvLS6gAVp2uuNRUKbyfb5ExJ5rDIQa/VarkENwcH0CGR18Vz5kek0J2ggfR6ZzgDzZv0//VTQK4qKJtXEc6LuVO1bTt11Rdc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FD5NkYJL; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8237C43390; Sun, 11 Feb 2024 17:43:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707673400; bh=ipeQZ+LZe5XilwqeMPmR4IQ68fkOcifsuM6YVshivis=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FD5NkYJLGeomQEeIp1Xv63ealhPiBYhblKKG2irQbuUnY5MqOtb+XQ6EDfMV+QoCq +5gMoE+NXCpbH3s4hJZIS05gGzXh4KNxFjbEKvNzU/dk1RAvTzB4bNipOSwarkKuxx 1qrTBV2mtkcwzPKWjp/6TwLzWQbYYlreZ9905gHqcwvAPkDZj/+RDzDHOrvG42MS2Y qrzSrIuBCuKFpjiVl7r9PJWHRo/+fnDGjXih+y18F0cBu1MIqAlUwgqKpwwrqRgs5O DajTQzngXbAS4u8OT93WT67f7bx0IVK7ki8ixn3md3KFKsaxmwgR9FToBZce1bj+7d aiRH7jjfLlPPw== From: Jonathan Cameron To: linux-iio@vger.kernel.org, Rob Herring , Frank Rowand , linux-kernel@vger.kernel.org, Julia Lawall Cc: Peter Zijlstra , 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: [PATCH 3/8] of: unittest: Use for_each_child_of_node_scoped() Date: Sun, 11 Feb 2024 17:42:31 +0000 Message-ID: <20240211174237.182947-4-jic23@kernel.org> X-Mailer: git-send-email 2.43.1 In-Reply-To: <20240211174237.182947-1-jic23@kernel.org> References: <20240211174237.182947-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(). In this particular case some of the nodes needed for the test are not available and the _available_ version would cause them to be skipped resulting in a test failure. 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.1