Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6
[safe/jmp/linux-2.6] / drivers / input / mousedev.c
index be83516..f34b22b 100644 (file)
 #define MOUSEDEV_MINORS                32
 #define MOUSEDEV_MIX           31
 
+#include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/poll.h>
 #include <linux/module.h>
-#include <linux/moduleparam.h>
 #include <linux/init.h>
 #include <linux/input.h>
 #include <linux/random.h>
@@ -60,7 +60,6 @@ struct mousedev {
        int exist;
        int open;
        int minor;
-       char name[16];
        struct input_handle handle;
        wait_queue_head_t wait;
        struct list_head client_list;
@@ -403,18 +402,16 @@ static void mousedev_event(struct input_handle *handle,
 
 static int mousedev_fasync(int fd, struct file *file, int on)
 {
-       int retval;
        struct mousedev_client *client = file->private_data;
 
-       retval = fasync_helper(fd, file, on, &client->fasync);
-
-       return retval < 0 ? retval : 0;
+       return fasync_helper(fd, file, on, &client->fasync);
 }
 
 static void mousedev_free(struct device *dev)
 {
        struct mousedev *mousedev = container_of(dev, struct mousedev, dev);
 
+       input_put_device(mousedev->handle.dev);
        kfree(mousedev);
 }
 
@@ -518,7 +515,6 @@ static int mousedev_release(struct inode *inode, struct file *file)
        struct mousedev_client *client = file->private_data;
        struct mousedev *mousedev = client->mousedev;
 
-       mousedev_fasync(-1, file, 0);
        mousedev_detach_client(mousedev, client);
        kfree(client);
 
@@ -546,15 +542,17 @@ static int mousedev_open(struct inode *inode, struct file *file)
                return -ENODEV;
 
        error = mutex_lock_interruptible(&mousedev_table_mutex);
-       if (error)
+       if (error) {
                return error;
+       }
        mousedev = mousedev_table[i];
        if (mousedev)
                get_device(&mousedev->dev);
        mutex_unlock(&mousedev_table_mutex);
 
-       if (!mousedev)
+       if (!mousedev) {
                return -ENODEV;
+       }
 
        client = kzalloc(sizeof(struct mousedev_client), GFP_KERNEL);
        if (!client) {
@@ -859,20 +857,17 @@ static struct mousedev *mousedev_create(struct input_dev *dev,
        init_waitqueue_head(&mousedev->wait);
 
        if (minor == MOUSEDEV_MIX)
-               strlcpy(mousedev->name, "mice", sizeof(mousedev->name));
+               dev_set_name(&mousedev->dev, "mice");
        else
-               snprintf(mousedev->name, sizeof(mousedev->name),
-                        "mouse%d", minor);
+               dev_set_name(&mousedev->dev, "mouse%d", minor);
 
        mousedev->minor = minor;
        mousedev->exist = 1;
-       mousedev->handle.dev = dev;
-       mousedev->handle.name = mousedev->name;
+       mousedev->handle.dev = input_get_device(dev);
+       mousedev->handle.name = dev_name(&mousedev->dev);
        mousedev->handle.handler = handler;
        mousedev->handle.private = mousedev;
 
-       strlcpy(mousedev->dev.bus_id, mousedev->name,
-               sizeof(mousedev->dev.bus_id));
        mousedev->dev.class = &input_class;
        if (dev)
                mousedev->dev.parent = &dev->dev;
@@ -1033,7 +1028,7 @@ static const struct input_device_id mousedev_ids[] = {
                .flags = INPUT_DEVICE_ID_MATCH_EVBIT |
                        INPUT_DEVICE_ID_MATCH_KEYBIT |
                        INPUT_DEVICE_ID_MATCH_ABSBIT,
-               .evbit = { BIT(EV_KEY) | BIT(EV_ABS) | BIT(EV_SYN) },
+               .evbit = { BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS) },
                .keybit = { [BIT_WORD(BTN_LEFT)] = BIT_MASK(BTN_LEFT) },
                .absbit = { BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) },
        },      /* Mouse-like device with absolute X and Y but ordinary