mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] watchdog: core: assign parent with devm registration
@ 2026-05-24  2:23 Rosen Penev
  2026-05-24 15:22 ` Guenter Roeck
  0 siblings, 1 reply; 3+ messages in thread
From: Rosen Penev @ 2026-05-24  2:23 UTC (permalink / raw)
  To: linux-watchdog; +Cc: Wim Van Sebroeck, linusw, Guenter Roeck, open list

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@gmail.com>
---
 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@kernel.org/
 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


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

end of thread, other threads:[~2026-05-27 16:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-24  2:23 [PATCH] watchdog: core: assign parent with devm registration Rosen Penev
2026-05-24 15:22 ` Guenter Roeck
2026-05-27 16:25   ` Linus Walleij

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®