1

usb: gadget: lpc32xx_udc: Remove NULL check of list_entry()

list_entry() will never return a NULL pointer, thus remove the
check.

Signed-off-by: Yuesong Li <liyuesong@vivo.com>
Reviewed-by: Vladimir Zapolskiy <vz@mleia.com>
Link: https://lore.kernel.org/r/20240821085245.25348-1-liyuesong@vivo.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Yuesong Li 2024-08-21 16:52:45 +08:00 committed by Greg Kroah-Hartman
parent e24ed5e2f9
commit 7393bf343a

View File

@ -1487,31 +1487,29 @@ static int udc_ep0_out_req(struct lpc32xx_udc *udc)
req = list_entry(ep0->queue.next, struct lpc32xx_request, req = list_entry(ep0->queue.next, struct lpc32xx_request,
queue); queue);
if (req) { if (req->req.length == 0) {
if (req->req.length == 0) { /* Just dequeue request */
/* Just dequeue request */ done(ep0, req, 0);
done(ep0, req, 0); udc->ep0state = WAIT_FOR_SETUP;
udc->ep0state = WAIT_FOR_SETUP; return 1;
return 1; }
}
/* Get data from FIFO */ /* Get data from FIFO */
bufferspace = req->req.length - req->req.actual; bufferspace = req->req.length - req->req.actual;
if (bufferspace > ep0->ep.maxpacket) if (bufferspace > ep0->ep.maxpacket)
bufferspace = ep0->ep.maxpacket; bufferspace = ep0->ep.maxpacket;
/* Copy data to buffer */ /* Copy data to buffer */
prefetchw(req->req.buf + req->req.actual); prefetchw(req->req.buf + req->req.actual);
tr = udc_read_hwep(udc, EP_OUT, req->req.buf + req->req.actual, tr = udc_read_hwep(udc, EP_OUT, req->req.buf + req->req.actual,
bufferspace); bufferspace);
req->req.actual += bufferspace; req->req.actual += bufferspace;
if (tr < ep0->ep.maxpacket) { if (tr < ep0->ep.maxpacket) {
/* This is the last packet */ /* This is the last packet */
done(ep0, req, 0); done(ep0, req, 0);
udc->ep0state = WAIT_FOR_SETUP; udc->ep0state = WAIT_FOR_SETUP;
return 1; return 1;
}
} }
return 0; return 0;
@ -1962,18 +1960,17 @@ static void udc_handle_eps(struct lpc32xx_udc *udc, struct lpc32xx_ep *ep)
/* If there isn't a request waiting, something went wrong */ /* If there isn't a request waiting, something went wrong */
req = list_entry(ep->queue.next, struct lpc32xx_request, queue); req = list_entry(ep->queue.next, struct lpc32xx_request, queue);
if (req) {
done(ep, req, 0);
/* Start another request if ready */ done(ep, req, 0);
if (!list_empty(&ep->queue)) {
if (ep->is_in) /* Start another request if ready */
udc_ep_in_req_dma(udc, ep); if (!list_empty(&ep->queue)) {
else if (ep->is_in)
udc_ep_out_req_dma(udc, ep); udc_ep_in_req_dma(udc, ep);
} else else
ep->req_pending = 0; udc_ep_out_req_dma(udc, ep);
} } else
ep->req_pending = 0;
} }
@ -1989,10 +1986,6 @@ static void udc_handle_dma_ep(struct lpc32xx_udc *udc, struct lpc32xx_ep *ep)
#endif #endif
req = list_entry(ep->queue.next, struct lpc32xx_request, queue); req = list_entry(ep->queue.next, struct lpc32xx_request, queue);
if (!req) {
ep_err(ep, "DMA interrupt on no req!\n");
return;
}
dd = req->dd_desc_ptr; dd = req->dd_desc_ptr;
/* DMA descriptor should always be retired for this call */ /* DMA descriptor should always be retired for this call */