Skip to content

Commit 140fb00

Browse files
Wolfram SangWim Van Sebroeck
authored andcommitted
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 <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]> Signed-off-by: Wim Van Sebroeck <[email protected]>
1 parent 06ba0b8 commit 140fb00

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

drivers/watchdog/watchdog_core.c

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ void watchdog_set_restart_priority(struct watchdog_device *wdd, int priority)
237237
}
238238
EXPORT_SYMBOL_GPL(watchdog_set_restart_priority);
239239

240-
static int __watchdog_register_device(struct watchdog_device *wdd)
240+
static int ___watchdog_register_device(struct watchdog_device *wdd)
241241
{
242242
int ret, id = -1;
243243

@@ -337,6 +337,22 @@ static int __watchdog_register_device(struct watchdog_device *wdd)
337337
return 0;
338338
}
339339

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+
340356
/**
341357
* watchdog_register_device() - register a watchdog device
342358
* @wdd: watchdog device
@@ -350,7 +366,6 @@ static int __watchdog_register_device(struct watchdog_device *wdd)
350366

351367
int watchdog_register_device(struct watchdog_device *wdd)
352368
{
353-
const char *dev_str;
354369
int ret = 0;
355370

356371
mutex_lock(&wtd_deferred_reg_mutex);
@@ -360,13 +375,6 @@ int watchdog_register_device(struct watchdog_device *wdd)
360375
watchdog_deferred_registration_add(wdd);
361376
mutex_unlock(&wtd_deferred_reg_mutex);
362377

363-
if (ret) {
364-
dev_str = wdd->parent ? dev_name(wdd->parent) :
365-
(const char *)wdd->info->identity;
366-
pr_err("%s: failed to register watchdog device (err = %d)\n",
367-
dev_str, ret);
368-
}
369-
370378
return ret;
371379
}
372380
EXPORT_SYMBOL_GPL(watchdog_register_device);

0 commit comments

Comments
 (0)