X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fusb%2Fmisc%2Fauerswald.c;h=1fef36e71c573ed10dc05b2de5240816e87fa0c5;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=c4bebdacda5c3abed047d8e59e838a29fa591d4a;hpb=c7b5ebbddf7bcd3651947760f423e3783bbe6573;p=linux-2.6.git diff --git a/drivers/usb/misc/auerswald.c b/drivers/usb/misc/auerswald.c index c4bebdacd..1fef36e71 100644 --- a/drivers/usb/misc/auerswald.c +++ b/drivers/usb/misc/auerswald.c @@ -29,7 +29,7 @@ #include #include #include -#undef DEBUG /* include debug macros until it's done */ +#include #include /*-------------------------------------------------------------------*/ @@ -425,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) { @@ -514,9 +514,8 @@ 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_unlink_urb (urbp); + usb_kill_urb (urbp); } } @@ -571,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); } @@ -605,7 +603,6 @@ static void auerchain_blocking_completion (struct urb *urb, struct pt_regs *regs /* Starts chained urb and waits for completion or timeout */ static int auerchain_start_wait_urb (pauerchain_t acp, struct urb *urb, int timeout, int* actual_length) { - DECLARE_WAITQUEUE (wait, current); auerchain_chs_t chs; int status; @@ -613,26 +610,13 @@ static int auerchain_start_wait_urb (pauerchain_t acp, struct urb *urb, int time init_waitqueue_head (&chs.wqh); chs.done = 0; - set_current_state (TASK_UNINTERRUPTIBLE); - add_wait_queue (&chs.wqh, &wait); urb->context = &chs; status = auerchain_submit_urb (acp, urb); - if (status) { + if (status) /* something went wrong */ - set_current_state (TASK_RUNNING); - remove_wait_queue (&chs.wqh, &wait); return status; - } - - while (timeout && !chs.done) - { - timeout = schedule_timeout (timeout); - set_current_state(TASK_UNINTERRUPTIBLE); - rmb(); - } - set_current_state (TASK_RUNNING); - remove_wait_queue (&chs.wqh, &wait); + timeout = wait_event_timeout(chs.wqh, chs.done, timeout); if (!timeout && !chs.done) { if (urb->status != -EINPROGRESS) { /* No callback?!! */ @@ -718,16 +702,12 @@ static int auerchain_control_msg (pauerchain_t acp, struct usb_device *dev, unsi /* free a single auerbuf */ static void auerbuf_free (pauerbuf_t bp) { - if (bp->bufp) { - kfree (bp->bufp); - } - if (bp->dr) { - kfree (bp->dr); - } + kfree(bp->bufp); + kfree(bp->dr); if (bp->urbp) { - usb_free_urb (bp->urbp); + usb_free_urb(bp->urbp); } - kfree (bp); + kfree(bp); } /* free the buffers from an auerbuf list */ @@ -780,13 +760,12 @@ 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); @@ -1106,14 +1085,12 @@ exit: */ static void auerswald_int_free (pauerswald_t cp) { - if (cp->inturbp) { - usb_free_urb (cp->inturbp); - cp->inturbp = NULL; - } - if (cp->intbufp) { - kfree (cp->intbufp); - cp->intbufp = NULL; - } + if (cp->inturbp) { + usb_free_urb(cp->inturbp); + cp->inturbp = NULL; + } + kfree(cp->intbufp); + cp->intbufp = NULL; } /* This function is called to activate the interrupt @@ -1123,16 +1100,16 @@ static void auerswald_int_free (pauerswald_t cp) static int auerswald_int_open (pauerswald_t cp) { int ret; - struct usb_endpoint_descriptor *ep; + struct usb_host_endpoint *ep; int irqsize; dbg ("auerswald_int_open"); - ep = usb_epnum_to_ep_desc (cp->usbdev, USB_DIR_IN | AU_IRQENDP); + ep = cp->usbdev->ep_in[AU_IRQENDP]; if (!ep) { ret = -EFAULT; goto intoend; } - irqsize = ep->wMaxPacketSize; + irqsize = le16_to_cpu(ep->desc.wMaxPacketSize); cp->irqsize = irqsize; /* allocate the urb and data buffer */ @@ -1144,14 +1121,16 @@ 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; } } /* setup urb */ - usb_fill_int_urb (cp->inturbp, cp->usbdev, usb_rcvintpipe (cp->usbdev,AU_IRQENDP), cp->intbufp, irqsize, auerswald_int_complete, cp, ep->bInterval); + usb_fill_int_urb (cp->inturbp, cp->usbdev, + usb_rcvintpipe (cp->usbdev,AU_IRQENDP), cp->intbufp, + irqsize, auerswald_int_complete, cp, ep->desc.bInterval); /* start the urb */ cp->inturbp->status = 0; /* needed! */ ret = usb_submit_urb (cp->inturbp, GFP_KERNEL); @@ -1171,22 +1150,16 @@ intoend: endpoint. This function returns 0 if successful or an error code. NOTE: no mutex please! */ -static int auerswald_int_release (pauerswald_t cp) +static void auerswald_int_release (pauerswald_t cp) { - int ret = 0; dbg ("auerswald_int_release"); /* stop the int endpoint */ - if (cp->inturbp) { - ret = usb_unlink_urb (cp->inturbp); - if (ret) - dbg ("nonzero int unlink result received: %d", ret); - } + if (cp->inturbp) + usb_kill_urb (cp->inturbp); /* deallocate memory */ auerswald_int_free (cp); - - return ret; } /* --------------------------------------------------------------------- */ @@ -1721,7 +1694,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) @@ -1897,9 +1870,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, }; @@ -1935,11 +1907,8 @@ static int auerswald_probe (struct usb_interface *intf, int ret; dbg ("probe: vendor id 0x%x, device id 0x%x", - usbdev->descriptor.idVendor, usbdev->descriptor.idProduct); - - /* See if the device offered us matches that we can accept */ - if (usbdev->descriptor.idVendor != ID_AUERSWALD) - return -ENODEV; + le16_to_cpu(usbdev->descriptor.idVendor), + le16_to_cpu(usbdev->descriptor.idProduct)); /* we use only the first -and only- interface */ if (intf->altsetting->desc.bInterfaceNumber != 0) @@ -1973,7 +1942,7 @@ static int auerswald_probe (struct usb_interface *intf, cp->dtindex = intf->minor; /* Get the usb version of the device */ - cp->version = cp->usbdev->descriptor.bcdDevice; + cp->version = le16_to_cpu(cp->usbdev->descriptor.bcdDevice); dbg ("Version is %X", cp->version); /* allow some time to settle the device */ @@ -2016,7 +1985,7 @@ static int auerswald_probe (struct usb_interface *intf, AUDI_MBCTRANS, /* USB message index value */ pbuf, /* pointer to the receive buffer */ 2, /* length of the buffer */ - HZ * 2); /* time to wait for the message to complete before timing out */ + 2000); /* time to wait for the message to complete before timing out */ if (ret == 2) { cp->maxControlLength = le16_to_cpup(pbuf); kfree(pbuf); @@ -2122,6 +2091,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 */ @@ -2132,7 +2103,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,