linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] USB: UDC: use swap() to make code cleaner
@ 2021-11-04  1:12 davidcomponentone
  2021-11-04 10:50 ` Andy Shevchenko
  0 siblings, 1 reply; 2+ messages in thread
From: davidcomponentone @ 2021-11-04  1:12 UTC (permalink / raw)
  To: balbi
  Cc: davidcomponentone, gregkh, colin.king, stern, yang.guang5,
	linux-usb, linux-kernel, Zeal Robot

From: Yang Guang <yang.guang5@zte.com.cn>

Use the macro 'swap()' defined in 'include/linux/minmax.h' to avoid
opencoding it.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Yang Guang <yang.guang5@zte.com.cn>
---
 drivers/usb/gadget/udc/net2280.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
index 16e7d2db6411..71e02bcebecd 100644
--- a/drivers/usb/gadget/udc/net2280.c
+++ b/drivers/usb/gadget/udc/net2280.c
@@ -933,16 +933,13 @@ 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->td_dma, req->td_dma);
 
 	end->dmadesc = cpu_to_le32 (ep->td_dma);
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] USB: UDC: use swap() to make code cleaner
  2021-11-04  1:12 [PATCH] USB: UDC: use swap() to make code cleaner davidcomponentone
@ 2021-11-04 10:50 ` Andy Shevchenko
  0 siblings, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2021-11-04 10:50 UTC (permalink / raw)
  To: davidcomponentone
  Cc: Felipe Balbi, Greg Kroah-Hartman, Colin King, Alan Stern,
	Yang Guang, USB, Linux Kernel Mailing List, Zeal Robot

On Thu, Nov 4, 2021 at 3:14 AM <davidcomponentone@gmail.com> wrote:

> Use the macro 'swap()' defined in 'include/linux/minmax.h' to avoid
> opencoding it.

Same comment as per all your valuable contributions: think about the
code you are modifying a little bit more. Okay?

>         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->td_dma, req->td_dma);

Interestingly, why the previous paragraph was not detected by you as
an opportunity to convert as well?

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-11-04 10:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-04  1:12 [PATCH] USB: UDC: use swap() to make code cleaner davidcomponentone
2021-11-04 10:50 ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).