Skip to contentSkip to conversation

polling loops: change exit condition to

PATCH In review Marcin Slusarz 2 participants 2 messages Dec 4, 2005 – Dec 10, 2005

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

PATCH 2/21 polling loops: change exit condition to

ATM
P: Chas Williams
M: [email protected]

drivers/atm/firestream.c +5 -4
diff -upr -X linux-2.6.15-rc4/Documentation/dontdiff linux-2.6.15-rc4-orig/drivers/atm/firestream.c linux-2.6.15-rc4/drivers/atm/firestream.c
@@ -1651,8 +1651,9 @@ static void fs_poll (unsigned long data)
 static int __devinit fs_init (struct fs_dev *dev)
 {
 	struct pci_dev  *pci_dev;
-	int isr, to;
+	int isr;
 	int i;
+	unsigned long end_time;
 
 	func_enter ();
 	pci_dev = dev->pci_dev;
@@ -1690,8 +1691,8 @@ static int __devinit fs_init (struct fs_
 
 	/* 10ms * 100 is 1 second. That should be enough, as AN3:9 says it takes
 	   1ms. */
-	to = 100;
-	while (--to) {
+	end_time = jiffies + msecs_to_jiffies(1000);
+	while (time_before(jiffies, end_time)) {
 		isr = read_fs (dev, ISR);
 
 		/* This bit is documented as "RESERVED" */
@@ -1708,7 +1709,7 @@ static int __devinit fs_init (struct fs_
 		msleep(10);
 	}
 
-	if (!to) {
+	if (time_after_eq(jiffies, end_time)) {
 		printk (KERN_ERR "timeout initializing the FS... \n");
 		return 1;
 	}
drivers/atm/he.c +5 -6
diff -upr -X linux-2.6.15-rc4/Documentation/dontdiff linux-2.6.15-rc4-orig/drivers/atm/he.c linux-2.6.15-rc4/drivers/atm/he.c
@@ -2550,8 +2550,9 @@ he_close(struct atm_vcc *vcc)
 	struct he_tpd *tpd;
 	unsigned cid;
 	struct he_vcc *he_vcc = HE_VCC(vcc);
-#define MAX_RETRY 30
-	int retry = 0, sleep = 1, tx_inuse;
+#define MAX_TIMEOUT 6000
+	int sleep = 1, tx_inuse;
+	unsigned long end_time;
 
 	HPRINTK("close vcc %p %d.%d\n", vcc, vcc->vpi, vcc->vci);
 
@@ -2607,14 +2608,12 @@ he_close(struct atm_vcc *vcc)
 		 * TBRQ. When the last packet on the connection arrives in the
 		 * TBRQ, the host issues the close command to the adapter.
 		 */
-
+		end_time = jiffies + msecs_to_jiffies(MAX_TIMEOUT);
 		while (((tx_inuse = atomic_read(&sk_atm(vcc)->sk_wmem_alloc)) > 0) &&
-		       (retry < MAX_RETRY)) {
+		       time_before(jiffies, end_time)) {
 			msleep(sleep);
 			if (sleep < 250)
 				sleep = sleep * 2;
-
-			++retry;
 		}
 
 		if (tx_inuse)

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

#1 lore raw

drivers/atm/he.c he_close(struct atm_vcc *vcc) · line 2553

Quoted 9 lines · Marcin Slusarz
drivers/atm/he.c +1 -2
@@ -2550,8 +2550,9 @@ he_close(struct atm_vcc *vcc)
 	struct he_tpd *tpd;
 	unsigned cid;
 	struct he_vcc *he_vcc = HE_VCC(vcc);
-#define MAX_RETRY 30
-	int retry = 0, sleep = 1, tx_inuse;
+#define MAX_TIMEOUT 6000

There is no point to keep this define. It's used only once.

You also forgot to include jiffies.h. This applies to the rest of the patchbomb.

Quoted 12 lines
drivers/atm/he.c +3 -1
+	int sleep = 1, tx_inuse;
+	unsigned long end_time;
 
 	HPRINTK("close vcc %p %d.%d\n", vcc, vcc->vpi, vcc->vci);
 
@@ -2607,14 +2608,12 @@ he_close(struct atm_vcc *vcc)
 		 * TBRQ. When the last packet on the connection arrives in 
 		 the
 		 * TBRQ, the host issues the close command to the adapter.
 		 */
-
+		end_time = jiffies + msecs_to_jiffies(MAX_TIMEOUT);

drivers/atm/he.c he_close(struct atm_vcc *vcc) · line 2619

Quoted 10 lines
drivers/atm/he.c +1 -3
 		while (((tx_inuse = 
 		atomic_read(&sk_atm(vcc)->sk_wmem_alloc)) > 0) &&
-		       (retry < MAX_RETRY)) {
+		       time_before(jiffies, end_time)) {
 			msleep(sleep);
 			if (sleep < 250)
 				sleep = sleep * 2;
-
-			++retry;
 		}

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