[<prev] [next>] [day] [month] [year] [list]
Message-id: <1381299602-6304-1-git-send-email-r.baldyga@samsung.com>
Date: Wed, 09 Oct 2013 08:20:02 +0200
From: Robert Baldyga <r.baldyga@...sung.com>
To: balbi@...com
Cc: gregkh@...uxfoundation.org, linux-usb@...r.kernel.org,
linux-kernel@...r.kernel.org, b.zolnierkie@...sung.com,
m.szyprowski@...sung.com, andrzej.p@...sung.com,
Robert Baldyga <r.baldyga@...sung.com>,
Kyungmin Park <kyungmin.park@...sung.com>
Subject: [PATCH] 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@...sung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@...sung.com>
---
drivers/usb/gadget/s3c-hsotg.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index 5a15de0..139122a 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -1726,15 +1726,14 @@ static void s3c_hsotg_set_ep_maxpacket(struct s3c_hsotg *hsotg,
mpsval = s3c_hsotg_ep0_mps(mps);
if (mpsval > 3)
goto bad_mps;
+ hs_ep->ep.maxpacket = mps;
} else {
- if (mps >= DxEPCTL_MPS_LIMIT+1)
+ mpsval = mps & DxEPCTL_MPS_MASK;
+ if (mpsval > 1024)
goto bad_mps;
-
- mpsval = mps;
+ hs_ep->ep.maxpacket = mpsval;
}
- hs_ep->ep.maxpacket = mps;
-
/*
* update both the in and out endpoint controldir_ registers, even
* if one of the directions may not be in use.
@@ -2614,7 +2613,7 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep,
epctrl |= DxEPCTL_SNAK;
/* update the endpoint state */
- hs_ep->ep.maxpacket = mps;
+ s3c_hsotg_set_ep_maxpacket(hsotg, hs_ep->index, mps);
/* default, set to non-periodic */
hs_ep->periodic = 0;
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists