Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: gadget: net2280: use swap() instead of open coding it

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>

authored by

Guo Zhengkui and committed by
Greg Kroah-Hartman
67ec2c75 b8a19881

+3 -11
+3 -11
drivers/usb/gadget/udc/net2280.c
··· 932 932 static inline void 933 933 queue_dma(struct net2280_ep *ep, struct net2280_request *req, int valid) 934 934 { 935 - struct net2280_dma *end; 936 - dma_addr_t tmp; 937 - 938 935 /* swap new dummy for old, link; fill and maybe activate */ 939 - end = ep->dummy; 940 - ep->dummy = req->td; 941 - req->td = end; 936 + swap(ep->dummy, req->td); 937 + swap(ep->td_dma, req->td_dma); 942 938 943 - tmp = ep->td_dma; 944 - ep->td_dma = req->td_dma; 945 - req->td_dma = tmp; 946 - 947 - end->dmadesc = cpu_to_le32 (ep->td_dma); 939 + req->td->dmadesc = cpu_to_le32 (ep->td_dma); 948 940 949 941 fill_dma_desc(ep, req, valid); 950 942 }