netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marcin Wojtas <mw@semihalf.com>
To: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org,
	linux-acpi@vger.kernel.org
Cc: graeme.gregory@linaro.org, davem@davemloft.net,
	linux@armlinux.org.uk, rafael.j.wysocki@intel.com,
	andrew@lunn.ch, f.fainelli@gmail.com,
	antoine.tenart@free-electrons.com,
	thomas.petazzoni@free-electrons.com,
	gregory.clement@free-electrons.com, stefanc@marvell.com,
	nadavh@marvell.com, neta@marvell.com, ard.biesheuvel@linaro.org,
	mw@semihalf.com, jaz@semihalf.com, tn@semihalf.com
Subject: [net-next: PATCH v3 4/7] device property: Allow iterating over available child fwnodes
Date: Wed, 17 Jan 2018 17:55:43 +0100	[thread overview]
Message-ID: <1516208146-4144-5-git-send-email-mw@semihalf.com> (raw)
In-Reply-To: <1516208146-4144-1-git-send-email-mw@semihalf.com>

Implement a new helper function fwnode_get_next_available_child_node(),
which enables obtaining next enabled child fwnode, which
works on a similar basis to OF's of_get_next_available_child().

This commit also introduces a macro, thanks to which it is
possible to iterate over the available fwnodes, using the
new function described above.

Signed-off-by: Marcin Wojtas <mw@semihalf.com>
---
 drivers/base/property.c  | 26 ++++++++++++++++++++
 include/linux/property.h |  6 +++++
 2 files changed, 32 insertions(+)

diff --git a/drivers/base/property.c b/drivers/base/property.c
index adb3893..2343906 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -998,6 +998,32 @@ fwnode_get_next_child_node(const struct fwnode_handle *fwnode,
 EXPORT_SYMBOL_GPL(fwnode_get_next_child_node);
 
 /**
+ * fwnode_get_next_available_child_node - Return the next
+ * available child node handle for a node
+ * @fwnode: Firmware node to find the next child node for.
+ * @child: Handle to one of the node's child nodes or a %NULL handle.
+ */
+struct fwnode_handle *
+fwnode_get_next_available_child_node(const struct fwnode_handle *fwnode,
+				     struct fwnode_handle *child)
+{
+	struct fwnode_handle *next_child = child;
+
+	if (!fwnode)
+		return NULL;
+
+	do {
+		next_child = fwnode_get_next_child_node(fwnode, next_child);
+
+		if (!next_child || fwnode_device_is_available(next_child))
+			break;
+	} while (next_child);
+
+	return next_child;
+}
+EXPORT_SYMBOL_GPL(fwnode_get_next_available_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.
diff --git a/include/linux/property.h b/include/linux/property.h
index e05889f..5b0563a 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -83,11 +83,17 @@ struct fwnode_handle *fwnode_get_next_parent(
 	struct fwnode_handle *fwnode);
 struct fwnode_handle *fwnode_get_next_child_node(
 	const struct fwnode_handle *fwnode, struct fwnode_handle *child);
+struct fwnode_handle *fwnode_get_next_available_child_node(
+	const struct fwnode_handle *fwnode, struct fwnode_handle *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))
 
+#define fwnode_for_each_available_child_node(fwnode, child)		       \
+	for (child = fwnode_get_next_available_child_node(fwnode, NULL); child;\
+	     child = fwnode_get_next_available_child_node(fwnode, child))
+
 struct fwnode_handle *device_get_next_child_node(
 	struct device *dev, struct fwnode_handle *child);
 
-- 
2.7.4

  parent reply	other threads:[~2018-01-17 16:55 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-17 16:55 [net-next: PATCH v3 0/7] Armada 7k/8k PP2 ACPI support Marcin Wojtas
2018-01-17 16:55 ` [net-next: PATCH v3 1/7] device property: Introduce fwnode_get_mac_address() Marcin Wojtas
2018-01-17 16:55 ` [net-next: PATCH v3 2/7] device property: Introduce fwnode_get_phy_mode() Marcin Wojtas
2018-01-17 16:55 ` [net-next: PATCH v3 3/7] device property: Introduce fwnode_irq_get() Marcin Wojtas
2018-01-17 16:55 ` Marcin Wojtas [this message]
2018-01-17 16:55 ` [net-next: PATCH v3 5/7] net: mvpp2: simplify maintaining enabled ports' list Marcin Wojtas
2018-01-17 16:55 ` [net-next: PATCH v3 6/7] net: mvpp2: use device_*/fwnode_* APIs instead of of_* Marcin Wojtas
2018-01-17 16:55 ` [net-next: PATCH v3 7/7] net: mvpp2: enable ACPI support in the driver Marcin Wojtas
2018-01-17 18:11 ` [net-next: PATCH v3 0/7] Armada 7k/8k PP2 ACPI support Andrew Lunn
2018-01-17 19:03   ` Marcin Wojtas
2018-01-17 20:20 ` Andrew Lunn
2018-01-18 15:53 ` graeme.gregory

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=1516208146-4144-5-git-send-email-mw@semihalf.com \
    --to=mw@semihalf.com \
    --cc=andrew@lunn.ch \
    --cc=antoine.tenart@free-electrons.com \
    --cc=ard.biesheuvel@linaro.org \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=graeme.gregory@linaro.org \
    --cc=gregory.clement@free-electrons.com \
    --cc=jaz@semihalf.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=nadavh@marvell.com \
    --cc=neta@marvell.com \
    --cc=netdev@vger.kernel.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=stefanc@marvell.com \
    --cc=thomas.petazzoni@free-electrons.com \
    --cc=tn@semihalf.com \
    /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;
as well as URLs for NNTP newsgroup(s).