Skip to contentSkip to conversation

netxen: only half timeout waited

PATCH In review Roel Kluin 2 participants 3 messages Feb 16, 2009 – Feb 17, 2009

Subsystems (2)
lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 netxen: only half timeout waited

Only half the timeout was waited, due to the double increment, and an error occurred one too early.

---

drivers/net/netxen/netxen_nic_niu.c +2 -4
index c3b9c83..df3aa08 100644
@@ -147,12 +147,11 @@ int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long reg,
 					  NETXEN_NIU_GB_MII_MGMT_INDICATE(0),
 					  &status, 4))
 			return -EIO;
-		timeout++;
 	} while ((netxen_get_gb_mii_mgmt_busy(status)
 		  || netxen_get_gb_mii_mgmt_notvalid(status))
 		 && (timeout++ < NETXEN_NIU_PHY_WAITMAX));
 
-	if (timeout < NETXEN_NIU_PHY_WAITMAX) {
+	if (timeout <= NETXEN_NIU_PHY_WAITMAX) {
 		if (adapter->hw_read_wx(adapter,
 					  NETXEN_NIU_GB_MII_MGMT_STATUS(0),
 					  readval, 4))
@@ -240,11 +239,10 @@ int netxen_niu_gbe_phy_write(struct netxen_adapter *adapter, long reg,
 					  NETXEN_NIU_GB_MII_MGMT_INDICATE(0),
 					  &status, 4))
 			return -EIO;
-		timeout++;
 	} while ((netxen_get_gb_mii_mgmt_busy(status))
 		 && (timeout++ < NETXEN_NIU_PHY_WAITMAX));
 
-	if (timeout < NETXEN_NIU_PHY_WAITMAX)
+	if (timeout <= NETXEN_NIU_PHY_WAITMAX)
 		result = 0;
 	else
 		result = -EIO;
#1 lore raw
Quoted 10 lines · Roel Kluin

Only half the timeout was waited, due to the double increment, and an error occurred one too early.

---

drivers/net/netxen/netxen_nic_niu.c +0 -0
index c3b9c83..df3aa08 100644

drivers/net/netxen/netxen_nic_niu.c int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long reg, · line 154

Quoted 10 lines
drivers/net/netxen/netxen_nic_niu.c +1 -2
@@ -147,12 +147,11 @@ int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long reg,
 					  NETXEN_NIU_GB_MII_MGMT_INDICATE(0),
 					  &status, 4))
 			return -EIO;
-		timeout++;
 	} while ((netxen_get_gb_mii_mgmt_busy(status)
 		  || netxen_get_gb_mii_mgmt_notvalid(status))
 		 && (timeout++ < NETXEN_NIU_PHY_WAITMAX));
 
-	if (timeout < NETXEN_NIU_PHY_WAITMAX) {
+	if (timeout <= NETXEN_NIU_PHY_WAITMAX) {

Roel, very good caches, but IMHO in all such cases changing to ++timeout with 'if (timeout == NETXEN_NIU_PHY_WAITMAX)' where possible, should be really more readable. At least wrt. next similar patches.

Thanks,
Jarek P.

Quoted 16 lines
drivers/net/netxen/netxen_nic_niu.c +1 -2
 		if (adapter->hw_read_wx(adapter,
 					  NETXEN_NIU_GB_MII_MGMT_STATUS(0),
 					  readval, 4))
@@ -240,11 +239,10 @@ int netxen_niu_gbe_phy_write(struct netxen_adapter *adapter, long reg,
 					  NETXEN_NIU_GB_MII_MGMT_INDICATE(0),
 					  &status, 4))
 			return -EIO;
-		timeout++;
 	} while ((netxen_get_gb_mii_mgmt_busy(status))
 		 && (timeout++ < NETXEN_NIU_PHY_WAITMAX));
 
-	if (timeout < NETXEN_NIU_PHY_WAITMAX)
+	if (timeout <= NETXEN_NIU_PHY_WAITMAX)
 		result = 0;
 	else
 		result = -EIO;
#2 lore raw
Quoted 19 lines · Jarek Poplawski
Quoted 18 lines · Roel Kluin

Only half the timeout was waited, due to the double increment, and an error occurred one too early.

---

drivers/net/netxen/netxen_nic_niu.c +0 -1
index c3b9c83..df3aa08 100644
@@ -147,12 +147,11 @@ int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long reg,
 					  NETXEN_NIU_GB_MII_MGMT_INDICATE(0),
 					  &status, 4))
 			return -EIO;
-		timeout++;
 	} while ((netxen_get_gb_mii_mgmt_busy(status)
 		  || netxen_get_gb_mii_mgmt_notvalid(status))
 		 && (timeout++ < NETXEN_NIU_PHY_WAITMAX));
 
Quoted 5 lines

drivers/net/netxen/netxen_nic_niu.c int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long reg, · line 154

Quoted 2 lines
drivers/net/netxen/netxen_nic_niu.c +1 -1
-	if (timeout < NETXEN_NIU_PHY_WAITMAX) {
+	if (timeout <= NETXEN_NIU_PHY_WAITMAX) {

Roel, very good caches, but IMHO in all such cases changing to ++timeout with 'if (timeout == NETXEN_NIU_PHY_WAITMAX)' where

Hmm... of course 'if (timeout == NETXEN_NIU_PHY_WAITMAX)' for errcode; in this particular case: 'if (timeout < NETXEN_NIU_PHY_WAITMAX)' would be OK.

Jarek P.

Quoted 22 lines

possible, should be really more readable. At least wrt. next similar patches.

Thanks,
Jarek P.

Quoted 16 lines
drivers/net/netxen/netxen_nic_niu.c +1 -2
 		if (adapter->hw_read_wx(adapter,
 					  NETXEN_NIU_GB_MII_MGMT_STATUS(0),
 					  readval, 4))
@@ -240,11 +239,10 @@ int netxen_niu_gbe_phy_write(struct netxen_adapter *adapter, long reg,
 					  NETXEN_NIU_GB_MII_MGMT_INDICATE(0),
 					  &status, 4))
 			return -EIO;
-		timeout++;
 	} while ((netxen_get_gb_mii_mgmt_busy(status))
 		 && (timeout++ < NETXEN_NIU_PHY_WAITMAX));
 
-	if (timeout < NETXEN_NIU_PHY_WAITMAX)
+	if (timeout <= NETXEN_NIU_PHY_WAITMAX)
 		result = 0;
 	else
 		result = -EIO;