mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] reset: gpio: Parent the reset-gpio device to the GPIO controller
@ 2026-10-26 12:21 Abel Vesa
  2026-11-06  5:21 ` Tyler Baker
  0 siblings, 1 reply; 2+ messages in thread
From: Abel Vesa @ 2026-10-26 12:21 UTC (permalink / raw)
  To: Philipp Zabel; +Cc: linux-kernel, Abel Vesa

The reset-gpio auxiliary device is a child of the GPIO device providing
the reset line. That GPIO device is unregistered when its controller is
unbound, which removes the sysfs directory of the reset-gpio device with
it, while the reset-gpio device itself stays registered. When the
controller is bound again, probing the reset-gpio device fails:

  reset_gpio reset.gpio.0: really_probe: driver_sysfs_add failed

and so do the consumers of its reset line. This happens for example with
the LPASS LPI pin controller, which goes away together with the ADSP.

Make the controller the parent instead, which stays registered while it
is unbound and gets a new GPIO device when it is bound again. Keep using
the GPIO device if it has no parent.

Signed-off-by: Abel Vesa <abel.vesa@oss.qualcomm.com>
---
Prepared with help from an LLM-based assistant.
---
 drivers/reset/core.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/reset/core.c b/drivers/reset/core.c
index 38e189d04d09..a1b82e093915 100644
--- a/drivers/reset/core.c
+++ b/drivers/reset/core.c
@@ -1015,7 +1015,7 @@ static int __reset_add_reset_gpio_device(struct fwnode_handle *fwnode,
 	struct property_entry properties[3] = { };
 	unsigned int offset, flags, lflags;
 	struct reset_gpio_lookup *rgpio_dev;
-	struct device *parent;
+	struct device *parent, *aux_parent;
 	int ret, prop = 0;
 
 	/*
@@ -1093,7 +1093,15 @@ static int __reset_add_reset_gpio_device(struct fwnode_handle *fwnode,
 		goto err_put_fwnode;
 	}
 
-	ret = reset_create_gpio_aux_device(rgpio_dev, parent);
+	/*
+	 * The GPIO device goes away when its controller is unbound, which would
+	 * leave the reset-gpio device without a place in sysfs. Hang it off the
+	 * controller instead, which stays around and gets a new GPIO device
+	 * when it is bound again. gpiolib parents the GPIO device to the chip's
+	 * parent device, if any; otherwise fall back to the GPIO device itself.
+	 */
+	aux_parent = parent->parent ?: parent;
+	ret = reset_create_gpio_aux_device(rgpio_dev, aux_parent);
 	if (ret)
 		goto err_del_swnode;
 

---
base-commit: bd1ecbb61afefc6a8b876ccbc31e9228b44e9eab
change-id: 20261023-b4-reset-gpio-parent-to-gpio-controller-6401488d80ad

Best regards,
--  
Abel Vesa <abel.vesa@oss.qualcomm.com>


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] reset: gpio: Parent the reset-gpio device to the GPIO controller
  2026-10-26 12:21 [PATCH] reset: gpio: Parent the reset-gpio device to the GPIO controller Abel Vesa
@ 2026-11-06  5:21 ` Tyler Baker
  0 siblings, 0 replies; 2+ messages in thread
From: Tyler Baker @ 2026-11-06  5:21 UTC (permalink / raw)
  To: Abel Vesa
  Cc: Philipp Zabel, Bartosz Golaszewski, Linus Walleij, linux-gpio,
	linux-kernel

On Mon, 26 Oct 2026 at 14:21, Abel Vesa wrote:
> Make the controller the parent instead, which stays registered while it
> is unbound and gets a new GPIO device when it is bound again. Keep using
> the GPIO device if it has no parent.

Fixes: 46dae84a90f9 ("reset: make the provider of reset-gpios the parent of the reset device")

> +	aux_parent = parent->parent ?: parent;

On banked controllers (a gpio_chip and fwnode per bank)
gpio_shared_dev_is_reset_gpio() stops matching, since it compares the
parent's fwnode. I'll send a small fix for that on top of this.

Adding Bartosz and linux-gpio.

Tested-by: Tyler Baker <tyler.baker@oss.qualcomm.com> # Hamoa IoT EVK

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-06  5:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-26 12:21 [PATCH] reset: gpio: Parent the reset-gpio device to the GPIO controller Abel Vesa
2026-11-06  5:21 ` Tyler Baker

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®