Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1984825rdb; Wed, 31 Jan 2024 15:52:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IES4BoEhki3xaGPYcnglfV61WqugAFU3eYlh931XFncKuJ+LBRM4UJ8jU+Mn4Uktg1c0D37 X-Received: by 2002:a17:906:5647:b0:a35:2841:2ab7 with SMTP id v7-20020a170906564700b00a3528412ab7mr2584525ejr.39.1706745120067; Wed, 31 Jan 2024 15:52:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706745120; cv=pass; d=google.com; s=arc-20160816; b=Hpo2X2qCNpiSQU9RRvvJnls8tpN8zoJL0v4w+5cEUqpYd+dDJxn/EydMkouSE1NF5l 0KjQ4J7TsVvOehXcBGE1JbCRNB+tRS/HdfkbbftlDt1OodG9nwuYZIELifpB9llFqWwD 0KIWiybK4nMRAAwCP43P9l+2jFP7+NPVnqkjwg/YbBLC75HHHbc5rMN9Ku+U41xlNR/R tjjhL0LmAcYhWhaUroX48rfGLxafkz9TnABht40/2L9YeplmsKZHfK+2GxWL/R0UsbZW ivZPxJu4o0ZUWpIpl2yInjisNL14rGySXrXEhx8hgv3WPS8luHBEEtaxlcVEJxhmd30R Kctw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=UjHlUoy7dsFE10trV/im/xLBQUCxIjncE1oCa+LnMl0=; fh=M5yWdZXtQattsBPh/KZ2i193PlB0IYLP4VVas7wKvFY=; b=ntiBbf+1yW06e2y7ZT07I/N9Q3mvjyOPaC/j5b4l7u1JinpTfcb0ihN8ZFM8Nurf/g VXCSrKUijgqd6b0ZpWFI9bZyAbvGrCI28g7uGHPRE1l+2hVHdQuWD1qkHvSJ7MS5jngP a+zHbLltJ+3F88HoN4CHF6aitmbxuhwr8tBf+7Wr/hZfWo90zDmVOb83bU5mdlG94RRE x8Htw0QCbM7qtl+og2cqQNHbpi9bgoYrMouviWbwxsTDKeoP9G7ToeOPjrUXyho5F6G3 8Bwxl9gge7i4HilsB8isgbRmjzX6kdRUnyIZ8ZjvFrHY5t772Pr+zbw7pe7VMUFdnN28 KbWw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Pq9J7l2R; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-47394-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47394-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCXv2UPBY4a68flS7GyZva5yRjpWnBpImNpww1g4Iz/YZgPI3famOL1tPnMK5e53ZP/K+l7+OqVssgG98+i4PMgrQV+yahjGAGsNVYXVoA== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id rn10-20020a170906d92a00b00a31897c47f4si5825787ejb.1023.2024.01.31.15.52.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 15:52:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47394-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Pq9J7l2R; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-47394-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47394-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 am.mirrors.kernel.org (Postfix) with ESMTPS id CB7DE1F24031 for ; Wed, 31 Jan 2024 23:51:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7990E3A8FC; Wed, 31 Jan 2024 23:51:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Pq9J7l2R" 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 925603A8C6; Wed, 31 Jan 2024 23:51:50 +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=1706745110; cv=none; b=kwiVYVhF2AqxUEnM8Ccyt4UglsYAmHm03/qpRs5TpeYG86FMA3pT7VI6JE/5SJFs+UyjJ/rEZqnGTFoKRFx+4rlwIb4m5uHMJnEFhgHkKSJMAXwG5+RVWUPZKSPX7RSylTkiPBiwaRR5WEHWs7oE0rrqVE6Bw5fSipfIScZR++E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706745110; c=relaxed/simple; bh=bEXE9iCcPsAyP4fz4RssHiTnyheZ4ZI2rqh4iftmVgo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ovAWbCuueG8aAuR61x9ugybxoA27x+Fw2ykkMKGJJbG2hudnRKGuYH6ur77lpKgNS5JyOqf2rHVijseJDZ6jXlcusJbnFZ1ZzNNlFWz/2lceYa3lF2VeEuUG8uv4x6UAkD+x3L3ofXPVNVcQ075c7EUJFjZKk5FJTnL0MgPAbE0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Pq9J7l2R; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2106EC433F1; Wed, 31 Jan 2024 23:51:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706745110; bh=bEXE9iCcPsAyP4fz4RssHiTnyheZ4ZI2rqh4iftmVgo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Pq9J7l2Ra6F4wkK6mHCN6mfAMSgCZKw1SvtPrQcPGZ7SY/FSOB/hGJwO2nlrlYJUI zLZwlTLPSpxXPIOa+IBhSgxW+W1pTISGjrlRZLxqTUsO+6+C7zLLtbY90mMJisimS3 kWckl4YNWUBlbLqOCrWRSg+7/8R6+lefyXNREAdEubVoFsDR1OYgAvnOcAJLio3d8D 2wpPwC4CevJnMJVYwlTBahP9AN0TLV4ood4N6XgdrulDEBooz1uTBNivsWoKhNC1/h fBZlkoT5NkvQyvvrxx6ZnJ35rtdMXxpfdS3KUyVQ2CljN1JlkKuXdEiFAXCi8jYm2B CgK5OiSe0kzBw== Date: Wed, 31 Jan 2024 17:51:48 -0600 From: Rob Herring To: David Lechner Cc: Jonathan Cameron , linux-iio@vger.kernel.org, Frank Rowand , linux-kernel@vger.kernel.org, Julia Lawall , Nicolas Palix , Sumera Priyadarsini , "Rafael J . Wysocki" , Len Brown , linux-acpi@vger.kernel.org, Andy Shevchenko , Greg Kroah-Hartman , Nuno =?iso-8859-1?Q?S=E1?= , Jonathan Cameron Subject: Re: [RFC PATCH 2/5] of: Introduce for_each_child_of_node_scoped() to automate of_node_put() handling Message-ID: <20240131235148.GA2743404-robh@kernel.org> References: <20240128160542.178315-1-jic23@kernel.org> <20240128160542.178315-3-jic23@kernel.org> 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Sun, Jan 28, 2024 at 03:11:01PM -0600, David Lechner wrote: > On Sun, Jan 28, 2024 at 10:06 AM Jonathan Cameron wrote: > > > > From: Jonathan Cameron > > > > To avoid issues with out of order cleanup, or ambiguity about when the > > auto freed data is first instantiated, do it within the for loop definition. > > > > The disadvantage is that the struct device_node *child variable creation > > is not immediately obvious where this is used. > > However, in many cases, if there is another definition of > > struct device_node *child; the compiler / static analysers will notify us > > that it is unused, or uninitialized. > > > > Signed-off-by: Jonathan Cameron > > --- > > include/linux/of.h | 6 ++++++ > > 1 file changed, 6 insertions(+) > > > > diff --git a/include/linux/of.h b/include/linux/of.h > > index 50e882ee91da..f822226eac6d 100644 > > --- a/include/linux/of.h > > +++ b/include/linux/of.h > > @@ -1434,6 +1434,12 @@ static inline int of_property_read_s32(const struct device_node *np, > > for (child = of_get_next_available_child(parent, NULL); child != NULL; \ > > child = of_get_next_available_child(parent, child)) > > > > +#define for_each_child_of_node_scoped(parent, child) \ > > + for (struct device_node *child __free(device_node) = \ > > + of_get_next_child(parent, NULL); \ > > + child != NULL; \ > > + child = of_get_next_available_child(parent, child)) > > Doesn't this need to match the initializer (of_get_next_child)? > Otherwise it seems like the first node could be a disabled node but no > other disabled nodes would be included in the iteration. > > It seems like we would want two macros, one for each variation, > analogous to for_each_child_of_node() and > for_each_available_child_of_node(). Yes, but really I'd like these the other way around. 'available' should be the default as disabled should really be the same as a node not present except for a few cases where it is not. I bring it up only because if we're changing things then it is a convenient time to change this. That's really a side issue to sorting out how this new way should work. Rob