Skip to contentSkip to conversation

polling loops: change exit condition to

PATCH In review Marcin Slusarz 1 participant 1 message Dec 4, 2005

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

PATCH 14/21 polling loops: change exit condition to

small bug in drivers/net/sis190.c - "i" never reached 1000

NETWORK DEVICE DRIVERS
P: Andrew Morton
M: [email protected]
P: Jeff Garzik
M: [email protected]

drivers/net/bnx2.c +4 -3
diff -upr -X linux-2.6.15-rc4/Documentation/dontdiff linux-2.6.15-rc4-orig/drivers/net/bnx2.c linux-2.6.15-rc4/drivers/net/bnx2.c
@@ -4055,9 +4055,9 @@ bnx2_test_link(struct bnx2 *bp)
 static int
 bnx2_test_intr(struct bnx2 *bp)
 {
-	int i;
 	u32 val;
 	u16 status_idx;
+	unsigned long end_time;
 
 	if (!netif_running(bp->dev))
 		return -ENODEV;
@@ -4069,7 +4069,8 @@ bnx2_test_intr(struct bnx2 *bp)
 	REG_WR(bp, BNX2_HC_COMMAND, val | BNX2_HC_COMMAND_COAL_NOW);
 	REG_RD(bp, BNX2_HC_COMMAND);
 
-	for (i = 0; i < 10; i++) {
+	end_time = jiffies + msecs_to_jiffies(100);
+	while (time_before(jiffies, end_time)) {
 		if ((REG_RD(bp, BNX2_PCICFG_INT_ACK_CMD) & 0xffff) ! 			status_idx) {
 
@@ -4078,7 +4079,7 @@ bnx2_test_intr(struct bnx2 *bp)
 
 		msleep_interruptible(10);
 	}
-	if (i < 10)
+	if (time_before(jiffies, end_time))
 		return 0;
 
 	return -ENODEV;
drivers/net/pcmcia/xirc2ps_cs.c +7 -7
diff -upr -X linux-2.6.15-rc4/Documentation/dontdiff linux-2.6.15-rc4-orig/drivers/net/pcmcia/xirc2ps_cs.c linux-2.6.15-rc4/drivers/net/pcmcia/xirc2ps_cs.c
@@ -1871,7 +1871,7 @@ init_mii(struct net_device *dev)
     local_info_t *local = netdev_priv(dev);
     kio_addr_t ioaddr = dev->base_addr;
     unsigned control, status, linkpartner;
-    int i;
+	unsigned long end_time;
 
     if (if_port = 4 || if_port = 1) { /* force 100BaseT or 10BaseT */
 	dev->if_port = if_port;
@@ -1905,13 +1905,13 @@ init_mii(struct net_device *dev)
     if (local->probe_port) {
 	/* according to the DP83840A specs the auto negotiation process
 	 * may take up to 3.5 sec, so we use this also for our ML6692
-	 * Fixme: Better to use a timer here!
 	 */
-	for (i=0; i < 35; i++) {
-	    msleep(100);	 /* wait 100 msec */
-	    status = mii_rd(ioaddr,  0, 1);
-	    if ((status & 0x0020) && (status & 0x0004))
-		break;
+	end_time = jiffies + msecs_to_jiffies(3500);
+	while (time_before(jiffies, end_time)) {
+		msleep(100);	 /* wait 100 msec */
+		status = mii_rd(ioaddr,  0, 1);
+		if ((status & 0x0020) && (status & 0x0004))
+			break;
 	}
 
 	if (!(status & 0x0020)) {
drivers/net/s2io.c +28 -27

203 lines not on this page · raw message

drivers/net/sis190.c +7 -5
diff -upr -X linux-2.6.15-rc4/Documentation/dontdiff linux-2.6.15-rc4-orig/drivers/net/sis190.c linux-2.6.15-rc4/drivers/net/sis190.c
@@ -370,19 +370,20 @@ static int multicast_filter_limit = 32;
 
 static void __mdio_cmd(void __iomem *ioaddr, u32 ctl)
 {
-	unsigned int i;
+	unsigned long end_time;
 
 	SIS_W32(GMIIControl, ctl);
 
 	msleep(1);
 
-	for (i = 0; i < 100; i++) {
+	end_time = jiffies + msecs_to_jiffies(100);
+	while (time_before(jiffies, end_time)) {
 		if (!(SIS_R32(GMIIControl) & EhnMIInotDone))
 			break;
 		msleep(1);
 	}
 
-	if (i > 999)
+	if (time_after_eq(jiffies, end_time))
 		printk(KERN_ERR PFX "PHY command failed !\n");
 }
 
@@ -424,14 +425,15 @@ static u16 mdio_read_latched(void __iome
 static u16 __devinit sis190_read_eeprom(void __iomem *ioaddr, u32 reg)
 {
 	u16 data = 0xffff;
-	unsigned int i;
+	unsigned long end_time;
 
 	if (!(SIS_R32(ROMControl) & 0x0002))
 		return 0;
 
 	SIS_W32(ROMInterface, EEREQ | EEROP | (reg << 10));
 
-	for (i = 0; i < 200; i++) {
+	end_time = jiffies + msecs_to_jiffies(200);
+	while (time_before(jiffies, end_time)) {
 		if (!(SIS_R32(ROMInterface) & EEREQ)) {
 			data = (SIS_R32(ROMInterface) & 0xffff0000) >> 16;
 			break;

SKGE, SKY2 10/100/1000 GIGABIT ETHERNET DRIVERS
P: Stephen Hemminger
M: [email protected]

drivers/net/skge.c +5 -5
diff -upr -X linux-2.6.15-rc4/Documentation/dontdiff linux-2.6.15-rc4-orig/drivers/net/skge.c linux-2.6.15-rc4/drivers/net/skge.c
@@ -680,21 +680,21 @@ static void skge_led(struct skge_port *s
 static int skge_phys_id(struct net_device *dev, u32 data)
 {
 	struct skge_port *skge = netdev_priv(dev);
-	unsigned long ms;
+	unsigned long end_time;
 	enum led_mode mode = LED_MODE_TST;
 
 	if (!data || data > (u32)(MAX_SCHEDULE_TIMEOUT / HZ))
-		ms = jiffies_to_msecs(MAX_SCHEDULE_TIMEOUT / HZ) * 1000;
+		end_time = jiffies_to_msecs(MAX_SCHEDULE_TIMEOUT / HZ) * 1000;
 	else
-		ms = data * 1000;
+		end_time = data * 1000;
 
-	while (ms > 0) {
+	end_time = jiffies + msecs_to_jiffies(end_time);
+	while (time_before(jiffies, end_time)) {
 		skge_led(skge, mode);
 		mode ^= LED_MODE_TST;
 
 		if (msleep_interruptible(BLINK_MS))
 			break;
-		ms -= BLINK_MS;
 	}
 
 	/* back to regular LED state */
drivers/net/tg3.c +4 -2
diff -upr -X linux-2.6.15-rc4/Documentation/dontdiff linux-2.6.15-rc4-orig/drivers/net/tg3.c linux-2.6.15-rc4/drivers/net/tg3.c
@@ -6229,7 +6229,8 @@ static void tg3_timer(unsigned long __op
 static int tg3_test_interrupt(struct tg3 *tp)
 {
 	struct net_device *dev = tp->dev;
-	int err, i;
+	int err;
+	unsigned long end_time;
 	u32 int_mbox = 0;
 
 	if (!netif_running(dev))
@@ -6250,7 +6251,8 @@ static int tg3_test_interrupt(struct tg3
 	tw32_f(HOSTCC_MODE, tp->coalesce_mode | HOSTCC_MODE_ENABLE |
 	       HOSTCC_MODE_NOW);
 
-	for (i = 0; i < 5; i++) {
+	end_time = jiffies + msecs_to_jiffies(50);
+	while (time_before(jiffies, end_time)) {
 		int_mbox = tr32_mailbox(MAILBOX_INTERRUPT_0 +
 					TG3_64BIT_REG_LOW);
 		if (int_mbox != 0)
drivers/net/wan/cycx_drv.c +5 -3
diff -upr -X linux-2.6.15-rc4/Documentation/dontdiff linux-2.6.15-rc4-orig/drivers/net/wan/cycx_drv.c linux-2.6.15-rc4/drivers/net/wan/cycx_drv.c
@@ -383,7 +383,7 @@ static int cycx_code_boot(void __iomem *
  * o start adapter up */
 static int load_cyc2x(struct cycx_hw *hw, struct cycx_firmware *cfm, u32 len)
 {
-	int i, j;
+	unsigned long end_time, end_time2;
 	struct cycx_fw_header *img_hdr;
 	u8 *reset_image,
 	   *data_image,
@@ -448,7 +448,8 @@ static int load_cyc2x(struct cycx_hw *hw
 			 cfm->descr[0] ? cfm->descr : "unknown firmware",
 			 cfm->info.codeid);
 
-	for (i = 0 ; i < 5 ; i++) {
+	end_time = jiffies + msecs_to_jiffies(20000);
+	while (time_before(jiffies, end_time)) {
 		/* Reset Cyclom hardware */
 		if (!reset_cyc2x(hw->dpmbase)) {
 			printk(KERN_ERR "%s: dpm problem or board not found\n",
@@ -462,7 +463,8 @@ static int load_cyc2x(struct cycx_hw *hw
 		writew(GEN_POWER_ON, pt_cycld);
 		msleep_interruptible(1 * 1000);
 
-		for (j = 0 ; j < 3 ; j++)
+		end_time2 = jiffies + msecs_to_jiffies(3000);
+		while (time_before(jiffies, end_time2))
 			if (!readw(pt_cycld))
 				goto reset_loaded;
 			else

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors