]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/usb/misc/auerswald.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/wim/linux-2.6-watchdog
[linux-2.6-omap-h63xx.git] / drivers / usb / misc / auerswald.c
index e4971d6aaafb323d5d931c99fe0f25c10d072906..42d4e6454a77f3bfec9562bc41b44a85ab42afb8 100644 (file)
@@ -630,7 +630,7 @@ static int auerchain_start_wait_urb (pauerchain_t acp, struct urb *urb, int time
        } else
                status = urb->status;
 
-       if (actual_length)
+       if (status >= 0)
                *actual_length = urb->actual_length;
 
        return status;
@@ -664,7 +664,7 @@ static int auerchain_control_msg (pauerchain_t acp, struct usb_device *dev, unsi
        int ret;
        struct usb_ctrlrequest *dr;
        struct urb *urb;
-        int length;
+        int uninitialized_var(length);
 
         dbg ("auerchain_control_msg");
         dr = kmalloc (sizeof (struct usb_ctrlrequest), GFP_KERNEL);
@@ -704,9 +704,7 @@ static void auerbuf_free (pauerbuf_t bp)
 {
        kfree(bp->bufp);
        kfree(bp->dr);
-       if (bp->urbp) {
-               usb_free_urb(bp->urbp);
-       }
+       usb_free_urb(bp->urbp);
        kfree(bp);
 }
 
@@ -768,7 +766,7 @@ static int auerbuf_setup (pauerbufctl_t bcp, unsigned int numElements, unsigned
                 bep->bufp = kmalloc (bufsize, GFP_KERNEL);
                 if (!bep->bufp)
                        goto bl_fail;
-                bep->dr = (struct usb_ctrlrequest *) kmalloc (sizeof (struct usb_ctrlrequest), GFP_KERNEL);
+                bep->dr = kmalloc(sizeof (struct usb_ctrlrequest), GFP_KERNEL);
                 if (!bep->dr)
                        goto bl_fail;
                 bep->urbp = usb_alloc_urb (0, GFP_KERNEL);
@@ -1155,8 +1153,7 @@ static void auerswald_int_release (pauerswald_t cp)
         dbg ("auerswald_int_release");
 
         /* stop the int endpoint */
-        if (cp->inturbp)
-                usb_kill_urb (cp->inturbp);
+       usb_kill_urb (cp->inturbp);
 
         /* deallocate memory */
         auerswald_int_free (cp);
@@ -1310,7 +1307,7 @@ static int auerswald_addservice (pauerswald_t cp, pauerscon_t scp)
 }
 
 
-/* remove a service from the the device
+/* remove a service from the device
    scp->id must be set! */
 static void auerswald_removeservice (pauerswald_t cp, pauerscon_t scp)
 {
@@ -1379,7 +1376,7 @@ static int auerchar_open (struct inode *inode, struct file *file)
        }
 
        /* we have access to the device. Now lets allocate memory */
-       ccp = (pauerchar_t) kmalloc(sizeof(auerchar_t), GFP_KERNEL);
+       ccp = kzalloc(sizeof(auerchar_t), GFP_KERNEL);
        if (ccp == NULL) {
                err ("out of memory");
                ret = -ENOMEM;
@@ -1387,7 +1384,6 @@ static int auerchar_open (struct inode *inode, struct file *file)
        }
 
        /* Initialize device descriptor */
-       memset( ccp, 0, sizeof(auerchar_t));
        init_MUTEX( &ccp->mutex);
        init_MUTEX( &ccp->readmutex);
         auerbuf_init (&ccp->bufctl);
@@ -1826,16 +1822,10 @@ static int auerchar_release (struct inode *inode, struct file *file)
        pauerswald_t cp;
        dbg("release");
 
-       /* get the mutexes */
-       if (down_interruptible (&ccp->mutex)) {
-               return -ERESTARTSYS;
-       }
+       down(&ccp->mutex);
        cp = ccp->auerdev;
        if (cp) {
-               if (down_interruptible (&cp->mutex)) {
-                       up (&ccp->mutex);
-                       return -ERESTARTSYS;
-               }
+               down(&cp->mutex);
                /* remove an open service */
                auerswald_removeservice (cp, &ccp->scontext);
                /* detach from device */
@@ -1915,14 +1905,13 @@ static int auerswald_probe (struct usb_interface *intf,
                return -ENODEV;
 
        /* allocate memory for our device and initialize it */
-       cp = kmalloc (sizeof(auerswald_t), GFP_KERNEL);
+       cp = kzalloc (sizeof(auerswald_t), GFP_KERNEL);
        if (cp == NULL) {
                err ("out of memory");
                goto pfail;
        }
 
        /* Initialize device descriptor */
-       memset (cp, 0, sizeof(auerswald_t));
        init_MUTEX (&cp->mutex);
        cp->usbdev = usbdev;
        auerchain_init (&cp->controlchain);
@@ -1972,7 +1961,7 @@ static int auerswald_probe (struct usb_interface *intf,
        info("device is a %s", cp->dev_desc);
 
         /* get the maximum allowed control transfer length */
-        pbuf = (__le16 *) kmalloc (2, GFP_KERNEL);    /* use an allocated buffer because of urb target */
+        pbuf = kmalloc(2, GFP_KERNEL);    /* use an allocated buffer because of urb target */
         if (!pbuf) {
                err( "out of memory");
                goto pfail;
@@ -2045,12 +2034,12 @@ static void auerswald_disconnect (struct usb_interface *intf)
        if (!cp)
                return;
 
-       down (&cp->mutex);
-       info ("device /dev/%s now disconnecting", cp->name);
-
        /* give back our USB minor number */
        usb_deregister_dev(intf, &auerswald_class);
 
+       down (&cp->mutex);
+       info ("device /dev/%s now disconnecting", cp->name);
+
        /* Stop the interrupt endpoint */
        auerswald_int_release (cp);