]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - drivers/usb/misc/idmouse.c
[PATCH] USB: kzalloc in idmouse
[karo-tx-linux.git] / drivers / usb / misc / idmouse.c
index 733acc213726ceb70349d099fbb2c29278178abe..b3aca51243397e7c6b757f33d27166fc005b0af4 100644 (file)
@@ -105,17 +105,15 @@ static struct file_operations idmouse_fops = {
        .release = idmouse_release,
 };
 
-/* class driver information for devfs */
+/* class driver information */
 static struct usb_class_driver idmouse_class = {
-       .name = "usb/idmouse%d",
+       .name = "idmouse%d",
        .fops = &idmouse_fops,
-       .mode = S_IFCHR | S_IRUSR | S_IRGRP | S_IROTH, /* filemode (char, 444) */
        .minor_base = USB_IDMOUSE_MINOR_BASE,
 };
 
 /* usb specific object needed to register this driver with the usb subsystem */
 static struct usb_driver idmouse_driver = {
-       .owner = THIS_MODULE,
        .name = DRIVER_SHORT,
        .probe = idmouse_probe,
        .disconnect = idmouse_disconnect,
@@ -320,20 +318,8 @@ static ssize_t idmouse_read(struct file *file, char __user *buffer, size_t count
                return -ENODEV;
        }
 
-       if (*ppos >= IMGSIZE) {
-               up (&dev->sem);
-               return 0;
-       }
-
-       count = min ((loff_t)count, IMGSIZE - (*ppos));
-
-       if (copy_to_user (buffer, dev->bulk_in_buffer + *ppos, count)) {
-               result = -EFAULT;
-       } else {
-               result = count;
-               *ppos += count;
-       }
-
+       result = simple_read_from_buffer(buffer, count, ppos,
+                                       dev->bulk_in_buffer, IMGSIZE);
        /* unlock the device */
        up(&dev->sem);
        return result;
@@ -354,10 +340,9 @@ static int idmouse_probe(struct usb_interface *interface,
                return -ENODEV;
 
        /* allocate memory for our device state and initialize it */
-       dev = kmalloc(sizeof(*dev), GFP_KERNEL);
+       dev = kzalloc(sizeof(*dev), GFP_KERNEL);
        if (dev == NULL)
                return -ENOMEM;
-       memset(dev, 0x00, sizeof(*dev));
 
        init_MUTEX(&dev->sem);
        dev->udev = udev;