Staging: rtl8192e: fix timeouts on firmware download

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Wednesday, September 16, 2009 - 9:15 am

Gitweb:     http://git.kernel.org/linus/fa052e912d4d575b86a7fd3623380aba897a1a8e
Commit:     fa052e912d4d575b86a7fd3623380aba897a1a8e
Parent:     3ef5a262ad0061d6147da7e3ee03aead7c160d91
Author:     Greg Kroah-Hartman <gregkh@suse.de>
AuthorDate: Mon Aug 24 14:40:50 2009 -0700
Committer:  Greg Kroah-Hartman <gregkh@suse.de>
CommitDate: Tue Sep 15 12:02:32 2009 -0700

    Staging: rtl8192e: fix timeouts on firmware download
    
    We need to actually wait a specific ammount of time, not just hope that
    a set number of loops will be long enough.
    
    Based on a conversation with Ralink, and a proposed patch for their
    older kernel driver.
    
    Cc: david woo <xinhua_wu@realsil.com.cn>
    Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
 drivers/staging/rtl8192e/r819xE_firmware.c |   30 ++++++++++++++-------------
 1 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/rtl8192e/r819xE_firmware.c b/drivers/staging/rtl8192e/r819xE_firmware.c
index 72f6792..1f9e413 100644
--- a/drivers/staging/rtl8192e/r819xE_firmware.c
+++ b/drivers/staging/rtl8192e/r819xE_firmware.c
@@ -122,19 +122,19 @@ static bool fw_download_code(struct net_device *dev, u8 *code_virtual_address,
  */
 static bool CPUcheck_maincodeok_turnonCPU(struct net_device *dev)
 {
+	unsigned long timeout;
 	bool rt_status = true;
-	int check_putcodeOK_time = 200000;
-	int check_bootOk_time = 200000;
 	u32 CPU_status = 0;
 
 	/* Check whether put code OK */
-	do {
+	timeout = jiffies + msecs_to_jiffies(20);
+	while (time_before(jiffies, timeout)) {
 		CPU_status = read_nic_dword(dev, CPU_GEN);
 
 		if (CPU_status & CPU_GEN_PUT_CODE_OK)
 			break;
-
-	} while (check_putcodeOK_time--);
+		msleep(2);
+	}
 
 	if (!(CPU_status & CPU_GEN_PUT_CODE_OK)) {
 		RT_TRACE(COMP_ERR, "Download Firmware: Put code fail!\n");
@@ -150,12 +150,14 @@ static bool CPUcheck_maincodeok_turnonCPU(struct net_device *dev)
 	mdelay(1);
 
 	/* Check whether CPU boot OK */
-	do {
+	timeout = jiffies + msecs_to_jiffies(20);
+	while (time_before(jiffies, timeout)) {
 		CPU_status = read_nic_dword(dev, CPU_GEN);
 
 		if (CPU_status & CPU_GEN_BOOT_RDY)
 			break;
-	} while (check_bootOk_time--);
+		msleep(2);
+	}
 
 	if (!(CPU_status & CPU_GEN_BOOT_RDY))
 		goto CPUCheckMainCodeOKAndTurnOnCPU_Fail;
@@ -172,19 +174,19 @@ CPUCheckMainCodeOKAndTurnOnCPU_Fail:
 
 static bool CPUcheck_firmware_ready(struct net_device *dev)
 {
-
-	bool		rt_status = true;
-	int		check_time = 200000;
-	u32		CPU_status = 0;
+	unsigned long timeout;
+	bool rt_status = true;
+	u32 CPU_status = 0;
 
 	/* Check Firmware Ready */
-	do {
+	timeout = jiffies + msecs_to_jiffies(20);
+	while (time_before(jiffies, timeout)) {
 		CPU_status = read_nic_dword(dev, CPU_GEN);
 
 		if (CPU_status & CPU_GEN_FIRM_RDY)
 			break;
-
-	} while (check_time--);
+		msleep(2);
+	}
 
 	if (!(CPU_status & CPU_GEN_FIRM_RDY))
 		goto CPUCheckFirmwareReady_Fail;
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Staging: rtl8192e: fix timeouts on firmware download, Linux Kernel Mailing ..., (Wed Sep 16, 9:15 am)