From: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
To: Krzysztof Kozlowski <krzk@kernel.org>,
Philipp Zabel <p.zabel@pengutronix.de>
Cc: linux-kernel@vger.kernel.org,
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Subject: [PATCH v2 11/14] reset: convert of_reset_control_get_count() to using firmware nodes
Date: Mon, 23 Feb 2026 11:06:24 +0100 [thread overview]
Message-ID: <20260223-reset-core-refactor-v2-11-5e5a7289190c@oss.qualcomm.com> (raw)
In-Reply-To: <20260223-reset-core-refactor-v2-0-5e5a7289190c@oss.qualcomm.com>
Start the conversion of reset core to using firmware nodes by reworking
of_reset_control_get_count(). Unfortunately there is no fwnode-based
alternative to of_count_phandle_with_args() so we have to hand-code it.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
drivers/reset/core.c | 36 +++++++++++++++++++++++++++---------
1 file changed, 27 insertions(+), 9 deletions(-)
diff --git a/drivers/reset/core.c b/drivers/reset/core.c
index 647e7112779517d2425f55728e1e7fb6e76a8045..b215f5a4aab3f7b625b35d183068633c9c581067 100644
--- a/drivers/reset/core.c
+++ b/drivers/reset/core.c
@@ -12,6 +12,7 @@
#include <linux/device.h>
#include <linux/err.h>
#include <linux/export.h>
+#include <linux/fwnode.h>
#include <linux/gpio/driver.h>
#include <linux/gpio/machine.h>
#include <linux/gpio/property.h>
@@ -20,6 +21,7 @@
#include <linux/kref.h>
#include <linux/module.h>
#include <linux/of.h>
+#include <linux/property.h>
#include <linux/reset.h>
#include <linux/reset-controller.h>
#include <linux/slab.h>
@@ -1416,21 +1418,35 @@ EXPORT_SYMBOL_GPL(__device_reset);
*/
/**
- * of_reset_control_get_count - Count number of resets available with a device
+ * fwnode_reset_control_get_count - Count number of resets available with a device
*
- * @node: device node that contains 'resets'.
+ * @fwnode: firmware node that contains 'resets'.
*
* Returns positive reset count on success, or error number on failure and
* on count being zero.
*/
-static int of_reset_control_get_count(struct device_node *node)
+static int fwnode_reset_control_get_count(struct fwnode_handle *fwnode)
{
- int count;
+ struct fwnode_reference_args args;
+ int count = 0, ret;
- if (!node)
+ if (!fwnode)
return -EINVAL;
- count = of_count_phandle_with_args(node, "resets", "#reset-cells");
+ for (;;) {
+ ret = fwnode_property_get_reference_args(fwnode, "resets", "#reset-cells",
+ 0, count, &args);
+ if (ret) {
+ if (ret == -ENOENT)
+ break;
+
+ return ret;
+ }
+
+ fwnode_handle_put(args.fwnode);
+ count++;
+ }
+
if (count == 0)
count = -ENOENT;
@@ -1454,7 +1470,7 @@ of_reset_control_array_get(struct device_node *np, enum reset_control_flags flag
struct reset_control *rstc;
int num, i;
- num = of_reset_control_get_count(np);
+ num = fwnode_reset_control_get_count(of_fwnode_handle(np));
if (num < 0)
return optional ? NULL : ERR_PTR(num);
@@ -1528,8 +1544,10 @@ EXPORT_SYMBOL_GPL(devm_reset_control_array_get);
*/
int reset_control_get_count(struct device *dev)
{
- if (dev->of_node)
- return of_reset_control_get_count(dev->of_node);
+ struct fwnode_handle *fwnode = dev_fwnode(dev);
+
+ if (fwnode)
+ return fwnode_reset_control_get_count(fwnode);
return -ENOENT;
}
--
2.47.3
next prev parent reply other threads:[~2026-02-23 10:06 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-23 10:06 [PATCH v2 00/14] reset: major reset core refactoring Bartosz Golaszewski
2026-02-23 10:06 ` [PATCH v2 01/14] reset: gpio: remove unneeded OF-node put Bartosz Golaszewski
2026-02-23 10:06 ` [PATCH v2 02/14] reset: gpio: add a devlink between reset-gpio and its consumer Bartosz Golaszewski
2026-02-23 10:06 ` [PATCH v2 03/14] reset: gpio: simplify fallback device matching Bartosz Golaszewski
2026-02-23 16:07 ` Philipp Zabel
2026-02-23 10:06 ` [PATCH v2 04/14] reset: gpio: remove unneeded auxiliary_set_drvdata() Bartosz Golaszewski
2026-02-23 10:06 ` [PATCH v2 05/14] reset: warn on reset-gpio release Bartosz Golaszewski
2026-02-23 16:07 ` Philipp Zabel
2026-02-23 10:06 ` [PATCH v2 06/14] reset: fold ida_alloc() into reset_create_gpio_aux_device() Bartosz Golaszewski
2026-02-23 10:06 ` [PATCH v2 07/14] reset: use lock guards in reset core Bartosz Golaszewski
2026-02-23 16:07 ` Philipp Zabel
2026-02-23 10:06 ` [PATCH v2 08/14] reset: handle removing supplier before consumers Bartosz Golaszewski
2026-03-04 10:56 ` Philipp Zabel
2026-03-05 11:11 ` Bartosz Golaszewski
2026-02-23 10:06 ` [PATCH v2 09/14] reset: protect struct reset_controller_dev with its own mutex Bartosz Golaszewski
2026-03-04 10:56 ` Philipp Zabel
2026-02-23 10:06 ` [PATCH v2 10/14] reset: protect struct reset_control " Bartosz Golaszewski
2026-03-04 10:57 ` Philipp Zabel
2026-02-23 10:06 ` Bartosz Golaszewski [this message]
2026-03-04 11:05 ` [PATCH v2 11/14] reset: convert of_reset_control_get_count() to using firmware nodes Philipp Zabel
2026-02-23 10:06 ` [PATCH v2 12/14] reset: convert the core API " Bartosz Golaszewski
2026-03-04 11:10 ` Philipp Zabel
2026-02-23 10:06 ` [PATCH v2 13/14] reset: convert reset core " Bartosz Golaszewski
2026-03-04 11:34 ` Philipp Zabel
2026-02-23 10:06 ` [PATCH v2 14/14] reset: gpio: make the driver fwnode-agnostic Bartosz Golaszewski
2026-03-04 11:34 ` Philipp Zabel
2026-03-03 8:55 ` [PATCH v2 00/14] reset: major reset core refactoring Bartosz Golaszewski
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=20260223-reset-core-refactor-v2-11-5e5a7289190c@oss.qualcomm.com \
--to=bartosz.golaszewski@oss.qualcomm.com \
--cc=krzk@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=p.zabel@pengutronix.de \
/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®