diff --git a/drivers/staging/rtl8712/drv_types.h b/drivers/staging/rtl8712/drv_types.h index e83665d..0735de9 100644 --- a/drivers/staging/rtl8712/drv_types.h +++ b/drivers/staging/rtl8712/drv_types.h @@ -37,8 +37,6 @@ struct _adapter; #include "wlan_bssdef.h" #include "rtl8712_spec.h" #include "rtl8712_hal.h" -#include -#include enum _NIC_VERSION { RTL8711_NIC, @@ -169,7 +167,6 @@ struct _adapter { s32 bSurpriseRemoved; u32 IsrContent; u32 ImrContent; - bool fw_found; u8 EepromAddressSize; u8 hw_init_completed; struct task_struct *cmdThread; @@ -186,10 +183,6 @@ struct _adapter { _workitem wkFilterRxFF0; u8 blnEnableRxFF0Filter; spinlock_t lockRxFF0Filter; - const struct firmware *fw; - struct usb_interface *pusb_intf; - struct mutex mutex_start; - struct completion rtl8712_fw_ready; }; static inline u8 *myid(struct eeprom_priv *peepriv) diff --git a/drivers/staging/rtl8712/hal_init.c b/drivers/staging/rtl8712/hal_init.c index cc893c0..d0029aa 100644 --- a/drivers/staging/rtl8712/hal_init.c +++ b/drivers/staging/rtl8712/hal_init.c @@ -42,56 +42,29 @@ #define FWBUFF_ALIGN_SZ 512 #define MAX_DUMP_FWSZ 49152 /*default = 49152 (48k)*/ -static void rtl871x_load_fw_cb(const struct firmware *firmware, void *context) +static u32 rtl871x_open_fw(struct _adapter *padapter, void **pphfwfile_hdl, + const u8 **ppmappedfw) { - struct _adapter *padapter = context; - - complete(&padapter->rtl8712_fw_ready); - if (!firmware) { - struct usb_device *udev = padapter->dvobjpriv.pusbdev; - struct usb_interface *pusb_intf = padapter->pusb_intf; - printk(KERN_ERR "r8712u: Firmware request failed\n"); - padapter->fw_found = false; - usb_put_dev(udev); - usb_set_intfdata(pusb_intf, NULL); - return; - } - padapter->fw = firmware; - padapter->fw_found = true; - /* 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; int rc; + const char firmware_file[] = "rtlwifi/rtl8712u.bin"; + const struct firmware **praw = (const struct firmware **) + (pphfwfile_hdl); + struct dvobj_priv *pdvobjpriv = (struct dvobj_priv *) + (&padapter->dvobjpriv); + struct usb_device *pusbdev = pdvobjpriv->pusbdev; - init_completion(&padapter->rtl8712_fw_ready); printk(KERN_INFO "r8712u: Loading firmware from \"%s\"\n", firmware_file); - rc = request_firmware_nowait(THIS_MODULE, 1, firmware_file, dev, - GFP_KERNEL, padapter, rtl871x_load_fw_cb); - if (rc) - printk(KERN_ERR "r8712u: Firmware request error %d\n", rc); - return rc; -} -MODULE_FIRMWARE("rtlwifi/rtl8712u.bin"); - -static u32 rtl871x_open_fw(struct _adapter *padapter, const u8 **ppmappedfw) -{ - const struct firmware **praw = &padapter->fw; - - if (padapter->fw->size > 200000) { - printk(KERN_ERR "r8172u: Badfw->size of %d\n", - (int)padapter->fw->size); + rc = request_firmware(praw, firmware_file, &pusbdev->dev); + if (rc < 0) { + printk(KERN_ERR "r8712u: Unable to load firmware\n"); + printk(KERN_ERR "r8712u: Install latest linux-firmware\n"); return 0; } *ppmappedfw = (u8 *)((*praw)->data); return (*praw)->size; } +MODULE_FIRMWARE("rtlwifi/rtl8712u.bin"); static void fill_fwpriv(struct _adapter *padapter, struct fw_priv *pfwpriv) { @@ -169,17 +142,18 @@ static u8 rtl8712_dl_fw(struct _adapter *padapter) uint dump_imem_sz, imem_sz, dump_emem_sz, emem_sz; /* max = 49152; */ struct fw_hdr fwhdr; u32 ulfilelength; /* FW file size */ + void *phfwfile_hdl = NULL; const u8 *pmappedfw = NULL; u8 *ptmpchar = NULL, *ppayload, *ptr; struct tx_desc *ptx_desc; u32 txdscp_sz = sizeof(struct tx_desc); u8 ret = _FAIL; - ulfilelength = rtl871x_open_fw(padapter, &pmappedfw); + ulfilelength = rtl871x_open_fw(padapter, &phfwfile_hdl, &pmappedfw); if (pmappedfw && (ulfilelength > 0)) { update_fwhdr(&fwhdr, pmappedfw); if (chk_fwhdr(&fwhdr, ulfilelength) == _FAIL) - return ret; + goto firmware_rel; fill_fwpriv(padapter, &fwhdr.fwpriv); /* firmware check ok */ maxlen = (fwhdr.img_IMEM_size > fwhdr.img_SRAM_size) ? @@ -187,7 +161,7 @@ static u8 rtl8712_dl_fw(struct _adapter *padapter) maxlen += txdscp_sz; ptmpchar = _malloc(maxlen + FWBUFF_ALIGN_SZ); if (ptmpchar == NULL) - return ret; + goto firmware_rel; ptx_desc = (struct tx_desc *)(ptmpchar + FWBUFF_ALIGN_SZ - ((addr_t)(ptmpchar) & (FWBUFF_ALIGN_SZ - 1))); @@ -323,6 +297,8 @@ static u8 rtl8712_dl_fw(struct _adapter *padapter) exit_fail: kfree(ptmpchar); +firmware_rel: + release_firmware((struct firmware *)phfwfile_hdl); return ret; } diff --git a/drivers/staging/rtl8712/os_intfs.c b/drivers/staging/rtl8712/os_intfs.c index b22fea5..250cd11 100644 --- a/drivers/staging/rtl8712/os_intfs.c +++ b/drivers/staging/rtl8712/os_intfs.c @@ -31,7 +31,6 @@ #include #include #include -#include #include "osdep_service.h" #include "drv_types.h" #include "xmit_osdep.h" @@ -265,12 +264,12 @@ static void start_drv_timers(struct _adapter *padapter) void r8712_stop_drv_timers(struct _adapter *padapter) { _cancel_timer_ex(&padapter->mlmepriv.assoc_timer); + _cancel_timer_ex(&padapter->mlmepriv.sitesurveyctrl. + sitesurvey_ctrl_timer); _cancel_timer_ex(&padapter->securitypriv.tkip_timer); _cancel_timer_ex(&padapter->mlmepriv.scan_to_timer); _cancel_timer_ex(&padapter->mlmepriv.dhcp_timer); _cancel_timer_ex(&padapter->mlmepriv.wdg_timer); - _cancel_timer_ex(&padapter->mlmepriv.sitesurveyctrl. - sitesurvey_ctrl_timer); } static u8 init_default_value(struct _adapter *padapter) @@ -347,8 +346,7 @@ u8 r8712_free_drv_sw(struct _adapter *padapter) r8712_free_mlme_priv(&padapter->mlmepriv); r8712_free_io_queue(padapter); _free_xmit_priv(&padapter->xmitpriv); - if (padapter->fw_found) - _r8712_free_sta_priv(&padapter->stapriv); + _r8712_free_sta_priv(&padapter->stapriv); _r8712_free_recv_priv(&padapter->recvpriv); mp871xdeinit(padapter); if (pnetdev) @@ -389,7 +387,6 @@ static int netdev_open(struct net_device *pnetdev) { struct _adapter *padapter = (struct _adapter *)netdev_priv(pnetdev); - mutex_lock(&padapter->mutex_start); if (padapter->bup == false) { padapter->bDriverStopped = false; padapter->bSurpriseRemoved = false; @@ -437,13 +434,11 @@ static int netdev_open(struct net_device *pnetdev) /* start driver mlme relation timer */ start_drv_timers(padapter); padapter->ledpriv.LedControlHandler(padapter, LED_CTL_NO_LINK); - mutex_unlock(&padapter->mutex_start); return 0; netdev_open_error: padapter->bup = false; netif_carrier_off(pnetdev); netif_stop_queue(pnetdev); - mutex_unlock(&padapter->mutex_start); return -1; } @@ -477,9 +472,6 @@ static int netdev_close(struct net_device *pnetdev) r8712_free_network_queue(padapter); /* The interface is no longer Up: */ padapter->bup = false; - release_firmware(padapter->fw); - /* never exit with a firmware callback pending */ - wait_for_completion(&padapter->rtl8712_fw_ready); return 0; } diff --git a/drivers/staging/rtl8712/rtl8712_hal.h b/drivers/staging/rtl8712/rtl8712_hal.h index d19865a..665e718 100644 --- a/drivers/staging/rtl8712/rtl8712_hal.h +++ b/drivers/staging/rtl8712/rtl8712_hal.h @@ -145,6 +145,5 @@ struct hal_priv { }; uint rtl8712_hal_init(struct _adapter *padapter); -int rtl871x_load_fw(struct _adapter *padapter); #endif diff --git a/drivers/staging/rtl8712/usb_intf.c b/drivers/staging/rtl8712/usb_intf.c index fe0e2ff..6ea9925 100644 --- a/drivers/staging/rtl8712/usb_intf.c +++ b/drivers/staging/rtl8712/usb_intf.c @@ -389,7 +389,6 @@ static int r871xu_drv_init(struct usb_interface *pusb_intf, pdvobjpriv = &padapter->dvobjpriv; pdvobjpriv->padapter = padapter; padapter->dvobjpriv.pusbdev = udev; - padapter->pusb_intf = pusb_intf; usb_set_intfdata(pusb_intf, pnetdev); SET_NETDEV_DEV(pnetdev, &pusb_intf->dev); /* step 2. */ @@ -596,11 +595,10 @@ static int r871xu_drv_init(struct usb_interface *pusb_intf, "%pM\n", mac); memcpy(pnetdev->dev_addr, mac, ETH_ALEN); } - /* step 6. Load the firmware asynchronously */ - if (rtl871x_load_fw(padapter)) + /* step 6. Tell the network stack we exist */ + if (register_netdev(pnetdev) != 0) goto error; spin_lock_init(&padapter->lockRxFF0Filter); - mutex_init(&padapter->mutex_start); return 0; error: usb_put_dev(udev); @@ -631,8 +629,7 @@ static void r871xu_dev_remove(struct usb_interface *pusb_intf) flush_scheduled_work(); udelay(1); /*Stop driver mlme relation timer */ - if (padapter->fw_found) - r8712_stop_drv_timers(padapter); + r8712_stop_drv_timers(padapter); r871x_dev_unload(padapter); r8712_free_drv_sw(padapter); }