diff options
-rw-r--r-- | driver/main.c | 49 | ||||
-rw-r--r-- | driver/main.h | 2 | ||||
-rw-r--r-- | dts/am335x-boneblack-uboot.dts | 10 |
3 files changed, 8 insertions, 53 deletions
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 <linux/i2c.h> #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 }, {}, }; diff --git a/dts/am335x-boneblack-uboot.dts b/dts/am335x-boneblack-uboot.dts index 9cdeada..64f2cea 100644 --- a/dts/am335x-boneblack-uboot.dts +++ b/dts/am335x-boneblack-uboot.dts @@ -2242,11 +2242,13 @@ }; }; - // NOTE: this is in i2c2, so I2C2_SCL = P9.19 and I2C2_SDA = P9.20 - lork { - compatible = "lork-i2c"; // load my driver - addr = <0x22>; // i2c slave address (see ../arduino/main.cpp) + // node name must match one in ../driver/main.h i2c_device_id struct + // reg and node address must match i2c address (see ../arduino/main.cpp) + lork_i2c: lork@22 { + compatible = "lork-i2c"; + reg = <0x22>; }; + // NOTE: this is in i2c2, so I2C2_SCL = P9.19 and I2C2_SDA = P9.20 }; }; |