]> 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 3944a55ed74cecabdd1b9d24415f22bdc8e5069e..b3aca51243397e7c6b757f33d27166fc005b0af4 100644 (file)
@@ -114,7 +114,6 @@ static struct usb_class_driver idmouse_class = {
 
 /* 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,
@@ -319,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;
@@ -353,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;