Skip to content

Commit

Permalink
net: variables reach -1, but 0 tested
Browse files Browse the repository at this point in the history
while (timeout--) { ... }

timeout becomes -1 if the loop isn't ended otherwise, not 0.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Roel Kluin authored and David S. Miller committed Feb 3, 2009
1 parent 0047e5d commit 46578a6
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions drivers/net/ibm_newemac/phy.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ int emac_mii_reset_phy(struct mii_phy *phy)

udelay(300);

while (limit--) {
while (--limit) {
val = phy_read(phy, MII_BMCR);
if (val >= 0 && (val & BMCR_RESET) == 0)
break;
Expand All @@ -84,7 +84,7 @@ int emac_mii_reset_gpcs(struct mii_phy *phy)

udelay(300);

while (limit--) {
while (--limit) {
val = gpcs_phy_read(phy, MII_BMCR);
if (val >= 0 && (val & BMCR_RESET) == 0)
break;
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/smc911x.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,9 @@ static void smc911x_reset(struct net_device *dev)

/* make sure EEPROM has finished loading before setting GPIO_CFG */
timeout=1000;
while ( timeout-- && (SMC_GET_E2P_CMD(lp) & E2P_CMD_EPC_BUSY_)) {
while (--timeout && (SMC_GET_E2P_CMD(lp) & E2P_CMD_EPC_BUSY_))
udelay(10);
}

if (timeout == 0){
PRINTK("%s: smc911x_reset timeout waiting for EEPROM busy\n", dev->name);
return;
Expand Down
12 changes: 6 additions & 6 deletions drivers/net/smsc9420.c
Original file line number Diff line number Diff line change
Expand Up @@ -498,21 +498,21 @@ static void smsc9420_check_mac_address(struct net_device *dev)
static void smsc9420_stop_tx(struct smsc9420_pdata *pd)
{
u32 dmac_control, mac_cr, dma_intr_ena;
int timeOut = 1000;
int timeout = 1000;

/* disable TX DMAC */
dmac_control = smsc9420_reg_read(pd, DMAC_CONTROL);
dmac_control &= (~DMAC_CONTROL_ST_);
smsc9420_reg_write(pd, DMAC_CONTROL, dmac_control);

/* Wait max 10ms for transmit process to stop */
while (timeOut--) {
while (--timeout) {
if (smsc9420_reg_read(pd, DMAC_STATUS) & DMAC_STS_TS_)
break;
udelay(10);
}

if (!timeOut)
if (!timeout)
smsc_warn(IFDOWN, "TX DMAC failed to stop");

/* ACK Tx DMAC stop bit */
Expand Down Expand Up @@ -596,7 +596,7 @@ static void smsc9420_free_rx_ring(struct smsc9420_pdata *pd)

static void smsc9420_stop_rx(struct smsc9420_pdata *pd)
{
int timeOut = 1000;
int timeout = 1000;
u32 mac_cr, dmac_control, dma_intr_ena;

/* mask RX DMAC interrupts */
Expand All @@ -617,13 +617,13 @@ static void smsc9420_stop_rx(struct smsc9420_pdata *pd)
smsc9420_pci_flush_write(pd);

/* wait up to 10ms for receive to stop */
while (timeOut--) {
while (--timeout) {
if (smsc9420_reg_read(pd, DMAC_STATUS) & DMAC_STS_RS_)
break;
udelay(10);
}

if (!timeOut)
if (!timeout)
smsc_warn(IFDOWN, "RX DMAC did not stop! timeout.");

/* ACK the Rx DMAC stop bit */
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/sungem.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ static u16 __phy_read(struct gem *gp, int phy_addr, int reg)
cmd |= (MIF_FRAME_TAMSB);
writel(cmd, gp->regs + MIF_FRAME);

while (limit--) {
while (--limit) {
cmd = readl(gp->regs + MIF_FRAME);
if (cmd & MIF_FRAME_TALSB)
break;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/sunqe.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ static int qe_init(struct sunqe *qep, int from_irq)
if (!(sbus_readb(mregs + MREGS_PHYCONFIG) & MREGS_PHYCONFIG_LTESTDIS)) {
int tries = 50;

while (tries--) {
while (--tries) {
u8 tmp;

mdelay(5);
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/tsi108_eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -1237,7 +1237,7 @@ static void tsi108_init_phy(struct net_device *dev)
spin_lock_irqsave(&phy_lock, flags);

tsi108_write_mii(data, MII_BMCR, BMCR_RESET);
while (i--){
while (--i) {
if(!(tsi108_read_mii(data, MII_BMCR) & BMCR_RESET))
break;
udelay(10);
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/tulip/de2104x.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ static void de_rx (struct de_private *de)
unsigned drop = 0;
int rc;

while (rx_work--) {
while (--rx_work) {
u32 status, len;
dma_addr_t mapping;
struct sk_buff *skb, *copy_skb;
Expand Down

0 comments on commit 46578a6

Please sign in to comment.