watchdog: let core print error message when registering device fails
authorWolfram Sang <wsa+renesas@sang-engineering.com>
Sat, 18 May 2019 21:27:17 +0000 (23:27 +0200)
committerWim Van Sebroeck <wim@linux-watchdog.org>
Mon, 8 Jul 2019 13:13:01 +0000 (15:13 +0200)
So we can remove boilerplate code from drivers.

Signed-off-by: Wolfram Sang <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 9fd096af0cc5fc949edaa12cc80b3dd656f505be..cf3247224a6eb41ac96573307683ffd48373c777 100644 (file)
@@ -264,6 +264,7 @@ 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);
@@ -272,6 +273,14 @@ int watchdog_register_device(struct watchdog_device *wdd)
        else
                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);