From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rob Herring (Arm)" <robh@kernel.org>,
Markus Elfring <elfring@users.sourceforge.net>,
Jakob Riepler <jakob+lkml@paranoidlabs.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Heikki Krogerus <heikki.krogerus@linux.intel.com>,
Jonathan Cameron <Jonathan.Cameron@huawei.com>,
linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-leds@vger.kernel.org, linux-usb@vger.kernel.org
Cc: Daniel Scally <djrscally@gmail.com>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Danilo Krummrich <dakr@kernel.org>, Lee Jones <lee@kernel.org>,
Pavel Machek <pavel@kernel.org>,
Matti Vaittinen <mazziesaccount@gmail.com>,
Jonathan Cameron <jic23@kernel.org>
Subject: [PATCH v1 1/4] device property: Split fwnode_get_child_node_count()
Date: Mon, 10 Mar 2025 16:54:51 +0200 [thread overview]
Message-ID: <20250310150835.3139322-2-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20250310150835.3139322-1-andriy.shevchenko@linux.intel.com>
The new helper is introduced to allow counting the child firmware nodes
of their parent without requiring a device to be passed. This also makes
the fwnode and device property API more symmetrical with the rest.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/base/property.c | 12 ++++++------
include/linux/property.h | 7 ++++++-
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/drivers/base/property.c b/drivers/base/property.c
index c1392743df9c..805f75b35115 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -928,22 +928,22 @@ bool fwnode_device_is_available(const struct fwnode_handle *fwnode)
EXPORT_SYMBOL_GPL(fwnode_device_is_available);
/**
- * device_get_child_node_count - return the number of child nodes for device
- * @dev: Device to count the child nodes for
+ * fwnode_get_child_node_count - return the number of child nodes for a given firmware node
+ * @fwnode: Pointer to the parent firmware node
*
- * Return: the number of child nodes for a given device.
+ * Return: the number of child nodes for a given firmware node.
*/
-unsigned int device_get_child_node_count(const struct device *dev)
+unsigned int fwnode_get_child_node_count(const struct fwnode_handle *fwnode)
{
struct fwnode_handle *child;
unsigned int count = 0;
- device_for_each_child_node(dev, child)
+ fwnode_for_each_child_node(fwnode, child)
count++;
return count;
}
-EXPORT_SYMBOL_GPL(device_get_child_node_count);
+EXPORT_SYMBOL_GPL(fwnode_get_child_node_count);
bool device_dma_supported(const struct device *dev)
{
diff --git a/include/linux/property.h b/include/linux/property.h
index e214ecd241eb..bc5bfc98176b 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -208,7 +208,12 @@ DEFINE_FREE(fwnode_handle, struct fwnode_handle *, fwnode_handle_put(_T))
int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index);
int fwnode_irq_get_byname(const struct fwnode_handle *fwnode, const char *name);
-unsigned int device_get_child_node_count(const struct device *dev);
+unsigned int fwnode_get_child_node_count(const struct fwnode_handle *fwnode);
+
+static inline unsigned int device_get_child_node_count(const struct device *dev)
+{
+ return fwnode_get_child_node_count(dev_fwnode(dev));
+}
static inline int device_property_read_u8(const struct device *dev,
const char *propname, u8 *val)
--
2.47.2
next prev parent reply other threads:[~2025-03-10 15:08 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-10 14:54 [PATCH v1 0/4] leds: Introduce and use fwnode_get_child_node_count() Andy Shevchenko
2025-03-10 14:54 ` Andy Shevchenko [this message]
2025-03-11 9:51 ` [PATCH v1 1/4] device property: Split fwnode_get_child_node_count() Jonathan Cameron
2025-03-11 12:00 ` [PATCH " Markus Elfring
2025-03-11 12:05 ` Greg Kroah-Hartman
2025-03-12 11:36 ` [PATCH v1 " Heikki Krogerus
2025-03-14 13:43 ` Sakari Ailus
2025-03-14 20:12 ` Rafael J. Wysocki
2025-03-10 14:54 ` [PATCH v1 2/4] leds: pwm-multicolor: Use fwnode_get_child_node_count() Andy Shevchenko
2025-03-11 9:52 ` Jonathan Cameron
2025-03-10 14:54 ` [PATCH v1 3/4] leds: ncp5623: " Andy Shevchenko
2025-03-11 9:54 ` Jonathan Cameron
2025-03-12 10:57 ` Andy Shevchenko
2025-03-10 14:54 ` [PATCH v1 4/4] usb: typec: tcpm: " Andy Shevchenko
2025-03-11 9:55 ` Jonathan Cameron
2025-03-12 3:29 ` Kyle Tso
2025-03-12 11:36 ` Heikki Krogerus
2025-03-14 12:38 ` [PATCH v1 0/4] leds: Introduce and use fwnode_get_child_node_count() Lee Jones
2025-03-14 12:39 ` Lee Jones
2025-03-14 13:35 ` Andy Shevchenko
2025-03-21 11:03 ` Lee Jones
2025-04-10 9:13 ` Lee Jones
2025-04-10 9:12 ` Lee Jones
2025-04-15 16:57 ` [GIT PULL] Immutable branch between LEDS, Base and USB due for the v6.16 merge window Lee Jones
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=20250310150835.3139322-2-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=dakr@kernel.org \
--cc=djrscally@gmail.com \
--cc=elfring@users.sourceforge.net \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=jakob+lkml@paranoidlabs.org \
--cc=jic23@kernel.org \
--cc=lee@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mazziesaccount@gmail.com \
--cc=pavel@kernel.org \
--cc=rafael@kernel.org \
--cc=robh@kernel.org \
--cc=sakari.ailus@linux.intel.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