[svn-commits] sruffell: linux/trunk r5562 - /linux/trunk/drivers/dahdi/wcb4xxp/base.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Dec 16 21:01:56 CST 2008


Author: sruffell
Date: Tue Dec 16 21:01:55 2008
New Revision: 5562

URL: http://svn.digium.com/view/dahdi?view=rev&rev=5562
Log:
wcb4xxp: Remove an endless while loop.

Modified:
    linux/trunk/drivers/dahdi/wcb4xxp/base.c

Modified: linux/trunk/drivers/dahdi/wcb4xxp/base.c
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/wcb4xxp/base.c?view=diff&rev=5562&r1=5561&r2=5562
==============================================================================
--- linux/trunk/drivers/dahdi/wcb4xxp/base.c (original)
+++ linux/trunk/drivers/dahdi/wcb4xxp/base.c Tue Dec 16 21:01:55 2008
@@ -681,25 +681,33 @@
 }
 
 /* performs a register write and then waits for the HFC "busy" bit to clear */
-static inline void hfc_setreg_waitbusy(struct b4xxp *b4, const unsigned int reg, const unsigned int val)
-{
-	unsigned long maxwait;
-
-	maxwait = 1048576;
+static void hfc_setreg_waitbusy(struct b4xxp *b4, const unsigned int reg, const unsigned int val)
+{
+	int timeout = 0;
+	unsigned long start;
+	const int TIMEOUT = HZ/4; /* 250ms */
+
+	start = jiffies;
 	while (unlikely((b4xxp_getreg8(b4, R_STATUS) & V_BUSY))) {
-		maxwait--; /* FIXME: do what? it isn't busy for long */
+		if (time_after(jiffies, start + TIMEOUT)) {
+			timeout = 1;
+			break;
+		}
 	};
 
 	mb();
 	b4xxp_setreg8(b4, reg, val);
 	mb();
 
-	maxwait = 1048576;
+	start = jiffies;
 	while (likely((b4xxp_getreg8(b4, R_STATUS) & V_BUSY))) {
-		maxwait--; /* FIXME: do what? it isn't busy for long */
+		if (time_after(jiffies, start + TIMEOUT)) {
+			timeout = 1;
+			break;
+		}
 	};
 
-	if (!maxwait) {
+	if (timeout) {
 		if (printk_ratelimit())
 			dev_warn(b4->dev, "hfc_setreg_waitbusy(write 0x%02x to 0x%02x) timed out waiting for busy flag to clear!\n", val, reg);
 	}




More information about the svn-commits mailing list