Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6
[safe/jmp/linux-2.6] / drivers / input / input.c
index cae4811..5d445f4 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/device.h>
 #include <linux/mutex.h>
 #include <linux/rcupdate.h>
+#include <linux/smp_lock.h>
 
 MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>");
 MODULE_DESCRIPTION("Input core");
@@ -28,6 +29,24 @@ MODULE_LICENSE("GPL");
 
 #define INPUT_DEVICES  256
 
+/*
+ * EV_ABS events which should not be cached are listed here.
+ */
+static unsigned int input_abs_bypass_init_data[] __initdata = {
+       ABS_MT_TOUCH_MAJOR,
+       ABS_MT_TOUCH_MINOR,
+       ABS_MT_WIDTH_MAJOR,
+       ABS_MT_WIDTH_MINOR,
+       ABS_MT_ORIENTATION,
+       ABS_MT_POSITION_X,
+       ABS_MT_POSITION_Y,
+       ABS_MT_TOOL_TYPE,
+       ABS_MT_BLOB_ID,
+       ABS_MT_TRACKING_ID,
+       0
+};
+static unsigned long input_abs_bypass[BITS_TO_LONGS(ABS_CNT)];
+
 static LIST_HEAD(input_dev_list);
 static LIST_HEAD(input_handler_list);
 
@@ -131,6 +150,11 @@ static void input_start_autorepeat(struct input_dev *dev, int code)
        }
 }
 
+static void input_stop_autorepeat(struct input_dev *dev)
+{
+       del_timer(&dev->timer);
+}
+
 #define INPUT_IGNORE_EVENT     0
 #define INPUT_PASS_TO_HANDLERS 1
 #define INPUT_PASS_TO_DEVICE   2
@@ -155,6 +179,10 @@ static void input_handle_event(struct input_dev *dev,
                                disposition = INPUT_PASS_TO_HANDLERS;
                        }
                        break;
+               case SYN_MT_REPORT:
+                       dev->sync = 0;
+                       disposition = INPUT_PASS_TO_HANDLERS;
+                       break;
                }
                break;
 
@@ -166,6 +194,8 @@ static void input_handle_event(struct input_dev *dev,
                                __change_bit(code, dev->key);
                                if (value)
                                        input_start_autorepeat(dev, code);
+                               else
+                                       input_stop_autorepeat(dev);
                        }
 
                        disposition = INPUT_PASS_TO_HANDLERS;
@@ -184,6 +214,11 @@ static void input_handle_event(struct input_dev *dev,
        case EV_ABS:
                if (is_event_supported(code, dev->absbit, ABS_MAX)) {
 
+                       if (test_bit(code, input_abs_bypass)) {
+                               disposition = INPUT_PASS_TO_HANDLERS;
+                               break;
+                       }
+
                        value = input_defuzz_abs_event(value,
                                        dev->abs[code], dev->absfuzz[code]);
 
@@ -736,11 +771,11 @@ static inline void input_wakeup_procfs_readers(void)
 
 static unsigned int input_proc_devices_poll(struct file *file, poll_table *wait)
 {
-       int state = input_devices_state;
-
        poll_wait(file, &input_devices_poll_wait, wait);
-       if (state != input_devices_state)
+       if (file->f_version != input_devices_state) {
+               file->f_version = input_devices_state;
                return POLLIN | POLLRDNORM;
+       }
 
        return 0;
 }
@@ -902,8 +937,6 @@ static int __init input_proc_init(void)
        if (!proc_bus_input_dir)
                return -ENOMEM;
 
-       proc_bus_input_dir->owner = THIS_MODULE;
-
        entry = proc_create("devices", 0, proc_bus_input_dir,
                            &input_devices_fileops);
        if (!entry)
@@ -1388,8 +1421,8 @@ int input_register_device(struct input_dev *dev)
        if (!dev->setkeycode)
                dev->setkeycode = input_default_setkeycode;
 
-       snprintf(dev->dev.bus_id, sizeof(dev->dev.bus_id),
-                "input%ld", (unsigned long) atomic_inc_return(&input_no) - 1);
+       dev_set_name(&dev->dev, "input%ld",
+                    (unsigned long) atomic_inc_return(&input_no) - 1);
 
        error = device_add(&dev->dev);
        if (error)
@@ -1543,7 +1576,6 @@ int input_register_handle(struct input_handle *handle)
                return error;
        list_add_tail_rcu(&handle->d_node, &dev->h_list);
        mutex_unlock(&dev->mutex);
-       synchronize_rcu();
 
        /*
         * Since we are supposed to be called from ->connect()
@@ -1588,13 +1620,17 @@ EXPORT_SYMBOL(input_unregister_handle);
 
 static int input_open_file(struct inode *inode, struct file *file)
 {
-       struct input_handler *handler = input_table[iminor(inode) >> 5];
+       struct input_handler *handler;
        const struct file_operations *old_fops, *new_fops = NULL;
        int err;
 
+       lock_kernel();
        /* No load-on-demand here? */
-       if (!handler || !(new_fops = fops_get(handler->fops)))
-               return -ENODEV;
+       handler = input_table[iminor(inode) >> 5];
+       if (!handler || !(new_fops = fops_get(handler->fops))) {
+               err = -ENODEV;
+               goto out;
+       }
 
        /*
         * That's _really_ odd. Usually NULL ->open means "nothing special",
@@ -1602,7 +1638,8 @@ static int input_open_file(struct inode *inode, struct file *file)
         */
        if (!new_fops->open) {
                fops_put(new_fops);
-               return -ENODEV;
+               err = -ENODEV;
+               goto out;
        }
        old_fops = file->f_op;
        file->f_op = new_fops;
@@ -1614,6 +1651,8 @@ static int input_open_file(struct inode *inode, struct file *file)
                file->f_op = fops_get(old_fops);
        }
        fops_put(old_fops);
+out:
+       unlock_kernel();
        return err;
 }
 
@@ -1622,10 +1661,20 @@ static const struct file_operations input_fops = {
        .open = input_open_file,
 };
 
+static void __init input_init_abs_bypass(void)
+{
+       const unsigned int *p;
+
+       for (p = input_abs_bypass_init_data; *p; p++)
+               input_abs_bypass[BIT_WORD(*p)] |= BIT_MASK(*p);
+}
+
 static int __init input_init(void)
 {
        int err;
 
+       input_init_abs_bypass();
+
        err = class_register(&input_class);
        if (err) {
                printk(KERN_ERR "input: unable to register input_dev class\n");