]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
usb: gadget: lpc32xx_udc: Remove NULL check of list_entry()
authorYuesong Li <liyuesong@vivo.com>
Wed, 21 Aug 2024 08:52:45 +0000 (16:52 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 22 Aug 2024 09:17:56 +0000 (17:17 +0800)
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>
drivers/usb/gadget/udc/lpc32xx_udc.c

index d5f29f8fe481311d5c4278cc5a7313264e63852e..3bfd889ed56a47623138854ea062105f0b0dae75 100644 (file)
@@ -1487,31 +1487,29 @@ static int udc_ep0_out_req(struct lpc32xx_udc *udc)
                req = list_entry(ep0->queue.next, struct lpc32xx_request,
                                 queue);
 
-       if (req) {
-               if (req->req.length == 0) {
-                       /* Just dequeue request */
-                       done(ep0, req, 0);
-                       udc->ep0state = WAIT_FOR_SETUP;
-                       return 1;
-               }
+       if (req->req.length == 0) {
+               /* Just dequeue request */
+               done(ep0, req, 0);
+               udc->ep0state = WAIT_FOR_SETUP;
+               return 1;
+       }
 
-               /* Get data from FIFO */
-               bufferspace = req->req.length - req->req.actual;
-               if (bufferspace > ep0->ep.maxpacket)
-                       bufferspace = ep0->ep.maxpacket;
+       /* Get data from FIFO */
+       bufferspace = req->req.length - req->req.actual;
+       if (bufferspace > ep0->ep.maxpacket)
+               bufferspace = ep0->ep.maxpacket;
 
-               /* Copy data to buffer */
-               prefetchw(req->req.buf + req->req.actual);
-               tr = udc_read_hwep(udc, EP_OUT, req->req.buf + req->req.actual,
-                                  bufferspace);
-               req->req.actual += bufferspace;
+       /* Copy data to buffer */
+       prefetchw(req->req.buf + req->req.actual);
+       tr = udc_read_hwep(udc, EP_OUT, req->req.buf + req->req.actual,
+                          bufferspace);
+       req->req.actual += bufferspace;
 
-               if (tr < ep0->ep.maxpacket) {
-                       /* This is the last packet */
-                       done(ep0, req, 0);
-                       udc->ep0state = WAIT_FOR_SETUP;
-                       return 1;
-               }
+       if (tr < ep0->ep.maxpacket) {
+               /* This is the last packet */
+               done(ep0, req, 0);
+               udc->ep0state = WAIT_FOR_SETUP;
+               return 1;
        }
 
        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 */
        req = list_entry(ep->queue.next, struct lpc32xx_request, queue);
-       if (req) {
-               done(ep, req, 0);
 
-               /* Start another request if ready */
-               if (!list_empty(&ep->queue)) {
-                       if (ep->is_in)
-                               udc_ep_in_req_dma(udc, ep);
-                       else
-                               udc_ep_out_req_dma(udc, ep);
-               } else
-                       ep->req_pending = 0;
-       }
+       done(ep, req, 0);
+
+       /* Start another request if ready */
+       if (!list_empty(&ep->queue)) {
+               if (ep->is_in)
+                       udc_ep_in_req_dma(udc, ep);
+               else
+                       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
 
        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;
 
        /* DMA descriptor should always be retired for this call */