rtlwifi: rtl8821ae: Fix firmware endian issues
authorLarry Finger <Larry.Finger@lwfinger.net>
Mon, 3 Aug 2015 20:56:13 +0000 (15:56 -0500)
committerKalle Valo <kvalo@codeaurora.org>
Thu, 13 Aug 2015 12:31:22 +0000 (15:31 +0300)
This driver is converted to use the common firmware header struct.
Because the old header definition failed to indicate that the multi-byte
entries should be little endian, several problems were thus exposed.
These are fixed.

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/rtlwifi/rtl8821ae/fw.c
drivers/net/wireless/rtlwifi/rtl8821ae/fw.h

index 95e95626b6325c29c43ceb440b4b3ea0b352874e..525eb234627c965daa3d0c7e9611163b9734df3a 100644 (file)
@@ -210,7 +210,7 @@ int rtl8821ae_download_fw(struct ieee80211_hw *hw, bool buse_wake_on_wlan_fw)
 {
        struct rtl_priv *rtlpriv = rtl_priv(hw);
        struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
-       struct rtl8821a_firmware_header *pfwheader;
+       struct rtlwifi_firmware_header *pfwheader;
        u8 *pfwdata;
        u32 fwsize;
        int err;
@@ -228,8 +228,8 @@ int rtl8821ae_download_fw(struct ieee80211_hw *hw, bool buse_wake_on_wlan_fw)
                        return 1;
 
                pfwheader =
-                 (struct rtl8821a_firmware_header *)rtlhal->wowlan_firmware;
-               rtlhal->fw_version = pfwheader->version;
+                 (struct rtlwifi_firmware_header *)rtlhal->wowlan_firmware;
+               rtlhal->fw_version = le16_to_cpu(pfwheader->version);
                rtlhal->fw_subversion = pfwheader->subversion;
                pfwdata = (u8 *)rtlhal->wowlan_firmware;
                fwsize = rtlhal->wowlan_fwsize;
@@ -238,8 +238,8 @@ int rtl8821ae_download_fw(struct ieee80211_hw *hw, bool buse_wake_on_wlan_fw)
                        return 1;
 
                pfwheader =
-                 (struct rtl8821a_firmware_header *)rtlhal->pfirmware;
-               rtlhal->fw_version = pfwheader->version;
+                 (struct rtlwifi_firmware_header *)rtlhal->pfirmware;
+               rtlhal->fw_version = le16_to_cpu(pfwheader->version);
                rtlhal->fw_subversion = pfwheader->subversion;
                pfwdata = (u8 *)rtlhal->pfirmware;
                fwsize = rtlhal->fwsize;
@@ -255,8 +255,8 @@ int rtl8821ae_download_fw(struct ieee80211_hw *hw, bool buse_wake_on_wlan_fw)
                         "Firmware Version(%d), Signature(%#x)\n",
                         pfwheader->version, pfwheader->signature);
 
-               pfwdata = pfwdata + sizeof(struct rtl8821a_firmware_header);
-               fwsize = fwsize - sizeof(struct rtl8821a_firmware_header);
+               pfwdata = pfwdata + sizeof(struct rtlwifi_firmware_header);
+               fwsize = fwsize - sizeof(struct rtlwifi_firmware_header);
        }
 
        if (rtlhal->mac_func_enable) {
index 591c14c0b9b52bd9247676cf972b18853874d07a..8f5b4aade3c91f356748dffa41318ce557c10bd5 100644 (file)
 #define FW_8821AE_POLLING_TIMEOUT_COUNT        6000
 
 #define IS_FW_HEADER_EXIST_8812(_pfwhdr)       \
-       ((_pfwhdr->signature&0xFFF0) == 0x9500)
+       ((le16_to_cpu(_pfwhdr->signature) & 0xFFF0) == 0x9500)
 
 #define IS_FW_HEADER_EXIST_8821(_pfwhdr)       \
-       ((_pfwhdr->signature&0xFFF0) == 0x2100)
+       ((le16_to_cpu(_pfwhdr->signature) & 0xFFF0) == 0x2100)
 
 #define USE_OLD_WOWLAN_DEBUG_FW 0
 
 #define        FW_PWR_STATE_ACTIVE     ((FW_PS_RF_ON) | (FW_PS_REGISTER_ACTIVE))
 #define        FW_PWR_STATE_RF_OFF     0
 
-struct rtl8821a_firmware_header {
-       u16 signature;
-       u8 category;
-       u8 function;
-       u16 version;
-       u8 subversion;
-       u8 rsvd1;
-       u8 month;
-       u8 date;
-       u8 hour;
-       u8 minute;
-       u16 ramcodeSize;
-       u16 rsvd2;
-       u32 svnindex;
-       u32 rsvd3;
-       u32 rsvd4;
-       u32 rsvd5;
-};
-
 enum rtl8812_c2h_evt {
        C2H_8812_DBG = 0,
        C2H_8812_LB = 1,