[PATCH v1 3/6] watchdog: register watchdog virtual device with short name wdog
Oleksij Rempel
o.rempel at pengutronix.de
Thu Mar 8 03:05:12 PST 2018
the watchdog hwdev is usually named with devicetree schema
which is not practical for CLI.
On device registration "wdog" will be extended with some index number
extracted from devicetree (if awailable) or automatically assigned
first available number. End result will be "wdog0" .. etc.
Signed-off-by: Oleksij Rempel <o.rempel at pengutronix.de>
---
drivers/watchdog/wd_core.c | 6 ++++++
include/watchdog.h | 1 +
2 files changed, 7 insertions(+)
diff --git a/drivers/watchdog/wd_core.c b/drivers/watchdog/wd_core.c
index 1d0f0de7d..97e2ab568 100644
--- a/drivers/watchdog/wd_core.c
+++ b/drivers/watchdog/wd_core.c
@@ -33,6 +33,11 @@ static const char *watchdog_name(struct watchdog *wd)
int watchdog_register(struct watchdog *wd)
{
+
+ strcpy(wd->dev.name, "wdog");
+ wd->dev.parent = wd->hwdev;
+ register_device(&wd->dev);
+
if (!wd->priority)
wd->priority = WATCHDOG_DEFAULT_PRIORITY;
@@ -50,6 +55,7 @@ EXPORT_SYMBOL(watchdog_register);
int watchdog_deregister(struct watchdog *wd)
{
+ unregister_device(&wd->dev);
list_del(&wd->list);
return 0;
diff --git a/include/watchdog.h b/include/watchdog.h
index 1e06fbc3f..a2459d255 100644
--- a/include/watchdog.h
+++ b/include/watchdog.h
@@ -17,6 +17,7 @@ struct watchdog {
int (*set_timeout)(struct watchdog *, unsigned);
const char *name;
struct device_d *hwdev;
+ struct device_d dev;
unsigned int priority;
unsigned int timeout_max;
struct list_head list;
--
2.16.1
More information about the barebox
mailing list