aboutsummaryrefslogtreecommitdiff
path: root/drivers/watchdog/watchdog_dev.c
diff options
context:
space:
mode:
authorPratyush Anand2015-12-17 17:53:58 +0530
committerWim Van Sebroeck2015-12-27 16:54:54 +0100
commit906d7a5cfeda508e7361f021605579a00cd82815 (patch)
tree4dfcbf80d6209a1215ee5f4932e9ebcf860303e0 /drivers/watchdog/watchdog_dev.c
parentd68106bbec2c2a33faacd50a1f7d24954701f505 (diff)
watchdog: Use static struct class watchdog_class in stead of pointer
We need few sysfs attributes to know different status of a watchdog device. To do that, we need to associate .dev_groups with watchdog_class. So convert it from pointer to static. Putting this static struct in watchdog_dev.c, so that static device attributes defined in that file can be attached to it. Signed-off-by: Pratyush Anand <panand@redhat.com> Suggested-by: Guenter Roeck <linux@roeck-us.net> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Diffstat (limited to 'drivers/watchdog/watchdog_dev.c')
-rw-r--r--drivers/watchdog/watchdog_dev.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
index 56a649e66eb2..055a4e1b4c13 100644
--- a/drivers/watchdog/watchdog_dev.c
+++ b/drivers/watchdog/watchdog_dev.c
@@ -581,18 +581,35 @@ int watchdog_dev_unregister(struct watchdog_device *wdd)
return 0;
}
+static struct class watchdog_class = {
+ .name = "watchdog",
+ .owner = THIS_MODULE,
+};
+
/*
* watchdog_dev_init: init dev part of watchdog core
*
* Allocate a range of chardev nodes to use for watchdog devices
*/
-int __init watchdog_dev_init(void)
+struct class * __init watchdog_dev_init(void)
{
- int err = alloc_chrdev_region(&watchdog_devt, 0, MAX_DOGS, "watchdog");
- if (err < 0)
+ int err;
+
+ err = class_register(&watchdog_class);
+ if (err < 0) {
+ pr_err("couldn't register class\n");
+ return ERR_PTR(err);
+ }
+
+ err = alloc_chrdev_region(&watchdog_devt, 0, MAX_DOGS, "watchdog");
+ if (err < 0) {
pr_err("watchdog: unable to allocate char dev region\n");
- return err;
+ class_unregister(&watchdog_class);
+ return ERR_PTR(err);
+ }
+
+ return &watchdog_class;
}
/*
@@ -604,4 +621,5 @@ int __init watchdog_dev_init(void)
void __exit watchdog_dev_exit(void)
{
unregister_chrdev_region(watchdog_devt, MAX_DOGS);
+ class_unregister(&watchdog_class);
}