From mboxrd@z Thu Jan 1 00:00:00 1970 From: Furquan Shaikh Subject: [PATCH 3/7] device property: introduce fwnode_for_each_child() Date: Tue, 24 Jan 2017 16:06:37 -0800 Message-ID: <20170125000641.25520-4-furquan@chromium.org> References: <20170125000641.25520-1-furquan@chromium.org> Return-path: In-Reply-To: <20170125000641.25520-1-furquan@chromium.org> Sender: linux-gpio-owner@vger.kernel.org To: "Rafael J . Wysocki" , Mark Brown Cc: Liam Girdwood , Tony Lindgren , Dmitry Torokhov , Len Brown , Greg Kroah-Hartman , Lorenzo Pieralisi , Hanjun Guo , Will Deacon , Rob Herring , Sathyanarayana Nujella , Heikki Krogerus , Adam Thomson , Linus Walleij , Alexandre Courbot , linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, Dmitry Torokhov , Furquan Shaikh List-Id: linux-acpi@vger.kernel.org From: Dmitry Torokhov Generic code, that wishes to work with ACPI, device tree, and pset properties needs iterator that can work with fwnode_handle. Signed-off-by: Dmitry Torokhov Signed-off-by: Furquan Shaikh --- drivers/base/property.c | 33 +++++++++++++++++++++++---------- include/linux/fwnode.h | 7 +++++++ 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/drivers/base/property.c b/drivers/base/property.c index f2f8220534c4..fbb05a4a7595 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -867,6 +867,28 @@ int device_add_properties(struct device *dev, struct property_entry *properties) EXPORT_SYMBOL_GPL(device_add_properties); /** + * fwnode_get_next_child_node - Return the next child node handle for a device + * @node: Node to find the next child node for. + * @child: Handle to one of the device's child nodes or a null handle. + */ +struct fwnode_handle *fwnode_get_next_child_node(struct fwnode_handle *node, + struct fwnode_handle *child) +{ + if (IS_ENABLED(CONFIG_OF) && is_of_node(node)) { + struct device_node *np; + + np = of_get_next_available_child(to_of_node(node), + to_of_node(child)); + if (np) + return &np->fwnode; + } else if (IS_ENABLED(CONFIG_ACPI) && is_acpi_node(node)) { + return acpi_get_next_subnode(node, child); + } + 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. @@ -874,16 +896,7 @@ EXPORT_SYMBOL_GPL(device_add_properties); struct fwnode_handle *device_get_next_child_node(struct device *dev, struct fwnode_handle *child) { - if (IS_ENABLED(CONFIG_OF) && dev->of_node) { - struct device_node *node; - - node = of_get_next_available_child(dev->of_node, to_of_node(child)); - if (node) - return &node->fwnode; - } else if (IS_ENABLED(CONFIG_ACPI)) { - return acpi_get_next_subnode(dev->fwnode, child); - } - return NULL; + return fwnode_get_next_child_node(dev_fwnode(dev), child); } EXPORT_SYMBOL_GPL(device_get_next_child_node); diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h index 8bd28ce6d76e..b4efe2a088ae 100644 --- a/include/linux/fwnode.h +++ b/include/linux/fwnode.h @@ -27,4 +27,11 @@ struct fwnode_handle { struct fwnode_handle *secondary; }; +struct fwnode_handle *fwnode_get_next_child_node(struct fwnode_handle *node, + struct fwnode_handle *child); + +#define fwnode_for_each_child_node(node, child) \ + for (child = fwnode_get_next_child_node(node, NULL); child; \ + child = fwnode_get_next_child_node(node, child)) + #endif -- 2.11.0.483.g087da7b7c-goog From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751196AbdAYAHC (ORCPT ); Tue, 24 Jan 2017 19:07:02 -0500 Received: from mail-pg0-f46.google.com ([74.125.83.46]:32875 "EHLO mail-pg0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751153AbdAYAG5 (ORCPT ); Tue, 24 Jan 2017 19:06:57 -0500 From: Furquan Shaikh To: "Rafael J . Wysocki" , Mark Brown Cc: Liam Girdwood , Tony Lindgren , Dmitry Torokhov , Len Brown , Greg Kroah-Hartman , Lorenzo Pieralisi , Hanjun Guo , Will Deacon , Rob Herring , Sathyanarayana Nujella , Heikki Krogerus , Adam Thomson , Linus Walleij , Alexandre Courbot , linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, Dmitry Torokhov , Furquan Shaikh Subject: [PATCH 3/7] device property: introduce fwnode_for_each_child() Date: Tue, 24 Jan 2017 16:06:37 -0800 Message-Id: <20170125000641.25520-4-furquan@chromium.org> X-Mailer: git-send-email 2.11.0.483.g087da7b7c-goog In-Reply-To: <20170125000641.25520-1-furquan@chromium.org> References: <20170125000641.25520-1-furquan@chromium.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dmitry Torokhov Generic code, that wishes to work with ACPI, device tree, and pset properties needs iterator that can work with fwnode_handle. Signed-off-by: Dmitry Torokhov Signed-off-by: Furquan Shaikh --- drivers/base/property.c | 33 +++++++++++++++++++++++---------- include/linux/fwnode.h | 7 +++++++ 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/drivers/base/property.c b/drivers/base/property.c index f2f8220534c4..fbb05a4a7595 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -867,6 +867,28 @@ int device_add_properties(struct device *dev, struct property_entry *properties) EXPORT_SYMBOL_GPL(device_add_properties); /** + * fwnode_get_next_child_node - Return the next child node handle for a device + * @node: Node to find the next child node for. + * @child: Handle to one of the device's child nodes or a null handle. + */ +struct fwnode_handle *fwnode_get_next_child_node(struct fwnode_handle *node, + struct fwnode_handle *child) +{ + if (IS_ENABLED(CONFIG_OF) && is_of_node(node)) { + struct device_node *np; + + np = of_get_next_available_child(to_of_node(node), + to_of_node(child)); + if (np) + return &np->fwnode; + } else if (IS_ENABLED(CONFIG_ACPI) && is_acpi_node(node)) { + return acpi_get_next_subnode(node, child); + } + 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. @@ -874,16 +896,7 @@ EXPORT_SYMBOL_GPL(device_add_properties); struct fwnode_handle *device_get_next_child_node(struct device *dev, struct fwnode_handle *child) { - if (IS_ENABLED(CONFIG_OF) && dev->of_node) { - struct device_node *node; - - node = of_get_next_available_child(dev->of_node, to_of_node(child)); - if (node) - return &node->fwnode; - } else if (IS_ENABLED(CONFIG_ACPI)) { - return acpi_get_next_subnode(dev->fwnode, child); - } - return NULL; + return fwnode_get_next_child_node(dev_fwnode(dev), child); } EXPORT_SYMBOL_GPL(device_get_next_child_node); diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h index 8bd28ce6d76e..b4efe2a088ae 100644 --- a/include/linux/fwnode.h +++ b/include/linux/fwnode.h @@ -27,4 +27,11 @@ struct fwnode_handle { struct fwnode_handle *secondary; }; +struct fwnode_handle *fwnode_get_next_child_node(struct fwnode_handle *node, + struct fwnode_handle *child); + +#define fwnode_for_each_child_node(node, child) \ + for (child = fwnode_get_next_child_node(node, NULL); child; \ + child = fwnode_get_next_child_node(node, child)) + #endif -- 2.11.0.483.g087da7b7c-goog