Linux GPIO subsystem development
 help / color / mirror / Atom feed
From: Pufan Jin <cyan2254650260@gmail.com>
To: Bartosz Golaszewski <brgl@kernel.org>,
	Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>,
	Linus Walleij <linusw@kernel.org>,
	Philipp Zabel <p.zabel@pengutronix.de>
Cc: Krzysztof Kozlowski <krzk@kernel.org>,
	linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 4/5] reset: gpio: derive fwnode_reset_n_cells from platform data
Date: Sat,  5 Dec 2026 14:43:54 +0800	[thread overview]
Message-ID: <20261205064355.137581-5-cyan2254650260@gmail.com> (raw)
In-Reply-To: <20261205064355.137581-1-cyan2254650260@gmail.com>

reset_gpio_probe() sets priv->rc.fwnode_reset_n_cells = 2. When
drivers/reset/core.c supports devicetree GPIO controllers with cell
counts other than 2, __fwnode_reset_control_get() hits
WARN_ON(args.nargs != rcdev->fwnode_reset_n_cells).

__reset_add_reset_gpio_device() passes &rgpio_dev->ref_args via
adev->dev.platform_data. Set fwnode_reset_n_cells from platdata->nargs,
falling back to 2 if platform_data is NULL, and guard
reset_gpio_fwnode_xlate() when nargs is 0.

Signed-off-by: Pufan Jin <cyan2254650260@gmail.com>
---
 drivers/reset/reset-gpio.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/reset/reset-gpio.c b/drivers/reset/reset-gpio.c
index d11d1d6de4..661ab672b1 100644
--- a/drivers/reset/reset-gpio.c
+++ b/drivers/reset/reset-gpio.c
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 
 #include <linux/auxiliary_bus.h>
+#include <linux/fwnode.h>
 #include <linux/gpio/consumer.h>
 #include <linux/module.h>
 #include <linux/property.h>
@@ -48,12 +49,13 @@ static const struct reset_control_ops reset_gpio_ops = {
 static int reset_gpio_fwnode_xlate(struct reset_controller_dev *rcdev,
 				   const struct fwnode_reference_args *reset_spec)
 {
-	return reset_spec->args[0];
+	return reset_spec->nargs ? reset_spec->args[0] : 0;
 }
 
 static int reset_gpio_probe(struct auxiliary_device *adev,
 			    const struct auxiliary_device_id *id)
 {
+	struct fwnode_reference_args *platdata = dev_get_platdata(&adev->dev);
 	struct device *dev = &adev->dev;
 	struct reset_gpio_priv *priv;
 
@@ -71,7 +73,7 @@ static int reset_gpio_probe(struct auxiliary_device *adev,
 	priv->rc.dev = dev;
 
 	/* Cells to match GPIO specifier, but it's not really used */
-	priv->rc.fwnode_reset_n_cells = 2;
+	priv->rc.fwnode_reset_n_cells = platdata ? platdata->nargs : 2;
 	priv->rc.fwnode_xlate = reset_gpio_fwnode_xlate;
 	priv->rc.nr_resets = 1;
 
-- 
2.56.1


  parent reply	other threads:[~2026-12-05  6:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-05  6:43 [PATCH v2 0/5] gpiolib / reset: resolve GPIO specifiers via gpiolib Pufan Jin
2026-12-05  6:43 ` [PATCH v2 1/5] gpiolib: add gpio_device_find_by_fwnode_args() Pufan Jin
2026-12-05  6:43 ` [PATCH v2 2/5] gpiolib: swnode: prefer matching parent gpio_device Pufan Jin
2026-12-05  6:43 ` [PATCH v2 3/5] gpiolib: shared: match reset-gpio against translated entry offset Pufan Jin
2026-12-05  6:43 ` Pufan Jin [this message]
2026-12-05  6:43 ` [PATCH v2 5/5] reset: core: translate GPIO specifier via gpio_device_find_by_fwnode_args() Pufan Jin

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=20261205064355.137581-5-cyan2254650260@gmail.com \
    --to=cyan2254650260@gmail.com \
    --cc=bartosz.golaszewski@oss.qualcomm.com \
    --cc=brgl@kernel.org \
    --cc=krzk@kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-gpio@vger.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