]> err.no Git - linux-2.6/blobdiff - drivers/input/mousedev.c
[PATCH] 3c59x: read current link status from phy
[linux-2.6] / drivers / input / mousedev.c
index 564974ce57935402ceb2e44471d727b07a056070..c6194a9dd174be5d1a534cc7b962543b112d9f60 100644 (file)
@@ -101,6 +101,7 @@ struct mousedev_list {
        unsigned char ready, buffer, bufsiz;
        unsigned char imexseq, impsseq;
        enum mousedev_emul mode;
+       unsigned long last_buttons;
 };
 
 #define MOUSEDEV_SEQ_LEN       6
@@ -219,12 +220,13 @@ static void mousedev_notify_readers(struct mousedev *mousedev, struct mousedev_h
        struct mousedev_list *list;
        struct mousedev_motion *p;
        unsigned long flags;
+       int wake_readers = 0;
 
        list_for_each_entry(list, &mousedev->list, node) {
                spin_lock_irqsave(&list->packet_lock, flags);
 
                p = &list->packets[list->head];
-               if (list->ready && p->buttons != packet->buttons) {
+               if (list->ready && p->buttons != mousedev->packet.buttons) {
                        unsigned int new_head = (list->head + 1) % PACKET_QUEUE_LEN;
                        if (new_head != list->tail) {
                                p = &list->packets[list->head = new_head];
@@ -249,13 +251,19 @@ static void mousedev_notify_readers(struct mousedev *mousedev, struct mousedev_h
                p->dz += packet->dz;
                p->buttons = mousedev->packet.buttons;
 
-               list->ready = 1;
+               if (p->dx || p->dy || p->dz || p->buttons != list->last_buttons)
+                       list->ready = 1;
 
                spin_unlock_irqrestore(&list->packet_lock, flags);
-               kill_fasync(&list->fasync, SIGIO, POLL_IN);
+
+               if (list->ready) {
+                       kill_fasync(&list->fasync, SIGIO, POLL_IN);
+                       wake_readers = 1;
+               }
        }
 
-       wake_up_interruptible(&mousedev->wait);
+       if (wake_readers)
+               wake_up_interruptible(&mousedev->wait);
 }
 
 static void mousedev_touchpad_touch(struct mousedev *mousedev, int value)
@@ -477,9 +485,10 @@ static void mousedev_packet(struct mousedev_list *list, signed char *ps2_data)
        }
 
        if (!p->dx && !p->dy && !p->dz) {
-               if (list->tail == list->head)
+               if (list->tail == list->head) {
                        list->ready = 0;
-               else
+                       list->last_buttons = p->buttons;
+               } else
                        list->tail = (list->tail + 1) % PACKET_QUEUE_LEN;
        }
 
@@ -642,9 +651,9 @@ static struct input_handle *mousedev_connect(struct input_handler *handler, stru
 
        devfs_mk_cdev(MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + minor),
                        S_IFCHR|S_IRUGO|S_IWUSR, "input/mouse%d", minor);
-       class_simple_device_add(input_class,
-                               MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + minor),
-                               dev->dev, "mouse%d", minor);
+       class_device_create(input_class,
+                       MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + minor),
+                       dev->dev, "mouse%d", minor);
 
        return &mousedev->handle;
 }
@@ -654,7 +663,8 @@ static void mousedev_disconnect(struct input_handle *handle)
        struct mousedev *mousedev = handle->private;
        struct mousedev_list *list;
 
-       class_simple_device_remove(MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + mousedev->minor));
+       class_device_destroy(input_class,
+                       MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + mousedev->minor));
        devfs_remove("input/mouse%d", mousedev->minor);
        mousedev->exist = 0;
 
@@ -730,8 +740,8 @@ static int __init mousedev_init(void)
 
        devfs_mk_cdev(MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + MOUSEDEV_MIX),
                        S_IFCHR|S_IRUGO|S_IWUSR, "input/mice");
-       class_simple_device_add(input_class, MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + MOUSEDEV_MIX),
-                               NULL, "mice");
+       class_device_create(input_class,
+                       MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + MOUSEDEV_MIX), NULL, "mice");
 
 #ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
        if (!(psaux_registered = !misc_register(&psaux_mouse)))
@@ -750,7 +760,8 @@ static void __exit mousedev_exit(void)
                misc_deregister(&psaux_mouse);
 #endif
        devfs_remove("input/mice");
-       class_simple_device_remove(MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + MOUSEDEV_MIX));
+       class_device_destroy(input_class,
+                       MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + MOUSEDEV_MIX));
        input_unregister_handler(&mousedev_handler);
 }