]> Pileus Git - ~andy/linux/blobdiff - drivers/input/evdev.c
Merge branch 'modules' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux...
[~andy/linux] / drivers / input / evdev.c
index cd323254ca6f560a1b7d38b5283297f67f5b84ee..054edf346e0b5f060e352572f473244e4aeeadcb 100644 (file)
@@ -24,7 +24,6 @@
 #include "input-compat.h"
 
 struct evdev {
-       int exist;
        int open;
        int minor;
        struct input_handle handle;
@@ -34,6 +33,7 @@ struct evdev {
        spinlock_t client_lock; /* protects client_list */
        struct mutex mutex;
        struct device dev;
+       bool exist;
 };
 
 struct evdev_client {
@@ -403,10 +403,15 @@ static unsigned int evdev_poll(struct file *file, poll_table *wait)
 {
        struct evdev_client *client = file->private_data;
        struct evdev *evdev = client->evdev;
+       unsigned int mask;
 
        poll_wait(file, &evdev->wait, wait);
-       return ((client->head == client->tail) ? 0 : (POLLIN | POLLRDNORM)) |
-               (evdev->exist ? 0 : (POLLHUP | POLLERR));
+
+       mask = evdev->exist ? POLLOUT | POLLWRNORM : POLLHUP | POLLERR;
+       if (client->head != client->tail)
+               mask |= POLLIN | POLLRDNORM;
+
+       return mask;
 }
 
 #ifdef CONFIG_COMPAT
@@ -686,6 +691,10 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd,
                                                                  sizeof(struct input_absinfo))))
                                        return -EFAULT;
 
+                               /* We can't change number of reserved MT slots */
+                               if (t == ABS_MT_SLOT)
+                                       return -EINVAL;
+
                                /*
                                 * Take event lock to ensure that we are not
                                 * changing device parameters in the middle
@@ -789,7 +798,7 @@ static void evdev_remove_chrdev(struct evdev *evdev)
 static void evdev_mark_dead(struct evdev *evdev)
 {
        mutex_lock(&evdev->mutex);
-       evdev->exist = 0;
+       evdev->exist = false;
        mutex_unlock(&evdev->mutex);
 }
 
@@ -838,7 +847,7 @@ static int evdev_connect(struct input_handler *handler, struct input_dev *dev,
        init_waitqueue_head(&evdev->wait);
 
        dev_set_name(&evdev->dev, "event%d", minor);
-       evdev->exist = 1;
+       evdev->exist = true;
        evdev->minor = minor;
 
        evdev->handle.dev = input_get_device(dev);