Skip to contentSkip to conversation

staging: emxx_udc: use min helper macro for variable comparison

PATCH New Deepak R Varma 1 participant 1 message Nov 6, 2022 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: emxx_udc: use min helper macro for variable comparison

Simplify code by using min helper macros in place of lengthy if/else block oriented logical evaluation and value assignment. This issue is identified by coccicheck using the minmax.cocci file.

---
 drivers/staging/emxx_udc/emxx_udc.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/staging/emxx_udc/emxx_udc.c +1 -4
index b6abd3770e81..b4e19174bef2 100644
@@ -1004,10 +1004,7 @@ static int _nbu2ss_in_dma(struct nbu2ss_udc *udc, struct nbu2ss_ep *ep,
 	/* MAX Packet Size */
 	mpkt = _nbu2ss_readl(&preg->EP_REGS[num].EP_PCKT_ADRS) & EPN_MPKT;
 
-	if ((DMA_MAX_COUNT * mpkt) < length)
-		i_write_length = DMA_MAX_COUNT * mpkt;
-	else
-		i_write_length = length;
+	i_write_length = min(DMA_MAX_COUNT * mpkt, length);
 
 	/*------------------------------------------------------------*/
 	/* Number of transmission packets */

--
2.34.1