Skip to contentSkip to conversation

amd-xgbe: fix a couple timeout loops

PATCH Applied Dan Carpenter 2 participants 2 messages Dec 15, 2015

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 amd-xgbe: fix a couple timeout loops

At the end of the loop we test "if (!count)" but because "count--" is a post-op then the loop will end with count set to -1. I have fixed this by changing it to --count.

Fixes c5aa9e3b8156 ('amd-xgbe: Initial AMD 10GbE platform driver')
drivers/net/ethernet/amd/xgbe/xgbe-dev.c +2 -2
index 970781a..f6a7161 100644
@@ -1849,7 +1849,7 @@ static int xgbe_exit(struct xgbe_prv_data *pdata)
 	usleep_range(10, 15);
 
 	/* Poll Until Poll Condition */
-	while (count-- && XGMAC_IOREAD_BITS(pdata, DMA_MR, SWR))
+	while (--count && XGMAC_IOREAD_BITS(pdata, DMA_MR, SWR))
 		usleep_range(500, 600);
 
 	if (!count)
@@ -1873,7 +1873,7 @@ static int xgbe_flush_tx_queues(struct xgbe_prv_data *pdata)
 	/* Poll Until Poll Condition */
 	for (i = 0; i < pdata->tx_q_count; i++) {
 		count = 2000;
-		while (count-- && XGMAC_MTL_IOREAD_BITS(pdata, i,
+		while (--count && XGMAC_MTL_IOREAD_BITS(pdata, i,
 							MTL_Q_TQOMR, FTQ))
 			usleep_range(500, 600);
 
maintainer Applied
#1 lore raw

From: Dan Carpenter <[email protected]>
Date: Tue, 15 Dec 2015 13:12:29 +0300

Quoted 6 lines

At the end of the loop we test "if (!count)" but because "count--" is a post-op then the loop will end with count set to -1. I have fixed this by changing it to --count.

Fixes c5aa9e3b8156 ('amd-xgbe: Initial AMD 10GbE platform driver')

Applied.