]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
watchdog: always print when registering watchdog fails
authorWolfram Sang <wsa+renesas@sang-engineering.com>
Fri, 4 Oct 2024 20:03:04 +0000 (22:03 +0200)
committerWim Van Sebroeck <wim@linux-watchdog.org>
Tue, 5 Nov 2024 09:04:32 +0000 (10:04 +0100)
So far, only 'watchdog_register_device' prints an error if registering
the watchdog driver fails. '__watchdog_register_device' doesn't.
Refactor the code so that both print out. Drivers can then rely on that
and skip their own error messages.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20241004200314.5459-2-wsa+renesas@sang-engineering.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
drivers/watchdog/watchdog_core.c

index aff2c3912ead69cae51fe8228b9f568ab2a61b41..d46d8c8c01f2d3db8d3b6121af8eaa73ca4a8fee 100644 (file)
@@ -237,7 +237,7 @@ void watchdog_set_restart_priority(struct watchdog_device *wdd, int priority)
 }
 EXPORT_SYMBOL_GPL(watchdog_set_restart_priority);
 
-static int __watchdog_register_device(struct watchdog_device *wdd)
+static int ___watchdog_register_device(struct watchdog_device *wdd)
 {
        int ret, id = -1;
 
@@ -337,6 +337,22 @@ static int __watchdog_register_device(struct watchdog_device *wdd)
        return 0;
 }
 
+static int __watchdog_register_device(struct watchdog_device *wdd)
+{
+       const char *dev_str;
+       int ret;
+
+       ret = ___watchdog_register_device(wdd);
+       if (ret) {
+               dev_str = wdd->parent ? dev_name(wdd->parent) :
+                         (const char *)wdd->info->identity;
+               pr_err("%s: failed to register watchdog device (err = %d)\n",
+                       dev_str, ret);
+       }
+
+       return ret;
+}
+
 /**
  * watchdog_register_device() - register a watchdog device
  * @wdd: watchdog device
@@ -350,7 +366,6 @@ static int __watchdog_register_device(struct watchdog_device *wdd)
 
 int watchdog_register_device(struct watchdog_device *wdd)
 {
-       const char *dev_str;
        int ret = 0;
 
        mutex_lock(&wtd_deferred_reg_mutex);
@@ -360,13 +375,6 @@ int watchdog_register_device(struct watchdog_device *wdd)
                watchdog_deferred_registration_add(wdd);
        mutex_unlock(&wtd_deferred_reg_mutex);
 
-       if (ret) {
-               dev_str = wdd->parent ? dev_name(wdd->parent) :
-                         (const char *)wdd->info->identity;
-               pr_err("%s: failed to register watchdog device (err = %d)\n",
-                       dev_str, ret);
-       }
-
        return ret;
 }
 EXPORT_SYMBOL_GPL(watchdog_register_device);