diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2009-08-24 17:40:50 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-09-15 15:02:32 -0400 |
commit | fa052e912d4d575b86a7fd3623380aba897a1a8e (patch) | |
tree | 21639a0600344bd6b55691566d56b5b95473e424 /drivers | |
parent | 3ef5a262ad0061d6147da7e3ee03aead7c160d91 (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')
-rw-r--r-- | 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 72f679274bc4..1f9e413bcd49 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 | */ |
123 | static bool CPUcheck_maincodeok_turnonCPU(struct net_device *dev) | 123 | static 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 | ||
173 | static bool CPUcheck_firmware_ready(struct net_device *dev) | 175 | static 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; |