aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2009-08-24 17:40:50 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2009-09-15 15:02:32 -0400
commitfa052e912d4d575b86a7fd3623380aba897a1a8e (patch)
tree21639a0600344bd6b55691566d56b5b95473e424 /drivers/staging
parent3ef5a262ad0061d6147da7e3ee03aead7c160d91 (diff)
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>
Diffstat (limited to 'drivers/staging')
-rw-r--r--drivers/staging/rtl8192e/r819xE_firmware.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/drivers/staging/rtl8192e/r819xE_firmware.c b/drivers/staging/rtl8192e/r819xE_firmware.c
index 72f679274bc..1f9e413bcd4 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,
122 */ 122 */
123static bool CPUcheck_maincodeok_turnonCPU(struct net_device *dev) 123static bool CPUcheck_maincodeok_turnonCPU(struct net_device *dev)
124{ 124{
125 unsigned long timeout;
125 bool rt_status = true; 126 bool rt_status = true;
126 int check_putcodeOK_time = 200000;
127 int check_bootOk_time = 200000;
128 u32 CPU_status = 0; 127 u32 CPU_status = 0;
129 128
130 /* Check whether put code OK */ 129 /* Check whether put code OK */
131 do { 130 timeout = jiffies + msecs_to_jiffies(20);
131 while (time_before(jiffies, timeout)) {
132 CPU_status = read_nic_dword(dev, CPU_GEN); 132 CPU_status = read_nic_dword(dev, CPU_GEN);
133 133
134 if (CPU_status & CPU_GEN_PUT_CODE_OK) 134 if (CPU_status & CPU_GEN_PUT_CODE_OK)
135 break; 135 break;
136 136 msleep(2);
137 } while (check_putcodeOK_time--); 137 }
138 138
139 if (!(CPU_status & CPU_GEN_PUT_CODE_OK)) { 139 if (!(CPU_status & CPU_GEN_PUT_CODE_OK)) {
140 RT_TRACE(COMP_ERR, "Download Firmware: Put code fail!\n"); 140 RT_TRACE(COMP_ERR, "Download Firmware: Put code fail!\n");
@@ -150,12 +150,14 @@ static bool CPUcheck_maincodeok_turnonCPU(struct net_device *dev)
150 mdelay(1); 150 mdelay(1);
151 151
152 /* Check whether CPU boot OK */ 152 /* Check whether CPU boot OK */
153 do { 153 timeout = jiffies + msecs_to_jiffies(20);
154 while (time_before(jiffies, timeout)) {
154 CPU_status = read_nic_dword(dev, CPU_GEN); 155 CPU_status = read_nic_dword(dev, CPU_GEN);
155 156
156 if (CPU_status & CPU_GEN_BOOT_RDY) 157 if (CPU_status & CPU_GEN_BOOT_RDY)
157 break; 158 break;
158 } while (check_bootOk_time--); 159 msleep(2);
160 }
159 161
160 if (!(CPU_status & CPU_GEN_BOOT_RDY)) 162 if (!(CPU_status & CPU_GEN_BOOT_RDY))
161 goto CPUCheckMainCodeOKAndTurnOnCPU_Fail; 163 goto CPUCheckMainCodeOKAndTurnOnCPU_Fail;
@@ -172,19 +174,19 @@ CPUCheckMainCodeOKAndTurnOnCPU_Fail:
172 174
173static bool CPUcheck_firmware_ready(struct net_device *dev) 175static bool CPUcheck_firmware_ready(struct net_device *dev)
174{ 176{
175 177 unsigned long timeout;
176 bool rt_status = true; 178 bool rt_status = true;
177 int check_time = 200000; 179 u32 CPU_status = 0;
178 u32 CPU_status = 0;
179 180
180 /* Check Firmware Ready */ 181 /* Check Firmware Ready */
181 do { 182 timeout = jiffies + msecs_to_jiffies(20);
183 while (time_before(jiffies, timeout)) {
182 CPU_status = read_nic_dword(dev, CPU_GEN); 184 CPU_status = read_nic_dword(dev, CPU_GEN);
183 185
184 if (CPU_status & CPU_GEN_FIRM_RDY) 186 if (CPU_status & CPU_GEN_FIRM_RDY)
185 break; 187 break;
186 188 msleep(2);
187 } while (check_time--); 189 }
188 190
189 if (!(CPU_status & CPU_GEN_FIRM_RDY)) 191 if (!(CPU_status & CPU_GEN_FIRM_RDY))
190 goto CPUCheckFirmwareReady_Fail; 192 goto CPUCheckFirmwareReady_Fail;