[PATCH] watchdog: core: assign parent with devm registration

From: Rosen Penev

Date: Sat May 23 2026 - 22:24:18 EST


If the user did not pass a parent in the struct watchdog_device
then use the device used for devres as parent.

This is quite intuitive and can help avoiding having to
assign parent explicitly in every driver using devres
to add the watchdog_device.

Signed-off-by: Rosen Penev <rosenp@xxxxxxxxx>
---
Linus: hope you don't mind me flat out copying the description from
https://lore.kernel.org/all/20260427-gpio-mmio-more-v3-1-fe1882351424@xxxxxxxxxx/
drivers/watchdog/watchdog_core.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/drivers/watchdog/watchdog_core.c b/drivers/watchdog/watchdog_core.c
index 8300520688d0..726c85debabc 100644
--- a/drivers/watchdog/watchdog_core.c
+++ b/drivers/watchdog/watchdog_core.c
@@ -440,6 +440,13 @@ int devm_watchdog_register_device(struct device *dev,
if (!rcwdd)
return -ENOMEM;

+ /*
+ * We are passing the devres device here so if the user did not pass
+ * another parent, it's this one.
+ */
+ if (!wdd->parent)
+ wdd->parent = dev;
+
ret = watchdog_register_device(wdd);
if (!ret) {
*rcwdd = wdd;
--
2.54.0