fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / usb / misc / auerswald.c
index 6f7994f..b5332e6 100644 (file)
@@ -30,7 +30,6 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/wait.h>
-#undef DEBUG                   /* include debug macros until it's done */
 #include <linux/usb.h>
 
 /*-------------------------------------------------------------------*/
@@ -268,7 +267,7 @@ typedef struct
 
 /*-------------------------------------------------------------------*/
 /* Forwards */
-static void auerswald_ctrlread_complete (struct urb * urb, struct pt_regs *regs);
+static void auerswald_ctrlread_complete (struct urb * urb);
 static void auerswald_removeservice (pauerswald_t cp, pauerscon_t scp);
 static struct usb_driver auerswald_driver;
 
@@ -278,7 +277,7 @@ static struct usb_driver auerswald_driver;
 /* --------------------------                                        */
 
 /* completion function for chained urbs */
-static void auerchain_complete (struct urb * urb, struct pt_regs *regs)
+static void auerchain_complete (struct urb * urb)
 {
        unsigned long flags;
         int result;
@@ -297,7 +296,7 @@ static void auerchain_complete (struct urb * urb, struct pt_regs *regs)
            NOTE: this function may lead to more urbs submitted into the chain.
                  (no chain lock at calling complete()!)
                  acp->active != NULL is protecting us against recursion.*/
-        urb->complete (urb, regs);
+        urb->complete (urb);
 
         /* detach element from chain data structure */
        spin_lock_irqsave (&acp->lock, flags);
@@ -332,7 +331,7 @@ static void auerchain_complete (struct urb * urb, struct pt_regs *regs)
                         urb->status = result;
                         dbg("auerchain_complete: usb_submit_urb with error code %d", result);
                         /* and do error handling via *this* completion function (recursive) */
-                        auerchain_complete( urb, NULL);
+                        auerchain_complete( urb);
                 }
         } else {
                 /* simple return without submitting a new urb.
@@ -409,7 +408,7 @@ static int auerchain_submit_urb_list (pauerchain_t acp, struct urb * urb, int ea
                         urb->status = result;
                         dbg("auerchain_submit_urb: usb_submit_urb with error code %d", result);
                         /* and do error handling via completion function */
-                        auerchain_complete( urb, NULL);
+                        auerchain_complete( urb);
                 }
         }
 
@@ -426,7 +425,7 @@ static int auerchain_submit_urb (pauerchain_t acp, struct urb * urb)
 
 /* cancel an urb which is submitted to the chain
    the result is 0 if the urb is cancelled, or -EINPROGRESS if
-   URB_ASYNC_UNLINK is set and the function is successfully started.
+   the function is successfully started.
 */
 static int auerchain_unlink_urb (pauerchain_t acp, struct urb * urb)
 {
@@ -449,7 +448,7 @@ static int auerchain_unlink_urb (pauerchain_t acp, struct urb * urb)
                         spin_unlock_irqrestore (&acp->lock, flags);
                         dbg ("unlink waiting urb");
                         urb->status = -ENOENT;
-                        urb->complete (urb, NULL);
+                        urb->complete (urb);
                         return 0;
                 }
         }
@@ -506,7 +505,7 @@ static void auerchain_unlink_all (pauerchain_t acp)
                 spin_unlock_irqrestore (&acp->lock, flags);
                 dbg ("unlink waiting urb");
                 urbp->status = -ENOENT;
-                urbp->complete (urbp, NULL);
+                urbp->complete (urbp);
                 spin_lock_irqsave (&acp->lock, flags);
         }
         spin_unlock_irqrestore (&acp->lock, flags);
@@ -515,7 +514,6 @@ static void auerchain_unlink_all (pauerchain_t acp)
         acep = acp->active;
         if (acep) {
                 urbp = acep->urbp;
-                urbp->transfer_flags &= ~URB_ASYNC_UNLINK;
                 dbg ("unlink active urb");
                 usb_kill_urb (urbp);
         }
@@ -572,10 +570,9 @@ static int auerchain_setup (pauerchain_t acp, unsigned int numElements)
 
         /* fill the list of free elements */
         for (;numElements; numElements--) {
-                acep = (pauerchainelement_t) kmalloc (sizeof (auerchainelement_t), GFP_KERNEL);
+                acep = kzalloc(sizeof(auerchainelement_t), GFP_KERNEL);
                 if (!acep)
                        goto ac_fail;
-               memset (acep, 0, sizeof (auerchainelement_t));
                 INIT_LIST_HEAD (&acep->list);
                 list_add_tail (&acep->list, &acp->free_list);
         }
