add temporary toggleable version of i2c-battery.diff (disabled by default)
authorDennis Groenen <tj.groenen@gmail.com>
Fri, 30 Sep 2011 19:50:11 +0000 (21:50 +0200)
committerDennis Groenen <tj.groenen@gmail.com>
Fri, 30 Sep 2011 19:50:11 +0000 (21:50 +0200)
kernel-bfs-2.6.28/debian/patches/extra/i2c-battery-sysfs.diff [new file with mode: 0644]
kernel-bfs-2.6.28/debian/patches/series

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 (file)
index 0000000..5a08d83
--- /dev/null
@@ -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 <linux/smp_lock.h>
+ #include <asm/uaccess.h>
++/* Sysfs knob for the N900 */
++#include <linux/kobject.h>
++#include <linux/sysfs.h>
++
++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");
index 20b669e..58c7732 100644 (file)
@@ -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