Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <linux/module.h>
- #include <linux/init.h>
- #include <linux/slab.h>
- #include <linux/i2c.h>
- #include <linux/hwmon.h>
- #include <linux/hwmon-sysfs.h>
- #include <linux/err.h>
- #include <linux/mutex.h>
- #include <linux/device.h>
- #define DRIVER_NAME "test114"
- static struct timer_list test114_update_timer;
- struct i2c_client *test114_i2c;
- void test114_update_device(unsigned long data)
- {
- struct i2c_client *client = test114_i2c;
- i2c_smbus_read_byte_data(client, 0);
- mod_timer(&test114_update_timer, jiffies + msecs_to_jiffies(1000));
- printk("Tick...\n");
- }
- static int __devinit test114_probe(struct i2c_client *client,
- const struct i2c_device_id *id)
- {
- int status;
- if (!i2c_check_functionality(client->adapter,
- I2C_FUNC_SMBUS_WORD_DATA)) {
- dev_err(&client->dev, "adapter doesn't support SMBus word "
- "transactions\n");
- return -ENODEV;
- }
- setup_timer(&test114_update_timer, test114_update_device, 0);
- status = mod_timer(&test114_update_timer, jiffies + msecs_to_jiffies(5000));
- test114_i2c = client;
- dev_info(&client->dev, "initialized\n");
- return 0;
- }
- static int __devexit test114_remove(struct i2c_client *client)
- {
- del_timer(&test114_update_timer);
- return 0;
- }
- static const struct i2c_device_id test114_id[] = {
- { "test114", 0 },
- { }
- };
- MODULE_DEVICE_TABLE(i2c, test114_id);
- static struct i2c_driver test114_driver = {
- .driver.name = DRIVER_NAME,
- .probe = test114_probe,
- .remove = __devexit_p(test114_remove),
- .id_table = test114_id,
- };
- static int __init test114_init(void)
- {
- return i2c_add_driver(&test114_driver);
- }
- module_init(test114_init);
- static void __exit test114_exit(void)
- {
- i2c_del_driver(&test114_driver);
- }
- module_exit(test114_exit);
- MODULE_AUTHOR("sza2");
- MODULE_DESCRIPTION("test114 driver");
- MODULE_LICENSE("GPL");
Advertisement
Add Comment
Please, Sign In to add comment