usb: gadget: net2280: use swap() instead of open coding it
authorGuo Zhengkui <guozhengkui@vivo.com>
Thu, 7 Apr 2022 10:04:52 +0000 (18:04 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 21 Apr 2022 17:03:11 +0000 (19:03 +0200)
Address the following coccicheck warning:
drivers/usb/gadget/udc/net2280.c:940:20-21: WARNING opportunity for swap().
drivers/usb/gadget/udc/net2280.c:944:25-26: WARNING opportunity for swap().

by using swap() for the swapping of variable values and drop the tmp
variables (`tmp` and `end`) that are not needed any more.

Signed-off-by: Guo Zhengkui <guozhengkui@vivo.com>
Link: https://lore.kernel.org/r/20220407100459.3605-1-guozhengkui@vivo.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/gadget/udc/net2280.c

index 051d024..d6a6863 100644 (file)
@@ -932,19 +932,11 @@ static void start_dma(struct net2280_ep *ep, struct net2280_request *req)
 static inline void
 queue_dma(struct net2280_ep *ep, struct net2280_request *req, int valid)
 {
-       struct net2280_dma      *end;
-       dma_addr_t              tmp;
-
        /* swap new dummy for old, link; fill and maybe activate */
-       end = ep->dummy;
-       ep->dummy = req->td;
-       req->td = end;
-
-       tmp = ep->td_dma;
-       ep->td_dma = req->td_dma;
-       req->td_dma = tmp;
+       swap(ep->dummy, req->td);
+       swap(ep->td_dma, req->td_dma);
 
-       end->dmadesc = cpu_to_le32 (ep->td_dma);
+       req->td->dmadesc = cpu_to_le32 (ep->td_dma);
 
        fill_dma_desc(ep, req, valid);
 }