Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

watchdog: always print when registering watchdog fails

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>

authored by

Wolfram Sang and committed by
Wim Van Sebroeck
140fb00c 06ba0b8d

+17 -9
+17 -9
drivers/watchdog/watchdog_core.c
··· 237 237 } 238 238 EXPORT_SYMBOL_GPL(watchdog_set_restart_priority); 239 239 240 - static int __watchdog_register_device(struct watchdog_device *wdd) 240 + static int ___watchdog_register_device(struct watchdog_device *wdd) 241 241 { 242 242 int ret, id = -1; 243 243 ··· 337 337 return 0; 338 338 } 339 339 340 + static int __watchdog_register_device(struct watchdog_device *wdd) 341 + { 342 + const char *dev_str; 343 + int ret; 344 + 345 + ret = ___watchdog_register_device(wdd); 346 + if (ret) { 347 + dev_str = wdd->parent ? dev_name(wdd->parent) : 348 + (const char *)wdd->info->identity; 349 + pr_err("%s: failed to register watchdog device (err = %d)\n", 350 + dev_str, ret); 351 + } 352 + 353 + return ret; 354 + } 355 + 340 356 /** 341 357 * watchdog_register_device() - register a watchdog device 342 358 * @wdd: watchdog device ··· 366 350 367 351 int watchdog_register_device(struct watchdog_device *wdd) 368 352 { 369 - const char *dev_str; 370 353 int ret = 0; 371 354 372 355 mutex_lock(&wtd_deferred_reg_mutex); ··· 374 359 else 375 360 watchdog_deferred_registration_add(wdd); 376 361 mutex_unlock(&wtd_deferred_reg_mutex); 377 - 378 - if (ret) { 379 - dev_str = wdd->parent ? dev_name(wdd->parent) : 380 - (const char *)wdd->info->identity; 381 - pr_err("%s: failed to register watchdog device (err = %d)\n", 382 - dev_str, ret); 383 - } 384 362 385 363 return ret; 386 364 }