[PATCH v2 4/5] reset: gpio: derive fwnode_reset_n_cells from platform data
From: Pufan Jin
Date: Sat Dec 05 2026 - 01:44:29 EST
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@xxxxxxxxx>
---
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