diff options
author | Shaun Ruffell <sruffell@digium.com> | 2008-12-17 03:01:55 +0000 |
---|---|---|
committer | Shaun Ruffell <sruffell@digium.com> | 2008-12-17 03:01:55 +0000 |
commit | 0b676e68f05c214d6f387c19e090433056c9c7aa (patch) | |
tree | 9068354b68715675cfb1bd721e9662257fb35a7c /drivers/dahdi/wcb4xxp | |
parent | a2a63c195f1eb513b67396137946cfabca7761a8 (diff) |
wcb4xxp: Remove an endless while loop.
git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@5562 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'drivers/dahdi/wcb4xxp')
-rw-r--r-- | drivers/dahdi/wcb4xxp/base.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/drivers/dahdi/wcb4xxp/base.c b/drivers/dahdi/wcb4xxp/base.c index 02e1bcc..daf4d02 100644 --- a/drivers/dahdi/wcb4xxp/base.c +++ b/drivers/dahdi/wcb4xxp/base.c @@ -681,25 +681,33 @@ static void ec_init(struct b4xxp *b4) } /* 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) +static void hfc_setreg_waitbusy(struct b4xxp *b4, const unsigned int reg, const unsigned int val) { - unsigned long maxwait; + int timeout = 0; + unsigned long start; + const int TIMEOUT = HZ/4; /* 250ms */ - maxwait = 1048576; + 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); } |