#include <linux/slab.h>
#include <linux/module.h>
#include <linux/init.h>
-#undef DEBUG /* include debug macros until it's done */
+#include <linux/wait.h>
#include <linux/usb.h>
/*-------------------------------------------------------------------*/
/* 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)
{
acep = acp->active;
if (acep) {
urbp = acep->urbp;
- urbp->transfer_flags &= ~URB_ASYNC_UNLINK;
dbg ("unlink active urb");
usb_kill_urb (urbp);
}
/* 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);
}
/* 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;
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?!! */
/* 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 */
/* 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);
*/
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
}
}
if (!cp->intbufp) {
- cp->intbufp = (char *) kmalloc (irqsize, GFP_KERNEL);
+ cp->intbufp = kmalloc (irqsize, GFP_KERNEL);
if (!cp->intbufp) {
ret = -ENOMEM;
goto intoend;
int ret;
wait_queue_t wait;
- dbg ("auerchar_write %d bytes", len);
+ dbg ("auerchar_write %zd bytes", len);
/* Error checking */
if (!ccp)
};
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,
};
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);
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 */
/* Standard usb driver struct */
static struct usb_driver auerswald_driver = {
- .owner = THIS_MODULE,
.name = "auerswald",
.probe = auerswald_probe,
.disconnect = auerswald_disconnect,