#include <linux/slab.h>
#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>
/* 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 */
*/
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
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);