Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 115745
b: refs/heads/master
c: 851a526
h: refs/heads/master
i:
  115743: 73b10d2
v: v3
  • Loading branch information
Alan Stern authored and Greg Kroah-Hartman committed Oct 17, 2008
1 parent 9192cd5 commit e775568
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a7a19fac8a9fbc0182fb1b464848a31529c39433
refs/heads/master: 851a526dcf97964265cadcc6664a9f0ff7c143c7
33 changes: 27 additions & 6 deletions trunk/drivers/usb/gadget/dummy_hcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ struct dummy_ep {
const struct usb_endpoint_descriptor *desc;
struct usb_ep ep;
unsigned halted : 1;
unsigned wedged : 1;
unsigned already_seen : 1;
unsigned setup_stage : 1;
};
Expand Down Expand Up @@ -436,6 +437,7 @@ dummy_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
/* at this point real hardware should be NAKing transfers
* to that endpoint, until a buffer is queued to it.
*/
ep->halted = ep->wedged = 0;
retval = 0;
done:
return retval;
Expand Down Expand Up @@ -597,7 +599,7 @@ static int dummy_dequeue (struct usb_ep *_ep, struct usb_request *_req)
}

static int
dummy_set_halt (struct usb_ep *_ep, int value)
dummy_set_halt_and_wedge(struct usb_ep *_ep, int value, int wedged)
{
struct dummy_ep *ep;
struct dummy *dum;
Expand All @@ -609,16 +611,32 @@ dummy_set_halt (struct usb_ep *_ep, int value)
if (!dum->driver)
return -ESHUTDOWN;
if (!value)
ep->halted = 0;
ep->halted = ep->wedged = 0;
else if (ep->desc && (ep->desc->bEndpointAddress & USB_DIR_IN) &&
!list_empty (&ep->queue))
return -EAGAIN;
else
else {
ep->halted = 1;
if (wedged)
ep->wedged = 1;
}
/* FIXME clear emulated data toggle too */
return 0;
}

static int
dummy_set_halt(struct usb_ep *_ep, int value)
{
return dummy_set_halt_and_wedge(_ep, value, 0);
}

static int dummy_set_wedge(struct usb_ep *_ep)
{
if (!_ep || _ep->name == ep0name)
return -EINVAL;
return dummy_set_halt_and_wedge(_ep, 1, 1);
}

static const struct usb_ep_ops dummy_ep_ops = {
.enable = dummy_enable,
.disable = dummy_disable,
Expand All @@ -630,6 +648,7 @@ static const struct usb_ep_ops dummy_ep_ops = {
.dequeue = dummy_dequeue,

.set_halt = dummy_set_halt,
.set_wedge = dummy_set_wedge,
};

/*-------------------------------------------------------------------------*/
Expand Down Expand Up @@ -760,7 +779,8 @@ usb_gadget_register_driver (struct usb_gadget_driver *driver)
ep->ep.name = ep_name [i];
ep->ep.ops = &dummy_ep_ops;
list_add_tail (&ep->ep.ep_list, &dum->gadget.ep_list);
ep->halted = ep->already_seen = ep->setup_stage = 0;
ep->halted = ep->wedged = ep->already_seen =
ep->setup_stage = 0;
ep->ep.maxpacket = ~0;
ep->last_io = jiffies;
ep->gadget = &dum->gadget;
Expand Down Expand Up @@ -1351,7 +1371,7 @@ static void dummy_timer (unsigned long _dum)
} else if (setup.bRequestType == Ep_Request) {
// endpoint halt
ep2 = find_endpoint (dum, w_index);
if (!ep2) {
if (!ep2 || ep2->ep.name == ep0name) {
value = -EOPNOTSUPP;
break;
}
Expand Down Expand Up @@ -1380,7 +1400,8 @@ static void dummy_timer (unsigned long _dum)
value = -EOPNOTSUPP;
break;
}
ep2->halted = 0;
if (!ep2->wedged)
ep2->halted = 0;
value = 0;
status = 0;
}
Expand Down

0 comments on commit e775568

Please sign in to comment.