summaryrefslogtreecommitdiff
path: root/drivers/watchdog/wdt-uclass.c
diff options
context:
space:
mode:
authorRasmus Villemoes <rasmus.villemoes@prevas.dk>2021-08-19 12:56:58 +0300
committerStefan Roese <sr@denx.de>2021-08-31 13:04:03 +0300
commit3eaf6e2e42c5855036a11dd7c00831226c27f152 (patch)
tree2c2f100647b32dfab2917a3c0ee93f40ce743220 /drivers/watchdog/wdt-uclass.c
parent068f8eafe985a8658aaea8f476316c4f3940c7bd (diff)
downloadu-boot-3eaf6e2e42c5855036a11dd7c00831226c27f152.tar.xz
watchdog: wdt-uclass.c: refactor initr_watchdog()
In preparation for handling all DM watchdogs in watchdog_reset(), pull out the code which handles starting (or not) the gd->watchdog_dev device. Include the device name in various printfs. Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Stefan Roese <sr@denx.de> Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Diffstat (limited to 'drivers/watchdog/wdt-uclass.c')
-rw-r--r--drivers/watchdog/wdt-uclass.c37
1 files changed, 21 insertions, 16 deletions
diff --git a/drivers/watchdog/wdt-uclass.c b/drivers/watchdog/wdt-uclass.c
index 81287c759a..0a1f43771c 100644
--- a/drivers/watchdog/wdt-uclass.c
+++ b/drivers/watchdog/wdt-uclass.c
@@ -35,11 +35,30 @@ struct wdt_priv {
ulong next_reset;
};
-int initr_watchdog(void)
+static void init_watchdog_dev(struct udevice *dev)
{
struct wdt_priv *priv;
int ret;
+ priv = dev_get_uclass_priv(dev);
+
+ if (!IS_ENABLED(CONFIG_WATCHDOG_AUTOSTART)) {
+ printf("WDT: Not starting %s\n", dev->name);
+ return;
+ }
+
+ ret = wdt_start(dev, priv->timeout * 1000, 0);
+ if (ret != 0) {
+ printf("WDT: Failed to start %s\n", dev->name);
+ return;
+ }
+
+ printf("WDT: Started %s with%s servicing (%ds timeout)\n", dev->name,
+ IS_ENABLED(CONFIG_WATCHDOG) ? "" : "out", priv->timeout);
+}
+
+int initr_watchdog(void)
+{
/*
* Init watchdog: This will call the probe function of the
* watchdog driver, enabling the use of the device
@@ -53,21 +72,7 @@ int initr_watchdog(void)
return 0;
}
}
- priv = dev_get_uclass_priv(gd->watchdog_dev);
-
- if (!IS_ENABLED(CONFIG_WATCHDOG_AUTOSTART)) {
- printf("WDT: Not starting\n");
- return 0;
- }
-
- ret = wdt_start(gd->watchdog_dev, priv->timeout * 1000, 0);
- if (ret != 0) {
- printf("WDT: Failed to start\n");
- return 0;
- }
-
- printf("WDT: Started with%s servicing (%ds timeout)\n",
- IS_ENABLED(CONFIG_WATCHDOG) ? "" : "out", priv->timeout);
+ init_watchdog_dev(gd->watchdog_dev);
return 0;
}