aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulia Lawall <julia@diku.dk>2009-07-12 03:43:52 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2009-09-23 09:46:28 -0400
commit058e698b6372aa32b3b0dbbb81e5531a2ae3e56c (patch)
tree1b29534beb35d5aab02c448a1aa0dd406229ca3d
parentd12b85e7de1abce4db940ebb169f064583b5796e (diff)
USB: gadget: Drop NULL test on list_entry result
list_entry, which is an alias for container_of, cannot return NULL, as there is no way to add a NULL value to a doubly linked list. A simplified version of the semantic match that findds this problem is as follows: (http://www.emn.fr/x-info/coccinelle/) // <smpl> @r@ expression x,E; statement S1,S2; position p,p1; @@ *x = list_entry@p(...) ... when != x = E *if@p1 (x == NULL) S1 else S2 // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/usb/gadget/amd5536udc.c56
1 files changed, 25 insertions, 31 deletions
diff --git a/drivers/usb/gadget/amd5536udc.c b/drivers/usb/gadget/amd5536udc.c
index 77352ccc245e..d5b65962dd36 100644
--- a/drivers/usb/gadget/amd5536udc.c
+++ b/drivers/usb/gadget/amd5536udc.c
@@ -2378,40 +2378,34 @@ static irqreturn_t udc_data_in_isr(struct udc *dev, int ep_ix)
2378 if (!ep->cancel_transfer && !list_empty(&ep->queue)) { 2378 if (!ep->cancel_transfer && !list_empty(&ep->queue)) {
2379 req = list_entry(ep->queue.next, 2379 req = list_entry(ep->queue.next,
2380 struct udc_request, queue); 2380 struct udc_request, queue);
2381 if (req) { 2381 /*
2382 /* 2382 * length bytes transfered
2383 * length bytes transfered 2383 * check dma done of last desc. in PPBDU mode
2384 * check dma done of last desc. in PPBDU mode 2384 */
2385 */ 2385 if (use_dma_ppb_du) {
2386 if (use_dma_ppb_du) { 2386 td = udc_get_last_dma_desc(req);
2387 td = udc_get_last_dma_desc(req); 2387 if (td) {
2388 if (td) { 2388 dma_done =
2389 dma_done = 2389 AMD_GETBITS(td->status,
2390 AMD_GETBITS(td->status, 2390 UDC_DMA_IN_STS_BS);
2391 UDC_DMA_IN_STS_BS); 2391 /* don't care DMA done */
2392 /* don't care DMA done */
2393 req->req.actual =
2394 req->req.length;
2395 }
2396 } else {
2397 /* assume all bytes transferred */
2398 req->req.actual = req->req.length; 2392 req->req.actual = req->req.length;
2399 } 2393 }
2394 } else {
2395 /* assume all bytes transferred */
2396 req->req.actual = req->req.length;
2397 }
2400 2398
2401 if (req->req.actual == req->req.length) { 2399 if (req->req.actual == req->req.length) {
2402 /* complete req */ 2400 /* complete req */
2403 complete_req(ep, req, 0); 2401 complete_req(ep, req, 0);
2404 req->dma_going = 0; 2402 req->dma_going = 0;
2405 /* further request available ? */ 2403 /* further request available ? */
2406 if (list_empty(&ep->queue)) { 2404 if (list_empty(&ep->queue)) {
2407 /* disable interrupt */ 2405 /* disable interrupt */
2408 tmp = readl( 2406 tmp = readl(&dev->regs->ep_irqmsk);
2409 &dev->regs->ep_irqmsk); 2407 tmp |= AMD_BIT(ep->num);
2410 tmp |= AMD_BIT(ep->num); 2408 writel(tmp, &dev->regs->ep_irqmsk);
2411 writel(tmp,
2412 &dev->regs->ep_irqmsk);
2413 }
2414
2415 } 2409 }
2416 } 2410 }
2417 } 2411 }