Skip to content

Commit

Permalink
USB: musb_gadget: implement set_wedge() method
Browse files Browse the repository at this point in the history
Implement the driver's set_wedge() method by adding the 'wedged' flag
to the 'struct musb_ep'.

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Sergei Shtylyov authored and Greg Kroah-Hartman committed Dec 11, 2009
1 parent 196f1b7 commit 47e9760
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
20 changes: 19 additions & 1 deletion drivers/usb/musb/musb_gadget.c
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,7 @@ static int musb_gadget_enable(struct usb_ep *ep,

musb_ep->desc = desc;
musb_ep->busy = 0;
musb_ep->wedged = 0;
status = 0;

pr_debug("%s periph: enabled %s for %s %s, %smaxpacket %d\n",
Expand Down Expand Up @@ -1262,7 +1263,8 @@ int musb_gadget_set_halt(struct usb_ep *ep, int value)
goto done;
}
}
}
} else
musb_ep->wedged = 0;

/* set/clear the stall and toggle bits */
DBG(2, "%s: %s stall\n", ep->name, value ? "set" : "clear");
Expand Down Expand Up @@ -1301,6 +1303,21 @@ int musb_gadget_set_halt(struct usb_ep *ep, int value)
return status;
}

/*
* Sets the halt feature with the clear requests ignored
*/
int musb_gadget_set_wedge(struct usb_ep *ep)
{
struct musb_ep *musb_ep = to_musb_ep(ep);

if (!ep)
return -EINVAL;

musb_ep->wedged = 1;

return usb_ep_set_halt(ep);
}

static int musb_gadget_fifo_status(struct usb_ep *ep)
{
struct musb_ep *musb_ep = to_musb_ep(ep);
Expand Down Expand Up @@ -1371,6 +1388,7 @@ static const struct usb_ep_ops musb_ep_ops = {
.queue = musb_gadget_queue,
.dequeue = musb_gadget_dequeue,
.set_halt = musb_gadget_set_halt,
.set_wedge = musb_gadget_set_wedge,
.fifo_status = musb_gadget_fifo_status,
.fifo_flush = musb_gadget_fifo_flush
};
Expand Down
2 changes: 2 additions & 0 deletions drivers/usb/musb/musb_gadget.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ struct musb_ep {
/* later things are modified based on usage */
struct list_head req_list;

u8 wedged;

/* true if lock must be dropped but req_list may not be advanced */
u8 busy;
};
Expand Down
6 changes: 5 additions & 1 deletion drivers/usb/musb/musb_gadget_ep0.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,18 @@ __acquires(musb->lock)
if (!musb_ep->desc)
break;

handled = 1;
/* Ignore request if endpoint is wedged */
if (musb_ep->wedged)
break;

/* REVISIT do it directly, no locking games */
spin_unlock(&musb->lock);
musb_gadget_set_halt(&musb_ep->end_point, 0);
spin_lock(&musb->lock);

/* select ep0 again */
musb_ep_select(mbase, 0);
handled = 1;
} break;
default:
/* class, vendor, etc ... delegate */
Expand Down

0 comments on commit 47e9760

Please sign in to comment.