Since commit 8c213fa, the delayed firmware loading callback routine in driver r8712u has intermittently resulted in a firmware image that is completely wrong. To work around this issue, a call to request_firmware() is placed when an incorrect firmware size is detected in the callback. This synchronous call should be safe. Signed-off-by: Larry Finger --- Index: staging/drivers/staging/rtl8712/hal_init.c =================================================================== --- staging.orig/drivers/staging/rtl8712/hal_init.c +++ staging/drivers/staging/rtl8712/hal_init.c @@ -42,6 +42,8 @@ #define FWBUFF_ALIGN_SZ 512 #define MAX_DUMP_FWSZ 49152 /*default = 49152 (48k)*/ +static const char firmware_file[] = "rtlwifi/rtl8712u.bin"; + static void rtl871x_load_fw_cb(const struct firmware *firmware, void *context) { struct _adapter *padapter = context; @@ -58,12 +60,18 @@ static void rtl871x_load_fw_cb(const str } padapter->fw = firmware; padapter->fw_found = true; + if (padapter->fw->size > 200000) { + struct device *dev = &padapter->dvobjpriv.pusbdev->dev; + /* On occasion, the firmware image is wrong - try once more */ + request_firmware(&firmware, firmware_file, dev); + if (padapter->fw->size > 200000) + printk(KERN_ERR "r8172u: Bad fw->size of %d\n", + (int)padapter->fw->size); + } /* firmware available - start netdev */ register_netdev(padapter->pnetdev); } -static const char firmware_file[] = "rtlwifi/rtl8712u.bin"; - int rtl871x_load_fw(struct _adapter *padapter) { struct device *dev = &padapter->dvobjpriv.pusbdev->dev; @@ -84,11 +92,8 @@ static u32 rtl871x_open_fw(struct _adapt { const struct firmware **praw = &padapter->fw; - if (padapter->fw->size > 200000) { - printk(KERN_ERR "r8172u: Badfw->size of %d\n", - (int)padapter->fw->size); + if (padapter->fw->size > 200000) return 0; - } *ppmappedfw = (u8 *)((*praw)->data); return (*praw)->size; }