aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Baldyga <r.baldyga@samsung.com>2013-10-09 02:20:02 -0400
committerFelipe Balbi <balbi@ti.com>2013-10-10 11:16:43 -0400
commite9edd199d69034fa163c97ef310ca72dca9cf030 (patch)
tree7fa8dbc67c0939c33ae6b0378f2daadfe528c1f4
parentdc807576d239239433cbb95d891ea23a820528c1 (diff)
usb: gadget: s3c-hsotg: fix set_ep_maxpacket function
This patch fixes max packet size check in s3c_hsotg_set_ep_maxpacket() function. According USB specification, bits 10..0 of mps specifies maximum packet size, so there is bitwise AND between mps and 0x7ff value. Also added check if maxpacket isn't grater than 1024 which is maximum size od single USB transaction. In s3c_hsotg_ep_enable() function added s3c_hsotg_set_ep_maxpacket() call instead of setting ep.maxpacket value directly. Signed-off-by: Robert Baldyga <r.baldyga@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r--drivers/usb/gadget/s3c-hsotg.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index 4691df732c42..424b2ad00ec7 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -1705,15 +1705,14 @@ static void s3c_hsotg_set_ep_maxpacket(struct s3c_hsotg *hsotg,
1705 mpsval = s3c_hsotg_ep0_mps(mps); 1705 mpsval = s3c_hsotg_ep0_mps(mps);
1706 if (mpsval > 3) 1706 if (mpsval > 3)
1707 goto bad_mps; 1707 goto bad_mps;
1708 hs_ep->ep.maxpacket = mps;
1708 } else { 1709 } else {
1709 if (mps >= DxEPCTL_MPS_LIMIT+1) 1710 mpsval = mps & DxEPCTL_MPS_MASK;
1711 if (mpsval > 1024)
1710 goto bad_mps; 1712 goto bad_mps;
1711 1713 hs_ep->ep.maxpacket = mpsval;
1712 mpsval = mps;
1713 } 1714 }
1714 1715
1715 hs_ep->ep.maxpacket = mps;
1716
1717 /* 1716 /*
1718 * update both the in and out endpoint controldir_ registers, even 1717 * update both the in and out endpoint controldir_ registers, even
1719 * if one of the directions may not be in use. 1718 * if one of the directions may not be in use.
@@ -2579,7 +2578,7 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep,
2579 epctrl |= DxEPCTL_SNAK; 2578 epctrl |= DxEPCTL_SNAK;
2580 2579
2581 /* update the endpoint state */ 2580 /* update the endpoint state */
2582 hs_ep->ep.maxpacket = mps; 2581 s3c_hsotg_set_ep_maxpacket(hsotg, hs_ep->index, mps);
2583 2582
2584 /* default, set to non-periodic */ 2583 /* default, set to non-periodic */
2585 hs_ep->periodic = 0; 2584 hs_ep->periodic = 0;