]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
iwlwifi: remove ucode virtual functions
authorJohannes Berg <johannes.berg@intel.com>
Wed, 28 Apr 2010 19:09:14 +0000 (12:09 -0700)
committerReinette Chatre <reinette.chatre@intel.com>
Mon, 10 May 2010 22:08:54 +0000 (15:08 -0700)
AGN devices all use the same ucode operations,
except for 4965, because 4965 uses only v1 file
headers.

Therefore, we can remove all the indirection
we have here and just code the API distinction
in place, with a small special case for 4965.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
drivers/net/wireless/iwlwifi/iwl-1000.c
drivers/net/wireless/iwlwifi/iwl-4965.c
drivers/net/wireless/iwlwifi/iwl-5000.c
drivers/net/wireless/iwlwifi/iwl-6000.c
drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
drivers/net/wireless/iwlwifi/iwl-agn.c
drivers/net/wireless/iwlwifi/iwl-agn.h
drivers/net/wireless/iwlwifi/iwl-core.h
drivers/net/wireless/iwlwifi/iwl-dev.h
drivers/net/wireless/iwlwifi/iwl3945-base.c

index ebaf02d47e73629b1bb8365d18f1e77b3ab0088f..a2f7cbcc2f7cade5ddc058e4f60f63416a70ff30 100644 (file)
@@ -225,7 +225,6 @@ static struct iwl_lib_ops iwl1000_lib = {
 };
 
 static const struct iwl_ops iwl1000_ops = {
-       .ucode = &iwlagn_ucode,
        .lib = &iwl1000_lib,
        .hcmd = &iwlagn_hcmd,
        .utils = &iwlagn_hcmd_utils,
index 5904a1beac4dbd45cc8a559703aafbd70d71be06..a3562a126c93f6e3e41b242f92298f774503a98b 100644 (file)
@@ -2112,34 +2112,6 @@ static void iwl4965_cancel_deferred_work(struct iwl_priv *priv)
        cancel_work_sync(&priv->txpower_work);
 }
 
