From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753847AbbGAXOO (ORCPT ); Wed, 1 Jul 2015 19:14:14 -0400 Received: from v094114.home.net.pl ([79.96.170.134]:51000 "HELO v094114.home.net.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1752813AbbGAXOL (ORCPT ); Wed, 1 Jul 2015 19:14:11 -0400 From: "Rafael J. Wysocki" To: Tomeu Vizoso Cc: linux-kernel@vger.kernel.org, Mark Brown , Greg Kroah-Hartman Subject: Re: [PATCH v1 07/10] device property: Add fwnode_get_next_child_node() Date: Thu, 02 Jul 2015 01:40:31 +0200 Message-ID: <1613871.h1d5f8T726@vostro.rjw.lan> User-Agent: KMail/4.11.5 (Linux/4.1.0-rc5+; KDE/4.11.5; x86_64; ; ) In-Reply-To: <1435676108-20590-8-git-send-email-tomeu.vizoso@collabora.com> References: <1435676108-20590-1-git-send-email-tomeu.vizoso@collabora.com> <1435676108-20590-8-git-send-email-tomeu.vizoso@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="utf-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tuesday, June 30, 2015 04:55:05 PM Tomeu Vizoso wrote: > So callers that have a handle to a firmware node but not any of the > devices related to it can iterate over their descendants. > > Also adds fwnode_for_each_child_node(). > > Signed-off-by: Tomeu Vizoso Looks OK to me. > --- > > drivers/base/property.c | 30 ++++++++++++++++++++++-------- > include/linux/property.h | 7 +++++++ > 2 files changed, 29 insertions(+), 8 deletions(-) > > diff --git a/drivers/base/property.c b/drivers/base/property.c > index 3280b04..92cdbb3 100644 > --- a/drivers/base/property.c > +++ b/drivers/base/property.c > @@ -466,28 +466,42 @@ int fwnode_property_read_string(struct fwnode_handle *fwnode, > EXPORT_SYMBOL_GPL(fwnode_property_read_string); > > /** > - * device_get_next_child_node - Return the next child node handle for a device > - * @dev: Device to find the next child node for. > - * @child: Handle to one of the device's child nodes or a null handle. > + * fwnode_get_next_child_node - Return the next child node handle for a fwnode > + * @fwnode: Firmware node to find the next child node for. > + * @child: Handle to one of the firmware node's child nodes or a null handle. > */ > -struct fwnode_handle *device_get_next_child_node(struct device *dev, > +struct fwnode_handle *fwnode_get_next_child_node(struct fwnode_handle *fwnode, > struct fwnode_handle *child) > { > - if (IS_ENABLED(CONFIG_OF) && dev->of_node) { > + if (is_of_node(fwnode)) { > struct device_node *node; > > - node = of_get_next_available_child(dev->of_node, to_of_node(child)); > + node = of_get_next_available_child(to_of_node(fwnode), > + to_of_node(child)); > if (node) > return &node->fwnode; > - } else if (IS_ENABLED(CONFIG_ACPI)) { > + } else if (is_acpi_node(fwnode)) { > struct acpi_device *node; > > - node = acpi_get_next_child(dev, to_acpi_node(child)); > + node = acpi_dev_get_next_child(to_acpi_node(fwnode), > + to_acpi_node(child)); > if (node) > return acpi_fwnode_handle(node); > } > return NULL; > } > +EXPORT_SYMBOL_GPL(fwnode_get_next_child_node); > + > +/** > + * device_get_next_child_node - Return the next child node handle for a device > + * @dev: Device to find the next child node for. > + * @child: Handle to one of the device's child nodes or a null handle. > + */ > +struct fwnode_handle *device_get_next_child_node(struct device *dev, > + struct fwnode_handle *child) > +{ > + return fwnode_get_next_child_node(dev->fwnode, child); > +} > EXPORT_SYMBOL_GPL(device_get_next_child_node); > > /** > diff --git a/include/linux/property.h b/include/linux/property.h > index 020a53c..cfd1eb2 100644 > --- a/include/linux/property.h > +++ b/include/linux/property.h > @@ -63,6 +63,9 @@ int fwnode_property_read_string(struct fwnode_handle *fwnode, > struct fwnode_handle *device_get_next_child_node(struct device *dev, > struct fwnode_handle *child); > > +struct fwnode_handle *fwnode_get_next_child_node(struct fwnode_handle *fwnode, > + struct fwnode_handle *child); > + > struct fwnode_handle *fwnode_get_parent(struct fwnode_handle *fwnode); > > const char *fwnode_get_name(struct fwnode_handle *fwnode); > @@ -71,6 +74,10 @@ const char *fwnode_get_name(struct fwnode_handle *fwnode); > for (child = device_get_next_child_node(dev, NULL); child; \ > child = device_get_next_child_node(dev, child)) > > +#define fwnode_for_each_child_node(fwnode, child) \ > + for (child = fwnode_get_next_child_node(fwnode, NULL); child; \ > + child = fwnode_get_next_child_node(fwnode, child)) > + > void fwnode_handle_put(struct fwnode_handle *fwnode); > > unsigned int device_get_child_node_count(struct device *dev); > -- I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.