From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Jonathan Cameron <jic23@kernel.org>,
Rob Herring <robh@kernel.org>,
Daniel Scally <djrscally@gmail.com>,
Heikki Krogerus <heikki.krogerus@linux.intel.com>,
Jean Delvare <jdelvare@suse.com>,
Guenter Roeck <linux@roeck-us.net>, Pavel Machek <pavel@ucw.cz>,
Lee Jones <lee@kernel.org>,
Marcin Wojtas <marcin.s.wojtas@gmail.com>,
Russell King <linux@armlinux.org.uk>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Andreas Kemnade <andreas@kemnade.info>,
linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-hwmon@vger.kernel.org, linux-leds@vger.kernel.org,
netdev@vger.kernel.org,
Jonathan Cameron <Jonathan.Cameron@huawei.com>
Subject: Re: [PATCH v3 1/4] device property: document device_for_each_child_node macro
Date: Mon, 5 Aug 2024 21:21:49 +0000 [thread overview]
Message-ID: <ZrFCbVdFIvgX-iXq@kekkonen.localdomain> (raw)
In-Reply-To: <20240805-device_for_each_child_node-available-v3-1-48243a4aa5c0@gmail.com>
Hi Javier,
Thanks for the patch.
On Mon, Aug 05, 2024 at 04:49:44PM +0200, Javier Carrasco wrote:
> There have been some misconceptions about this macro, which iterates
> over available child nodes from different backends.
>
> As that is not obvious by its name, some users have opted for the
> `fwnode_for_each_available_child_node()` macro instead.
> That requires an unnecessary, explicit access to the fwnode member
> of the device structure.
>
> Passing the device to `device_for_each_child_node()` is shorter,
> reflects more clearly the nature of the child nodes, and renders the
> same result.
>
> In general, `fwnode_for_each_available_child_node()` should be used
> whenever the parent node of the children to iterate over is a firmware
> node, and not the device itself.
>
> Document the `device_for_each_child node(dev, child)` macro to clarify
> its functionality.
>
> Suggested-by: Jonathan Cameron <jic23@kernel.org>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
> ---
> include/linux/property.h | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/include/linux/property.h b/include/linux/property.h
> index 61fc20e5f81f..da8f1208de38 100644
> --- a/include/linux/property.h
> +++ b/include/linux/property.h
> @@ -171,6 +171,16 @@ struct fwnode_handle *fwnode_get_next_available_child_node(
> struct fwnode_handle *device_get_next_child_node(const struct device *dev,
> struct fwnode_handle *child);
>
> +/**
> + * device_for_each_child_node - iterate over available child nodes of a device
> + * @dev: Pointer to the struct device
> + * @child: Pointer to an available child node in each loop iteration
> + *
> + * Unavailable nodes are skipped i.e. this macro is implicitly _available_.
Is it?
I think this was brought up previously but I understand there's an
available check on OF but not on ACPI, so on OF the availability-agnostic
and availability-aware variants are the same.
Both in OF and ACPI a node that's been marked not available simply isn't
there so as far as I understand, the semantics are the same. There's a
difference though: in OF every node can be tested for availability whereas
on ACPI only device nodes can (there are data nodes, too, for which the
availability test is always false as it's pointless to test them in the
first place).
So overall I guess the code is mostly ok be but the caller does need to be
careful with the differences.
> + * The reference to the child node must be dropped on early exits.
> + * See fwnode_handle_put().
> + * For a scoped version of this macro, use device_for_each_child_node_scoped().
> + */
> #define device_for_each_child_node(dev, child) \
> for (child = device_get_next_child_node(dev, NULL); child; \
> child = device_get_next_child_node(dev, child))
>
--
Kind regards,
Sakari Ailus
next prev parent reply other threads:[~2024-08-05 21:21 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-05 14:49 [PATCH v3 0/4] use device_for_each_child_node() to access device child nodes Javier Carrasco
2024-08-05 14:49 ` [PATCH v3 1/4] device property: document device_for_each_child_node macro Javier Carrasco
2024-08-05 21:21 ` Sakari Ailus [this message]
2024-08-05 14:49 ` [PATCH v3 2/4] leds: pca995x: use device_for_each_child_node() to access device child nodes Javier Carrasco
2024-08-05 16:00 ` (subset) " Lee Jones
2024-08-05 16:01 ` Lee Jones
2024-08-06 20:45 ` Javier Carrasco
2024-08-05 14:49 ` [PATCH v3 3/4] net: mvpp2: use port_count to remove ports Javier Carrasco
2024-08-05 14:49 ` [PATCH v3 4/4] net: mvpp2: use device_for_each_child_node() to access device child nodes Javier Carrasco
2024-08-07 1:10 ` [PATCH v3 0/4] " Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZrFCbVdFIvgX-iXq@kekkonen.localdomain \
--to=sakari.ailus@linux.intel.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=andreas@kemnade.info \
--cc=andriy.shevchenko@linux.intel.com \
--cc=davem@davemloft.net \
--cc=djrscally@gmail.com \
--cc=edumazet@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=javier.carrasco.cruz@gmail.com \
--cc=jdelvare@suse.com \
--cc=jic23@kernel.org \
--cc=kuba@kernel.org \
--cc=lee@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=linux@roeck-us.net \
--cc=marcin.s.wojtas@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pavel@ucw.cz \
--cc=rafael@kernel.org \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®