aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--driver/main.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/driver/main.c b/driver/main.c
index 76ba1d8..8775727 100644
--- a/driver/main.c
+++ b/driver/main.c
@@ -21,14 +21,37 @@ struct platform_driver lork_driver = {
}
};
+struct class* class;
+
static int mod_init(void) {
- printk("%s()\n", __PRETTY_FUNCTION__);
- return platform_driver_register(&lork_driver);
+ int err;
+
+ // create /sys/class/lork
+ class = class_create("lork");
+ if (IS_ERR_OR_NULL(class)) {
+ err = PTR_ERR(class);
+ printk(KERN_ERR "class_create error %d\n", err);
+ goto free_class;
+ }
+
+ // create platform driver
+ err = platform_driver_register(&lork_driver);
+ if (err) goto return_err;
+
+ printk("%s() OK\n", __PRETTY_FUNCTION__);
+ return 0;
+
+free_class:
+ class_destroy(class);
+return_err:
+ printk("%s() -> %d\n", __PRETTY_FUNCTION__, err);
+ return err;
}
static void mod_exit(void) {
- printk("%s()\n", __PRETTY_FUNCTION__);
platform_driver_unregister(&lork_driver);
+ class_destroy(class);
+ printk("%s()\n", __PRETTY_FUNCTION__);
}
module_init(mod_init);