kernel-2_6_6-1_441
[linux-2.6.git] / drivers / input / evdev.c
index 4f784c8..3737e5a 100644 (file)
@@ -126,7 +126,7 @@ static int evdev_open(struct inode * inode, struct file * file)
        int i = iminor(inode) - EVDEV_MINOR_BASE;
        int accept_err;
 
-       if (i >= EVDEV_MINORS || !evdev_table[i])
+       if (i >= EVDEV_MINORS || !evdev_table[i] || !evdev_table[i]->exist)
                return -ENODEV;
 
        if ((accept_err = input_accept_process(&(evdev_table[i]->handle), file)))
@@ -175,7 +175,7 @@ static ssize_t evdev_read(struct file * file, char __user * buffer, size_t count
                return -EAGAIN;
 
        retval = wait_event_interruptible(list->evdev->wait,
-               list->head != list->tail && list->evdev->exist);
+               list->head != list->tail || (!list->evdev->exist));
 
        if (retval)
                return retval;
@@ -222,7 +222,7 @@ static int evdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
 
                case EVIOCGID:
                        return copy_to_user(p, &dev->id, sizeof(struct input_id)) ? -EFAULT : 0;
-               
+
                case EVIOCGKEYCODE:
                        if (get_user(t, ip)) return -EFAULT;
                        if (t < 0 || t > dev->keycodemax || !dev->keycodesize) return -EINVAL;
@@ -430,7 +430,7 @@ static struct input_handle *evdev_connect(struct input_handler *handler, struct
 
        devfs_mk_cdev(MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + minor),
                        S_IFCHR|S_IRUGO|S_IWUSR, "input/event%d", minor);
-       class_simple_device_add(input_class, 
+       class_simple_device_add(input_class,
                                MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + minor),
                                dev->dev, "event%d", minor);