[PATCH ver3 2/4] qla4xxx: Add a timeout period and return status from ql4xxx_lock_drvr_wait()

Doug Maxey
2006-08-05T22:54:37Z

From: Doug Maxey <dwm@enoyolf.org>

Change the func to only wait for QL4_LOCK_DRVR_WAIT ms.
Fix callers to use the return status.

Signed-off-by: Doug Maxey <dwm@enoyolf.org>
---

drivers/scsi/qla4xxx/ql4_init.c | 26 ++++++++++++++++----------
1 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/drivers/scsi/qla4xxx/ql4_init.c b/drivers/scsi/qla4xxx/ql4_init.c
index 8608106..8fb39b5 100644
--- a/drivers/scsi/qla4xxx/ql4_init.c
+++ b/drivers/scsi/qla4xxx/ql4_init.c
@@ -988,25 +988,29 @@ static int qla4xxx_start_firmware_from_f
return status;
}

-static void ql4xxx_lock_drvr_wait(struct scsi_qla_host *a)
+static int ql4xxx_lock_drvr_wait(struct scsi_qla_host *a)
{
- int i = 0;
- while (1) {
+#define QL4_LOCK_DRVR_WAIT (20000)
+#define QL4_LOCK_DRVR_SLEEP (10)
+ int i = QL4_LOCK_DRVR_WAIT;
+
+ while (i > 0) {
if (ql4xxx_lock_drvr(a) == 0) {
- msleep(10);
- if (!i) {
+ msleep(QL4_LOCK_DRVR_SLEEP);
+ if (i == QL4_LOCK_DRVR_WAIT) {
DEBUG2(printk("scsi%ld: %s: Waiting for "
"Global Init Semaphore...n",
a->host_no,
__func__));
- i++;
}
+ i -= QL4_LOCK_DRVR_SLEEP;
} else {
DEBUG2(printk("scsi%ld: %s: Global Init Semaphore "
- "acquired.n", a->host_no, __func__));
- break;
+ "acquired\n", a->host_no, __func__));
+ return QLA_SUCCESS;
}
}
+ return QLA_ERROR;
}

/**
@@ -1030,7 +1034,8 @@ static int qla4xxx_start_firmware(struct
if (is_qla4022(ha))
ql4xxx_set_mac_number(ha);

- ql4xxx_lock_drvr_wait(ha);
+ if (ql4xxx_lock_drvr_wait(ha))
+ return QLA_ERROR;

spin_lock_irqsave(&ha->hardware_lock, flags);

@@ -1107,7 +1112,8 @@ static int qla4xxx_start_firmware(struct
config_chip = 1;

/* Reset clears the semaphore, so aquire again */
- ql4xxx_lock_drvr_wait(ha);
+ if (ql4xxx_lock_drvr_wait(ha))
+ return QLA_ERROR;
}

if (config_chip) {