-#define IWL4965_UCODE_GET(item)                                                \
-static u32 iwl4965_ucode_get_##item(const struct iwl_ucode_header *ucode,\
-                                   u32 api_ver)                        \
-{                                                                      \
-       return le32_to_cpu(ucode->u.v1.item);                           \
-}
-
-static u32 iwl4965_ucode_get_header_size(u32 api_ver)
-{
-       return UCODE_HEADER_SIZE(1);
-}
-static u32 iwl4965_ucode_get_build(const struct iwl_ucode_header *ucode,
-                                  u32 api_ver)
-{
-       return 0;
-}
-static u8 *iwl4965_ucode_get_data(const struct iwl_ucode_header *ucode,
-                                 u32 api_ver)
-{
-       return (u8 *) ucode->u.v1.data;
-}
-
-IWL4965_UCODE_GET(inst_size);
-IWL4965_UCODE_GET(data_size);
-IWL4965_UCODE_GET(init_size);
-IWL4965_UCODE_GET(init_data_size);
-IWL4965_UCODE_GET(boot_size);
-
 static struct iwl_hcmd_ops iwl4965_hcmd = {
        .rxon_assoc = iwl4965_send_rxon_assoc,
        .commit_rxon = iwl_commit_rxon,
@@ -2147,16 +2119,6 @@ static struct iwl_hcmd_ops iwl4965_hcmd = {
        .send_bt_config = iwl_send_bt_config,
 };
 
-static struct iwl_ucode_ops iwl4965_ucode = {
-       .get_header_size = iwl4965_ucode_get_header_size,
-       .get_build = iwl4965_ucode_get_build,
-       .get_inst_size = iwl4965_ucode_get_inst_size,
-       .get_data_size = iwl4965_ucode_get_data_size,
-       .get_init_size = iwl4965_ucode_get_init_size,
-       .get_init_data_size = iwl4965_ucode_get_init_data_size,
-       .get_boot_size = iwl4965_ucode_get_boot_size,
-       .get_data = iwl4965_ucode_get_data,
-};
 static struct iwl_hcmd_utils_ops iwl4965_hcmd_utils = {
        .get_hcmd_size = iwl4965_get_hcmd_size,
        .build_addsta_hcmd = iwl4965_build_addsta_hcmd,
@@ -2229,7 +2191,6 @@ static struct iwl_lib_ops iwl4965_lib = {
 };
 
 static const struct iwl_ops iwl4965_ops = {
-       .ucode = &iwl4965_ucode,
        .lib = &iwl4965_lib,
        .hcmd = &iwl4965_hcmd,
        .utils = &iwl4965_hcmd_utils,
index bde0f18cbae91e67b6a93310964f9f7ad62542ac..efda0e8ccacbd4f7dbcd323e20145ffe2a4fb29e 100644 (file)
@@ -427,7 +427,6 @@ static struct iwl_lib_ops iwl5150_lib = {
 };
 
 static const struct iwl_ops iwl5000_ops = {
-       .ucode = &iwlagn_ucode,
        .lib = &iwl5000_lib,
        .hcmd = &iwlagn_hcmd,
        .utils = &iwlagn_hcmd_utils,
@@ -435,7 +434,6 @@ static const struct iwl_ops iwl5000_ops = {
 };
 
 static const struct iwl_ops iwl5150_ops = {
-       .ucode = &iwlagn_ucode,
        .lib = &iwl5150_lib,
        .hcmd = &iwlagn_hcmd,
        .utils = &iwlagn_hcmd_utils,
index 5f0f586931045259d7d0e735651c598a3db8748a..03c73244703c2edf425451c6df39e00d12132cc9 100644 (file)
@@ -330,7 +330,6 @@ static struct iwl_lib_ops iwl6000_lib = {
 };
 
 static const struct iwl_ops iwl6000_ops = {
-       .ucode = &iwlagn_ucode,
        .lib = &iwl6000_lib,
        .hcmd = &iwlagn_hcmd,
        .utils = &iwlagn_hcmd_utils,
@@ -404,7 +403,6 @@ static struct iwl_lib_ops iwl6050_lib = {
 };
 
 static const struct iwl_ops iwl6050_ops = {
-       .ucode = &iwlagn_ucode,
        .lib = &iwl6050_lib,
        .hcmd = &iwlagn_hcmd,
        .utils = &iwlagn_hcmd_utils,
index c3e3283426a914c6b426fe46862e080cfb920353..637286c396fe9c7cf992ba3c748362f74d130a81 100644 (file)
@@ -182,55 +182,6 @@ int iwlagn_load_ucode(struct iwl_priv *priv)
        return ret;
 }
 
-#define IWL_UCODE_GET(item)                                            \
-static u32 iwlagn_ucode_get_##item(const struct iwl_ucode_header *ucode,\
-                                   u32 api_ver)                        \
-{                                                                      \
-       if (api_ver <= 2)                                               \
-               return le32_to_cpu(ucode->u.v1.item);                   \
-       return le32_to_cpu(ucode->u.v2.item);                           \
-}
-
-static u32 iwlagn_ucode_get_header_size(u32 api_ver)
-{
-       if (api_ver <= 2)
-               return UCODE_HEADER_SIZE(1);
-       return UCODE_HEADER_SIZE(2);
-}
-
-static u32 iwlagn_ucode_get_build(const struct iwl_ucode_header *ucode,
-                                  u32 api_ver)
-{
-       if (api_ver <= 2)
-               return 0;
-       return le32_to_cpu(ucode->u.v2.build);
-}
-
-static u8 *iwlagn_ucode_get_data(const struct iwl_ucode_header *ucode,
-                                 u32 api_ver)
-{
-       if (api_ver <= 2)
-               return (u8 *) ucode->u.v1.data;
-       return (u8 *) ucode->u.v2.data;
-}
-
-IWL_UCODE_GET(inst_size);
-IWL_UCODE_GET(data_size);
-IWL_UCODE_GET(init_size);
-IWL_UCODE_GET(init_data_size);
-IWL_UCODE_GET(boot_size);
-
-struct iwl_ucode_ops iwlagn_ucode = {
-       .get_header_size = iwlagn_ucode_get_header_size,
-       .get_build = iwlagn_ucode_get_build,
-       .get_inst_size = iwlagn_ucode_get_inst_size,
-       .get_data_size = iwlagn_ucode_get_data_size,
-       .get_init_size = iwlagn_ucode_get_init_size,
-       .get_init_data_size = iwlagn_ucode_get_init_data_size,
-       .get_boot_size = iwlagn_ucode_get_boot_size,
-       .get_data = iwlagn_ucode_get_data,
-};
-
 /*
  *  Calibration
  */
index f9c9c08ab88eb62bcb2e81fe6e8ed2721726f2b8..7bcc8a3aee4a5e2b151f39a103d95ac33076b9c7 100644 (file)
@@ -1550,7 +1550,7 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
        size_t len;
        u32 api_ver, build;
        u32 inst_size, data_size, init_size, init_data_size, boot_size;
-       int err;
+       int err, hdr_size;
        u16 eeprom_ver;
        char buildstr[25];
 
@@ -1563,8 +1563,8 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
        IWL_DEBUG_INFO(priv, "Loaded firmware file '%s' (%zd bytes).\n",
                       priv->firmware_name, ucode_raw->size);
 
-       /* Make sure that we got at least the v1 header! */
-       if (ucode_raw->size < priv->cfg->ops->ucode->get_header_size(1)) {
+       /* Make sure that we got at least the API version number */
+       if (ucode_raw->size < 4) {
                IWL_ERR(priv, "File size way too small!\n");
                goto try_again;
        }
@@ -1574,14 +1574,47 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
 
        priv->ucode_ver = le32_to_cpu(ucode->ver);
        api_ver = IWL_UCODE_API(priv->ucode_ver);
-       build = priv->cfg->ops->ucode->get_build(ucode, api_ver);
-       inst_size = priv->cfg->ops->ucode->get_inst_size(ucode, api_ver);
-       data_size = priv->cfg->ops->ucode->get_data_size(ucode, api_ver);
-       init_size = priv->cfg->ops->ucode->get_init_size(ucode, api_ver);
-       init_data_size =
-               priv->cfg->ops->ucode->get_init_data_size(ucode, api_ver);
-       boot_size = priv->cfg->ops->ucode->get_boot_size(ucode, api_ver);
-       src = priv->cfg->ops->ucode->get_data(ucode, api_ver);
+
+       switch (api_ver) {
+       default:
+               /*
+                * 4965 doesn't revision the firmware file format
+                * along with the API version, it always uses v1
+                * file format.
+                */
+               if (priv->cfg != &iwl4965_agn_cfg) {
+                       hdr_size = 28;
+                       if (ucode_raw->size < hdr_size) {
+                               IWL_ERR(priv, "File size too small!\n");
+                               goto try_again;
+                       }
+                       build = ucode->u.v2.build;
+                       inst_size = ucode->u.v2.inst_size;
+                       data_size = ucode->u.v2.data_size;
+                       init_size = ucode->u.v2.init_size;
+                       init_data_size = ucode->u.v2.init_data_size;
+                       boot_size = ucode->u.v2.boot_size;
+                       src = ucode->u.v2.data;
+                       break;
+               }
+               /* fall through for 4965 */
+       case 0:
+       case 1:
+       case 2:
+               hdr_size = 24;
+               if (ucode_raw->size < hdr_size) {
+                       IWL_ERR(priv, "File size too small!\n");
+                       goto try_again;
+               }
+               build = 0;
+               inst_size = ucode->u.v1.inst_size;
+               data_size = ucode->u.v1.data_size;
+               init_size = ucode->u.v1.init_size;
+               init_data_size = ucode->u.v1.init_data_size;
+               boot_size = ucode->u.v1.boot_size;
+               src = ucode->u.v1.data;
+               break;
+       }
 
        /* api_ver should match the api version forming part of the
         * firmware filename ... but we don't check for that and only rely
@@ -1646,10 +1679,8 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
         */
 
        /* Verify size of file vs. image size info in file's header */
-       if (ucode_raw->size !=
-               priv->cfg->ops->ucode->get_header_size(api_ver) +
-               inst_size + data_size + init_size +
-               init_data_size + boot_size) {
+       if (ucode_raw->size != hdr_size + inst_size + data_size + init_size +
+                               init_data_size + boot_size) {
 
                IWL_DEBUG_INFO(priv,
                        "uCode file size %d does not match expected size\n",
index a9ba9fc6740a8fb81985789fc71f02419a19353b..4a1e7b2b7a8ed82651db786545b1f0d7b94f30dd 100644 (file)
@@ -66,7 +66,6 @@
 #include "iwl-dev.h"
 
 extern struct iwl_mod_params iwlagn_mod_params;
-extern struct iwl_ucode_ops iwlagn_ucode;
 extern struct iwl_hcmd_ops iwlagn_hcmd;
 extern struct iwl_hcmd_utils_ops iwlagn_hcmd_utils;
 
index 0fa99650f75a2933d5ea06c486396bcb5a620308..2f664a3f0484f881c7b08dd98a4024c7e1102cc1 100644 (file)
@@ -131,17 +131,6 @@ struct iwl_temp_ops {
        void (*set_calib_version)(struct iwl_priv *priv);
 };
 
-struct iwl_ucode_ops {
-       u32 (*get_header_size)(u32);
-       u32 (*get_build)(const struct iwl_ucode_header *, u32);
-       u32 (*get_inst_size)(const struct iwl_ucode_header *, u32);
-       u32 (*get_data_size)(const struct iwl_ucode_header *, u32);
-       u32 (*get_init_size)(const struct iwl_ucode_header *, u32);
-       u32 (*get_init_data_size)(const struct iwl_ucode_header *, u32);
-       u32 (*get_boot_size)(const struct iwl_ucode_header *, u32);
-       u8 * (*get_data)(const struct iwl_ucode_header *, u32);
-};
-
 struct iwl_lib_ops {
        /* set hw dependent parameters */
        int (*set_hw_params)(struct iwl_priv *priv);
@@ -222,7 +211,6 @@ struct iwl_led_ops {
 };
 
 struct iwl_ops {
-       const struct iwl_ucode_ops *ucode;
        const struct iwl_lib_ops *lib;
        const struct iwl_hcmd_ops *hcmd;
        const struct iwl_hcmd_utils_ops *utils;
index e485465e4d56caa18429783c0808ccf1d7b6e317..fe938d9e43cbd7cc2a5e03ec1cdfe3c705d868aa 100644 (file)
@@ -541,7 +541,6 @@ struct iwl_ucode_header {
                } v2;
        } u;
 };
-#define UCODE_HEADER_SIZE(ver) ((ver) == 1 ? 24 : 28)
 
 struct iwl4965_ibss_seq {
        u8 mac[ETH_ALEN];
index e9de10964c5126270c43fe9b1532cd5065dd9884..59c85f55e625d178dbd32e81431deb5216e8f19d 100644 (file)
@@ -2117,7 +2117,7 @@ static u32 iwl3945_ucode_get_##item(const struct iwl_ucode_header *ucode)\
 
 static u32 iwl3945_ucode_get_header_size(u32 api_ver)
 {
-       return UCODE_HEADER_SIZE(1);
+       return 24;
 }
 
 static u8 *iwl3945_ucode_get_data(const struct iwl_ucode_header *ucode)