Linux Watchdog driver development
 help / color / mirror / Atom feed
From: Rosen Penev <rosenp@gmail.com>
To: linux-watchdog@vger.kernel.org
Cc: Wim Van Sebroeck <wim@linux-watchdog.org>,
	linusw@kernel.org, Guenter Roeck <linux@roeck-us.net>,
	linux-kernel@vger.kernel.org (open list)
Subject: [PATCH] watchdog: core: assign parent with devm registration
Date: Sat, 23 May 2026 19:23:32 -0700	[thread overview]
Message-ID: <20260524022332.179202-1-rosenp@gmail.com> (raw)

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


             reply	other threads:[~2026-05-24  2:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-24  2:23 Rosen Penev [this message]
2026-05-24  3:11 ` [PATCH] watchdog: core: assign parent with devm registration sashiko-bot
2026-05-24 15:22 ` Guenter Roeck
2026-05-27 16:25   ` Linus Walleij

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=20260524022332.179202-1-rosenp@gmail.com \
    --to=rosenp@gmail.com \
    --cc=linusw@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=wim@linux-watchdog.org \
    /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