From b24e99bf53cb9799c3ca7136a351321efd8d57f1 Mon Sep 17 00:00:00 2001 From: Dennis Groenen Date: Fri, 30 Sep 2011 21:50:11 +0200 Subject: [PATCH] add temporary toggleable version of i2c-battery.diff (disabled by default) --- .../debian/patches/extra/i2c-battery-sysfs.diff | 86 ++++++++++++++++++++ kernel-bfs-2.6.28/debian/patches/series | 1 + 2 files changed, 87 insertions(+) create mode 100644 kernel-bfs-2.6.28/debian/patches/extra/i2c-battery-sysfs.diff diff --git a/kernel-bfs-2.6.28/debian/patches/extra/i2c-battery-sysfs.diff b/kernel-bfs-2.6.28/debian/patches/extra/i2c-battery-sysfs.diff new file mode 100644 index 0000000..5a08d83 --- /dev/null +++ b/kernel-bfs-2.6.28/debian/patches/extra/i2c-battery-sysfs.diff @@ -0,0 +1,86 @@ +diff -urpN linux-2.6.28.orig/drivers/i2c/i2c-dev.c linux-2.6.28/drivers/i2c/i2c-dev.c +--- linux-2.6.28.orig/drivers/i2c/i2c-dev.c 2008-12-25 00:26:37.000000000 +0100 ++++ linux-2.6.28/drivers/i2c/i2c-dev.c 2011-09-27 19:55:45.752843074 +0200 +@@ -37,6 +37,31 @@ + #include + #include + ++/* Sysfs knob for the N900 */ ++#include ++#include ++ ++static int break_ioctl; ++static int sysfs_succes; ++ ++static ssize_t break_ioctl_show(struct kobject *kobj, struct kobj_attribute *attr, ++ char *buf) ++{ ++ return sprintf(buf, "%d\n", break_ioctl); ++} ++ ++static ssize_t break_ioctl_store(struct kobject *kobj, struct kobj_attribute *attr, ++ const char *buf, size_t count) ++{ ++ sscanf(buf, "%du", &break_ioctl); ++ return count; ++} ++ ++static struct kobj_attribute break_ioctl_attribute = ++ __ATTR(i2c-dev_break_ioctl, 0644, break_ioctl_show, break_ioctl_store); ++ ++ ++static struct kobject *n900_kobj; + static struct i2c_driver i2cdev_driver; + + /* +@@ -391,9 +416,14 @@ static long i2cdev_ioctl(struct file *fi + if ((arg > 0x3ff) || + (((client->flags & I2C_M_TEN) == 0) && arg > 0x7f)) + return -EINVAL; +- if (cmd == I2C_SLAVE && i2cdev_check_addr(client->adapter, arg)) +- return -EBUSY; +- /* REVISIT: address could become busy later */ ++ if (!break_ioctl) { ++ if (cmd == I2C_SLAVE && i2cdev_check_addr(client->adapter, arg)) { ++ return -EBUSY; ++ } ++ /* REVISIT: address could become busy later */ ++ } else { ++ printk(KERN_INFO "i2c-dev: HACK: omitting lock (EBUSY)\n"); ++ } + client->addr = arg; + return 0; + case I2C_TENBIT: +@@ -592,8 +622,23 @@ static int __init i2c_dev_init(void) + if (res) + goto out_unreg_class; + ++ break_ioctl = 0; /* do not break by default */ ++ ++ n900_kobj = kobject_create_and_add("n900", kernel_kobj); ++ if (!n900_kobj) ++ goto skip_sysfs; ++ ++ res = sysfs_create_file(n900_kobj, &break_ioctl_attribute.attr); ++ if (res) ++ kobject_put(n900_kobj); ++ ++ sysfs_succes = 1; + return 0; + ++skip_sysfs: ++ sysfs_succes = 0; ++ printk(KERN_INFO "Failed to create i2c-dev_break_ioctl sysfs knob\n"); ++ return 0; + out_unreg_class: + class_destroy(i2c_dev_class); + out_unreg_chrdev: +@@ -605,6 +650,8 @@ out: + + static void __exit i2c_dev_exit(void) + { ++ if (sysfs_succes) ++ kobject_put(n900_kobj); + i2c_del_driver(&i2cdev_driver); + class_destroy(i2c_dev_class); + unregister_chrdev(I2C_MAJOR,"i2c"); diff --git a/kernel-bfs-2.6.28/debian/patches/series b/kernel-bfs-2.6.28/debian/patches/series index 20b669e..58c7732 100644 --- a/kernel-bfs-2.6.28/debian/patches/series +++ b/kernel-bfs-2.6.28/debian/patches/series @@ -102,6 +102,7 @@ extra/voltage_scaling_0.diff extra/reiser4-for-2.6.28.patch extra/reiser4-2.6.28.1-fix.patch extra/ubifs.diff +#extra/i2c-battery-sysfs.diff ################################# # BFQ patches -- 1.7.9.5