aboutsummaryrefslogtreecommitdiff
path: root/driver/main.c
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2024-05-14 20:56:43 +0200
committerlonkaars <loek@pipeframe.xyz>2024-05-14 20:56:43 +0200
commita8bab1509e795f367db2e374fe600ecacf66e26b (patch)
tree97ccd68f1142da7cd372830ba5cab08c25495b6a /driver/main.c
parent44a5c2b2d47dde5215171966eeef0acdadcaded3 (diff)
add attribute (9.4)
Diffstat (limited to 'driver/main.c')
-rw-r--r--driver/main.c24
1 files changed, 7 insertions, 17 deletions
diff --git a/driver/main.c b/driver/main.c
index 8775727..2676c9a 100644
--- a/driver/main.c
+++ b/driver/main.c
@@ -1,26 +1,11 @@
#include <linux/init.h>
#include <linux/io.h>
#include <linux/module.h>
-#include <linux/of.h>
#include <linux/platform_device.h>
+#include "main.h"
#include "platform.h"
-static const struct of_device_id lork_ids[] = {
- { .compatible = "gpio-extern" },
- {},
-};
-
-struct platform_driver lork_driver = {
- .probe = lork_probe,
- .remove = lork_remove,
- .driver = {
- .name = "gpio-extern",
- .owner = THIS_MODULE,
- .of_match_table = of_match_ptr(lork_ids),
- }
-};
-
struct class* class;
static int mod_init(void) {
@@ -38,17 +23,22 @@ static int mod_init(void) {
err = platform_driver_register(&lork_driver);
if (err) goto return_err;
+ // create attribute under /sys/bus/platform/drivers/gpio-extern
+ err = driver_create_file(&lork_driver.driver, &attr);
+ if (err) goto return_err;
+
printk("%s() OK\n", __PRETTY_FUNCTION__);
return 0;
+return_err:
free_class:
class_destroy(class);
-return_err:
printk("%s() -> %d\n", __PRETTY_FUNCTION__, err);
return err;
}
static void mod_exit(void) {
+ driver_remove_file(&lork_driver.driver, &attr);
platform_driver_unregister(&lork_driver);
class_destroy(class);
printk("%s()\n", __PRETTY_FUNCTION__);