@@ -594,7 +591,7 @@ ac_fail:/* free the elements */
 
 
 /* completion handler for synchronous chained URBs */
-static void auerchain_blocking_completion (struct urb *urb, struct pt_regs *regs)
+static void auerchain_blocking_completion (struct urb *urb)
 {
        pauerchain_chs_t pchs = (pauerchain_chs_t)urb->context;
        pchs->done = 1;
@@ -707,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);
 }
 
@@ -763,16 +758,15 @@ static int auerbuf_setup (pauerbufctl_t bcp, unsigned int numElements, unsigned
 
         /* fill the list of free elements */
         for (;numElements; numElements--) {
-                bep = (pauerbuf_t) kmalloc (sizeof (auerbuf_t), GFP_KERNEL);
+                bep = kzalloc(sizeof(auerbuf_t), GFP_KERNEL);
                 if (!bep)
                        goto bl_fail;
-               memset (bep, 0, sizeof (auerbuf_t));
                 bep->list = bcp;
                 INIT_LIST_HEAD (&bep->buff_list);
-                bep->bufp = (char *) kmalloc (bufsize, GFP_KERNEL);
+                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);
@@ -784,7 +778,7 @@ static int auerbuf_setup (pauerbufctl_t bcp, unsigned int numElements, unsigned
 
 bl_fail:/* not enough memory. Free allocated elements */
         dbg ("auerbuf_setup: no more memory");
-       kfree(bep);
+       auerbuf_free(bep);
         auerbuf_free_buffers (bcp);
         return -ENOMEM;
 }
@@ -810,7 +804,7 @@ static void auerbuf_releasebuf( pauerbuf_t bp)
 0              Initial, OK
 -EINPROGRESS   during submission until end
 -ENOENT                if urb is unlinked
--ETIMEDOUT     Transfer timed out, NAK
+-ETIME         Device did not respond
 -ENOMEM                Memory Overflow
 -ENODEV                Specified USB-device or bus doesn't exist
 -ENXIO         URB already queued
@@ -836,7 +830,7 @@ static int auerswald_status_retry (int status)
 {
        switch (status) {
        case 0:
-       case -ETIMEDOUT:
+       case -ETIME:
        case -EOVERFLOW:
        case -EAGAIN:
        case -EPIPE:
@@ -850,7 +844,7 @@ static int auerswald_status_retry (int status)
 }
 
 /* Completion of asynchronous write block */
-static void auerchar_ctrlwrite_complete (struct urb * urb, struct pt_regs *regs)
+static void auerchar_ctrlwrite_complete (struct urb * urb)
 {
        pauerbuf_t bp = (pauerbuf_t) urb->context;
        pauerswald_t cp = ((pauerswald_t)((char *)(bp->list)-(unsigned long)(&((pauerswald_t)0)->bufctl)));
@@ -863,7 +857,7 @@ static void auerchar_ctrlwrite_complete (struct urb * urb, struct pt_regs *regs)
 }
 
 /* Completion handler for dummy retry packet */
-static void auerswald_ctrlread_wretcomplete (struct urb * urb, struct pt_regs *regs)
+static void auerswald_ctrlread_wretcomplete (struct urb * urb)
 {
         pauerbuf_t bp = (pauerbuf_t) urb->context;
         pauerswald_t cp;
@@ -897,12 +891,12 @@ static void auerswald_ctrlread_wretcomplete (struct urb * urb, struct pt_regs *r
         if (ret) {
                dbg ("auerswald_ctrlread_complete: nonzero result of auerchain_submit_urb_list %d", ret);
                bp->urbp->status = ret;
-               auerswald_ctrlread_complete (bp->urbp, NULL);
+               auerswald_ctrlread_complete (bp->urbp);
        }
 }
 
 /* completion handler for receiving of control messages */
-static void auerswald_ctrlread_complete (struct urb * urb, struct pt_regs *regs)
+static void auerswald_ctrlread_complete (struct urb * urb)
 {
         unsigned int  serviceid;
         pauerswald_t  cp;
@@ -945,7 +939,7 @@ static void auerswald_ctrlread_complete (struct urb * urb, struct pt_regs *regs)
                        if (ret) {
                                dbg ("auerswald_ctrlread_complete: nonzero result of auerchain_submit_urb_list %d", ret);
                                bp->urbp->status = ret;
-                               auerswald_ctrlread_wretcomplete (bp->urbp, regs);
+                               auerswald_ctrlread_wretcomplete (bp->urbp);
                }
                 return;
         }
@@ -974,7 +968,7 @@ static void auerswald_ctrlread_complete (struct urb * urb, struct pt_regs *regs)
    messages from the USB device.
 */
 /* int completion handler. */
-static void auerswald_int_complete (struct urb * urb, struct pt_regs *regs)
+static void auerswald_int_complete (struct urb * urb)
 {
         unsigned long flags;
         unsigned  int channelid;
@@ -1074,7 +1068,7 @@ static void auerswald_int_complete (struct urb * urb, struct pt_regs *regs)
         if (ret) {
                 dbg ("auerswald_int_complete: nonzero result of auerchain_submit_urb %d", ret);
                 bp->urbp->status = ret;
-                auerswald_ctrlread_complete( bp->urbp, NULL);
+                auerswald_ctrlread_complete( bp->urbp);
                /* here applies the same problem as above: device locking! */
         }
 exit:
@@ -1125,7 +1119,7 @@ static int auerswald_int_open (pauerswald_t cp)
                 }
         }
         if (!cp->intbufp) {
-                cp->intbufp = (char *) kmalloc (irqsize, GFP_KERNEL);
+                cp->intbufp = kmalloc (irqsize, GFP_KERNEL);
                 if (!cp->intbufp) {
                         ret = -ENOMEM;
                         goto intoend;
@@ -1159,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);
@@ -1383,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;
@@ -1391,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);
@@ -1698,7 +1690,7 @@ static ssize_t auerchar_write (struct file *file, const char __user *buf, size_t
        int ret;
        wait_queue_t wait;
 
-        dbg ("auerchar_write %d bytes", len);
+        dbg ("auerchar_write %zd bytes", len);
 
        /* Error checking */
        if (!ccp)
@@ -1862,7 +1854,7 @@ static int auerchar_release (struct inode *inode, struct file *file)
 
 /*----------------------------------------------------------------------*/
 /* File operation structure                                             */
-static struct file_operations auerswald_fops =
+static const struct file_operations auerswald_fops =
 {
        .owner =        THIS_MODULE,
        .llseek =       no_llseek,
@@ -1874,9 +1866,8 @@ static struct file_operations auerswald_fops =
 };
 
 static struct usb_class_driver auerswald_class = {
-       .name =         "usb/auer%d",
+       .name =         "auer%d",
        .fops =         &auerswald_fops,
-       .mode =         S_IFCHR | S_IRUGO | S_IWUGO,
        .minor_base =   AUER_MINOR_BASE,
 };
 
@@ -1920,14 +1911,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);
@@ -1977,7 +1967,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;
@@ -2096,6 +2086,8 @@ static void auerswald_disconnect (struct usb_interface *intf)
 static struct usb_device_id auerswald_ids [] = {
        { USB_DEVICE (ID_AUERSWALD, 0x00C0) },          /* COMpact 2104 USB */
        { USB_DEVICE (ID_AUERSWALD, 0x00DB) },          /* COMpact 4410/2206 USB */
+       { USB_DEVICE (ID_AUERSWALD, 0x00DC) }, /* COMpact 4406 DSL */
+       { USB_DEVICE (ID_AUERSWALD, 0x00DD) }, /* COMpact 2204 USB */
        { USB_DEVICE (ID_AUERSWALD, 0x00F1) },          /* Comfort 2000 System Telephone */
        { USB_DEVICE (ID_AUERSWALD, 0x00F2) },          /* Comfort 1200 System Telephone */
         { }                                            /* Terminating entry */
@@ -2106,7 +2098,6 @@ MODULE_DEVICE_TABLE (usb, auerswald_ids);
 
 /* Standard usb driver struct */
 static struct usb_driver auerswald_driver = {
-       .owner =        THIS_MODULE,
        .name =         "auerswald",
        .probe =        auerswald_probe,
        .disconnect =   auerswald_disconnect,