aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/musb
diff options
context:
space:
mode:
authorSergei Shtylyov <sshtylyov@ru.mvista.com>2009-11-18 14:51:51 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2009-12-11 14:55:25 -0500
commit47e9760529a9823be59d879f726acdc7e2fcbe11 (patch)
treed9c5d1ac662e0bd54c0b3a0fd40639ddcf4b177d /drivers/usb/musb
parent196f1b7a387546f425df2f1fad26772e3d513aea (diff)
USB: musb_gadget: implement set_wedge() method
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>
Diffstat (limited to 'drivers/usb/musb')
-rw-r--r--drivers/usb/musb/musb_gadget.c20
-rw-r--r--drivers/usb/musb/musb_gadget.h2
-rw-r--r--drivers/usb/musb/musb_gadget_ep0.c6
3 files changed, 26 insertions, 2 deletions
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index 74073f9a43f0..173c963e7f02 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -966,6 +966,7 @@ static int musb_gadget_enable(struct usb_ep *ep,
966 966
967 musb_ep->desc = desc; 967 musb_ep->desc = desc;
968 musb_ep->busy = 0; 968 musb_ep->busy = 0;
969 musb_ep->wedged = 0;
969 status = 0; 970 status = 0;
970 971
971 pr_debug("%s periph: enabled %s for %s %s, %smaxpacket %d\n", 972 pr_debug("%s periph: enabled %s for %s %s, %smaxpacket %d\n",
@@ -1262,7 +1263,8 @@ int musb_gadget_set_halt(struct usb_ep *ep, int value)
1262 goto done; 1263 goto done;
1263 } 1264 }
1264 } 1265 }
1265 } 1266 } else
1267 musb_ep->wedged = 0;
1266 1268
1267 /* set/clear the stall and toggle bits */ 1269 /* set/clear the stall and toggle bits */
1268 DBG(2, "%s: %s stall\n", ep->name, value ? "set" : "clear"); 1270 DBG(2, "%s: %s stall\n", ep->name, value ? "set" : "clear");
@@ -1301,6 +1303,21 @@ done:
1301 return status; 1303 return status;
1302} 1304}
1303 1305
1306/*
1307 * Sets the halt feature with the clear requests ignored
1308 */
1309int musb_gadget_set_wedge(struct usb_ep *ep)
1310{
1311 struct musb_ep *musb_ep = to_musb_ep(ep);
1312
1313 if (!ep)
1314 return -EINVAL;
1315
1316 musb_ep->wedged = 1;
1317
1318 return usb_ep_set_halt(ep);
1319}
1320
1304static int musb_gadget_fifo_status(struct usb_ep *ep) 1321static int musb_gadget_fifo_status(struct usb_ep *ep)
1305{ 1322{
1306 struct musb_ep *musb_ep = to_musb_ep(ep); 1323 struct musb_ep *musb_ep = to_musb_ep(ep);
@@ -1371,6 +1388,7 @@ static const struct usb_ep_ops musb_ep_ops = {
1371 .queue = musb_gadget_queue, 1388 .queue = musb_gadget_queue,
1372 .dequeue = musb_gadget_dequeue, 1389 .dequeue = musb_gadget_dequeue,
1373 .set_halt = musb_gadget_set_halt, 1390 .set_halt = musb_gadget_set_halt,
1391 .set_wedge = musb_gadget_set_wedge,
1374 .fifo_status = musb_gadget_fifo_status, 1392 .fifo_status = musb_gadget_fifo_status,
1375 .fifo_flush = musb_gadget_fifo_flush 1393 .fifo_flush = musb_gadget_fifo_flush
1376}; 1394};
diff --git a/drivers/usb/musb/musb_gadget.h b/drivers/usb/musb/musb_gadget.h
index 59502da9f739..90966695ae53 100644
--- a/drivers/usb/musb/musb_gadget.h
+++ b/drivers/usb/musb/musb_gadget.h
@@ -75,6 +75,8 @@ struct musb_ep {
75 /* later things are modified based on usage */ 75 /* later things are modified based on usage */
76 struct list_head req_list; 76 struct list_head req_list;
77 77
78 u8 wedged;
79
78 /* true if lock must be dropped but req_list may not be advanced */ 80 /* true if lock must be dropped but req_list may not be advanced */
79 u8 busy; 81 u8 busy;
80}; 82};
diff --git a/drivers/usb/musb/musb_gadget_ep0.c b/drivers/usb/musb/musb_gadget_ep0.c
index 1c44b975049c..c63aff110c45 100644
--- a/drivers/usb/musb/musb_gadget_ep0.c
+++ b/drivers/usb/musb/musb_gadget_ep0.c
@@ -273,6 +273,11 @@ __acquires(musb->lock)
273 if (!musb_ep->desc) 273 if (!musb_ep->desc)
274 break; 274 break;
275 275
276 handled = 1;
277 /* Ignore request if endpoint is wedged */
278 if (musb_ep->wedged)
279 break;
280
276 /* REVISIT do it directly, no locking games */ 281 /* REVISIT do it directly, no locking games */
277 spin_unlock(&musb->lock); 282 spin_unlock(&musb->lock);
278 musb_gadget_set_halt(&musb_ep->end_point, 0); 283 musb_gadget_set_halt(&musb_ep->end_point, 0);
@@ -280,7 +285,6 @@ __acquires(musb->lock)
280 285
281 /* select ep0 again */ 286 /* select ep0 again */
282 musb_ep_select(mbase, 0); 287 musb_ep_select(mbase, 0);
283 handled = 1;
284 } break; 288 } break;
285 default: 289 default:
286 /* class, vendor, etc ... delegate */ 290 /* class, vendor, etc ... delegate */