]> Pileus Git - ~andy/linux/blobdiff - drivers/net/wireless/rtlwifi/rtl8192se/sw.c
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wirel...
[~andy/linux] / drivers / net / wireless / rtlwifi / rtl8192se / sw.c
index 36140ccf2abdb5a26451d28cf76868070ba60c94..eda30b9d0f15b90724a23c43d3afb001cdddc118 100644 (file)
@@ -1,6 +1,6 @@
 /******************************************************************************
  *
- * Copyright(c) 2009-2010  Realtek Corporation.
+ * Copyright(c) 2009-2012  Realtek Corporation.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of version 2 of the GNU General Public License as
  *
  *****************************************************************************/
 
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
-#include <linux/vmalloc.h>
-#include <linux/module.h>
-
 #include "../wifi.h"
 #include "../core.h"
 #include "../pci.h"
+#include "../base.h"
+#include "../pci.h"
 #include "reg.h"
 #include "def.h"
 #include "phy.h"
@@ -45,6 +42,8 @@
 #include "trx.h"
 #include "led.h"
 
+#include <linux/module.h>
+
 static void rtl92s_init_aspm_vars(struct ieee80211_hw *hw)
 {
        struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
@@ -89,12 +88,53 @@ static void rtl92s_init_aspm_vars(struct ieee80211_hw *hw)
        rtlpci->const_support_pciaspm = 2;
 }
 
+static void rtl92se_fw_cb(const struct firmware *firmware, void *context)
+{
+       struct ieee80211_hw *hw = context;
+       struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw);
+       struct rtl_priv *rtlpriv = rtl_priv(hw);
+       struct rtl_pci *rtlpci = rtl_pcidev(pcipriv);
+       struct rt_firmware *pfirmware = NULL;
+       int err;
+
+       RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
+                        "Firmware callback routine entered!\n");
+       complete(&rtlpriv->firmware_loading_complete);
+       if (!firmware) {
+               pr_err("Firmware %s not available\n", rtlpriv->cfg->fw_name);
+               rtlpriv->max_fw_size = 0;
+               return;
+       }
+       if (firmware->size > rtlpriv->max_fw_size) {
+               RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
+                        "Firmware is too big!\n");
+               release_firmware(firmware);
+               return;
+       }
+       pfirmware = (struct rt_firmware *)rtlpriv->rtlhal.pfirmware;
+       memcpy(pfirmware->sz_fw_tmpbuffer, firmware->data, firmware->size);
+       pfirmware->sz_fw_tmpbufferlen = firmware->size;
+       release_firmware(firmware);
+
+       err = ieee80211_register_hw(hw);
+       if (err) {
+               RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
+                        "Can't register mac80211 hw\n");
+               return;
+       } else {
+               rtlpriv->mac80211.mac80211_registered = 1;
+       }
+       rtlpci->irq_alloc = 1;
+       set_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status);
+
+       /*init rfkill */
+       rtl_init_rfkill(hw);
+}
+
 static int rtl92s_init_sw_vars(struct ieee80211_hw *hw)
 {
        struct rtl_priv *rtlpriv = rtl_priv(hw);
        struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
-       const struct firmware *firmware;
-       struct rt_firmware *pfirmware = NULL;
        int err = 0;
        u16 earlyrxthreshold = 7;
 
@@ -168,9 +208,9 @@ static int rtl92s_init_sw_vars(struct ieee80211_hw *hw)
        rtlpriv->psc.swctrl_lps = rtlpriv->cfg->mod_params->swctrl_lps;
        rtlpriv->psc.fwctrl_lps = rtlpriv->cfg->mod_params->fwctrl_lps;
        if (!rtlpriv->psc.inactiveps)
-               pr_info("rtl8192ce: Power Save off (module option)\n");
+               pr_info("Power Save off (module option)\n");
        if (!rtlpriv->psc.fwctrl_lps)
-               pr_info("rtl8192ce: FW Power Save off (module option)\n");
+               pr_info("FW Power Save off (module option)\n");
        rtlpriv->psc.reg_fwctrl_lps = 3;
        rtlpriv->psc.reg_max_lps_awakeintvl = 5;
        /* for ASPM, you can close aspm through
@@ -189,27 +229,19 @@ static int rtl92s_init_sw_vars(struct ieee80211_hw *hw)
        if (!rtlpriv->rtlhal.pfirmware)
                return 1;
 
+       rtlpriv->max_fw_size = sizeof(struct rt_firmware);
+
        pr_info("Driver for Realtek RTL8192SE/RTL8191SE\n"
                "Loading firmware %s\n", rtlpriv->cfg->fw_name);
        /* request fw */
-       err = request_firmware(&firmware, rtlpriv->cfg->fw_name,
-                       rtlpriv->io.dev);
+       err = request_firmware_nowait(THIS_MODULE, 1, rtlpriv->cfg->fw_name,
+                                     rtlpriv->io.dev, GFP_KERNEL, hw,
+                                     rtl92se_fw_cb);
        if (err) {
                RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
-                        ("Failed to request firmware!\n"));
+                        "Failed to request firmware!\n");
                return 1;
        }
-       if (firmware->size > sizeof(struct rt_firmware)) {
-               RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
-                        ("Firmware is too big!\n"));
-               release_firmware(firmware);
-               return 1;
-       }
-
-       pfirmware = (struct rt_firmware *)rtlpriv->rtlhal.pfirmware;
-       memcpy(pfirmware->sz_fw_tmpbuffer, firmware->data, firmware->size);
-       pfirmware->sz_fw_tmpbufferlen = firmware->size;
-       release_firmware(firmware);
 
        return err;
 }
@@ -423,7 +455,7 @@ static int __init rtl92se_module_init(void)
 
        ret = pci_register_driver(&rtl92se_driver);
        if (ret)
-               RT_ASSERT(false, (": No device found\n"));
+               RT_ASSERT(false, "No device found\n");
 
        return ret;
 }