From afe370287370f3ee5dfdd0f402a936183a5e5813 Mon Sep 17 00:00:00 2001 From: Shaun Ruffell Date: Tue, 3 Jan 2012 19:25:42 +0000 Subject: [PATCH] wct4xxp: Reduce time spent waiting for auth done bit on TE820. It is not necessary to wait a full second for the donebit. Signed-off-by: Shaun Ruffell Acked-by: Russ Meyerriecks git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10395 a0bf4364-ded3-4de4-8d8a-66a801d63aff --- drivers/dahdi/wct4xxp/base.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/dahdi/wct4xxp/base.c b/drivers/dahdi/wct4xxp/base.c index c91ce59..7127561 100644 --- a/drivers/dahdi/wct4xxp/base.c +++ b/drivers/dahdi/wct4xxp/base.c @@ -4888,19 +4888,21 @@ static int t4_hardware_init_1(struct t4 *wc, unsigned int cardflags) /* TE820 Auth Check */ if (is_octal(wc)) { + unsigned long stop = jiffies + HZ; uint32_t donebit; - donebit = t4_pci_in(wc, WC_LEDS2); t4_pci_out(wc, WC_LEDS2, WC_SET_AUTH); - - msleep(1000); - donebit = t4_pci_in(wc, WC_LEDS2); - if (!(donebit & WC_GET_AUTH)) { - /* Encryption check failed, stop operation */ - dev_info(&wc->dev->dev, "Failed encryption check. "\ - "Unloading driver.\n"); - return -EIO; + while (!(donebit & WC_GET_AUTH)) { + if (time_after(jiffies, stop)) { + /* Encryption check failed, stop operation */ + dev_info(&wc->dev->dev, + "Failed encryption check. " + "Unloading driver.\n"); + return -EIO; + } + msleep(20); + donebit = t4_pci_in(wc, WC_LEDS2); } }