From 5254cc646177e0934db75550b44e297b4337ea75 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Sat, 15 Jun 2024 18:17:15 +0200 Subject: i2c driver load + probe works --- driver/main.c | 49 +------------------------------------------------ driver/main.h | 2 +- 2 files changed, 2 insertions(+), 49 deletions(-) (limited to 'driver') diff --git a/driver/main.c b/driver/main.c index 2097edd..4dd4b88 100644 --- a/driver/main.c +++ b/driver/main.c @@ -2,54 +2,7 @@ #include #include "main.h" -#include "platform.h" -struct device *dev; -struct class *class; -dev_t node = 0; // do not register /dev/lork - -static int mod_init(void) { - int err; - - // create /sys/class/lork - class = class_create("lork"); - if (IS_ERR_OR_NULL(class)) { - err = PTR_ERR(class); - goto free_class; - } - - // create device (required for device attributes under /sys/class) - dev = device_create(class, NULL, node, NULL, "lork"); - if (IS_ERR_OR_NULL(dev)) { - err = PTR_ERR(dev); - goto free_device; - } - - // create platform driver - err = i2c_add_driver(&lork_driver); - if (err) goto free_platform_driver; - - printk("%s() OK\n", __PRETTY_FUNCTION__); - return 0; - -free_platform_driver: - i2c_del_driver(&lork_driver); -free_device: - device_destroy(class, node); -free_class: - class_destroy(class); - printk("%s() -> %d\n", __PRETTY_FUNCTION__, err); - return err; -} - -static void mod_exit(void) { - i2c_del_driver(&lork_driver); - device_destroy(class, node); - class_destroy(class); - printk("%s()\n", __PRETTY_FUNCTION__); -} - -module_init(mod_init); -module_exit(mod_exit); +module_i2c_driver(lork_driver); MODULE_LICENSE("Dual MIT/GPL"); diff --git a/driver/main.h b/driver/main.h index 666bcc1..77ebad5 100644 --- a/driver/main.h +++ b/driver/main.h @@ -11,7 +11,7 @@ static const struct of_device_id lork_match[] = { }; static const struct i2c_device_id lork_ids[] = { - { "foo", 0 }, + { "lork", 0 }, {}, }; -- cgit v1.2.3