aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2010-04-28 15:09:14 -0400
committerReinette Chatre <reinette.chatre@intel.com>2010-05-10 18:08:54 -0400
commit22adba2a6995dc24663251ffb954f8856968f26e (patch)
treedbfaf7fa3926244445cbe51ec582ea2952f78bf3
parent93b1a2f919a752bb689fdb0c5817c643c2f74435 (diff)
iwlwifi: remove ucode virtual functions
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>
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-1000.c1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965.c39
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-5000.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-6000.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-ucode.c49
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c61
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.h1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.h12
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-dev.h1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c2
10 files changed, 47 insertions, 123 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-1000.c b/drivers/net/wireless/iwlwifi/iwl-1000.c
index ebaf02d47e73..a2f7cbcc2f7c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-1000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-1000.c
@@ -225,7 +225,6 @@ static struct iwl_lib_ops iwl1000_lib = {
225}; 225};
226 226
227static const struct iwl_ops iwl1000_ops = { 227static const struct iwl_ops iwl1000_ops = {
228 .ucode = &iwlagn_ucode,
229 .lib = &iwl1000_lib, 228 .lib = &iwl1000_lib,
230 .hcmd = &iwlagn_hcmd, 229 .hcmd = &iwlagn_hcmd,
231 .utils = &iwlagn_hcmd_utils, 230 .utils = &iwlagn_hcmd_utils,
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index 5904a1beac4d..a3562a126c93 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -2112,34 +2112,6 @@ static void iwl4965_cancel_deferred_work(struct iwl_priv *priv)
2112 cancel_work_sync(&priv->txpower_work); 2112 cancel_work_sync(&priv->txpower_work);
2113} 2113}
2114 2114
2115#define IWL4965_UCODE_GET(item) \
2116static u32 iwl4965_ucode_get_##item(const struct iwl_ucode_header *ucode,\
2117 u32 api_ver) \
2118{ \
2119 return le32_to_cpu(ucode->u.v1.item); \
2120}
2121
2122static u32 iwl4965_ucode_get_header_size(u32 api_ver)
2123{
2124 return UCODE_HEADER_SIZE(1);
2125}
2126static u32 iwl4965_ucode_get_build(const struct iwl_ucode_header *ucode,
2127 u32 api_ver)
2128{
2129 return 0;
2130}
2131static u8 *iwl4965_ucode_get_data(const struct iwl_ucode_header *ucode,
2132 u32 api_ver)
2133{
2134 return (u8 *) ucode->u.v1.data;
2135}
2136
2137IWL4965_UCODE_GET(inst_size);
2138IWL4965_UCODE_GET(data_size);
2139IWL4965_UCODE_GET(init_size);
2140IWL4965_UCODE_GET(init_data_size);
2141IWL4965_UCODE_GET(boot_size);
2142
2143static struct iwl_hcmd_ops iwl4965_hcmd = { 2115static struct iwl_hcmd_ops iwl4965_hcmd = {
2144 .rxon_assoc = iwl4965_send_rxon_assoc, 2116 .rxon_assoc = iwl4965_send_rxon_assoc,
2145 .commit_rxon = iwl_commit_rxon, 2117 .commit_rxon = iwl_commit_rxon,
@@ -2147,16 +2119,6 @@ static struct iwl_hcmd_ops iwl4965_hcmd = {
2147 .send_bt_config = iwl_send_bt_config, 2119 .send_bt_config = iwl_send_bt_config,
2148}; 2120};
2149 2121
2150static struct iwl_ucode_ops iwl4965_ucode = {
2151 .get_header_size = iwl4965_ucode_get_header_size,
2152 .get_build = iwl4965_ucode_get_build,
2153 .get_inst_size = iwl4965_ucode_get_inst_size,
2154 .get_data_size = iwl4965_ucode_get_data_size,
2155 .get_init_size = iwl4965_ucode_get_init_size,
2156 .get_init_data_size = iwl4965_ucode_get_init_data_size,
2157 .get_boot_size = iwl4965_ucode_get_boot_size,
2158 .get_data = iwl4965_ucode_get_data,
2159};
2160static struct iwl_hcmd_utils_ops iwl4965_hcmd_utils = { 2122static struct iwl_hcmd_utils_ops iwl4965_hcmd_utils = {
2161 .get_hcmd_size = iwl4965_get_hcmd_size, 2123 .get_hcmd_size = iwl4965_get_hcmd_size,
2162 .build_addsta_hcmd = iwl4965_build_addsta_hcmd, 2124 .build_addsta_hcmd = iwl4965_build_addsta_hcmd,
@@ -2229,7 +2191,6 @@ static struct iwl_lib_ops iwl4965_lib = {
2229}; 2191};
2230 2192
2231static const struct iwl_ops iwl4965_ops = { 2193static const struct iwl_ops iwl4965_ops = {
2232 .ucode = &iwl4965_ucode,
2233 .lib = &iwl4965_lib, 2194 .lib = &iwl4965_lib,
2234 .hcmd = &iwl4965_hcmd, 2195 .hcmd = &iwl4965_hcmd,
2235 .utils = &iwl4965_hcmd_utils, 2196 .utils = &iwl4965_hcmd_utils,
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c
index bde0f18cbae9..efda0e8ccacb 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-5000.c
@@ -427,7 +427,6 @@ static struct iwl_lib_ops iwl5150_lib = {
427}; 427};
428 428
429static const struct iwl_ops iwl5000_ops = { 429static const struct iwl_ops iwl5000_ops = {
430 .ucode = &iwlagn_ucode,
431 .lib = &iwl5000_lib, 430 .lib = &iwl5000_lib,
432 .hcmd = &iwlagn_hcmd, 431 .hcmd = &iwlagn_hcmd,
433 .utils = &iwlagn_hcmd_utils, 432 .utils = &iwlagn_hcmd_utils,
@@ -435,7 +434,6 @@ static const struct iwl_ops iwl5000_ops = {
435}; 434};
436 435
437static const struct iwl_ops iwl5150_ops = { 436static const struct iwl_ops iwl5150_ops = {
438 .ucode = &iwlagn_ucode,
439 .lib = &iwl5150_lib, 437 .lib = &iwl5150_lib,
440 .hcmd = &iwlagn_hcmd, 438 .hcmd = &iwlagn_hcmd,
441 .utils = &iwlagn_hcmd_utils, 439 .utils = &iwlagn_hcmd_utils,
diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c
index 5f0f58693104..03c73244703c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-6000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-6000.c
@@ -330,7 +330,6 @@ static struct iwl_lib_ops iwl6000_lib = {
330}; 330};
331 331
332static const struct iwl_ops iwl6000_ops = { 332static const struct iwl_ops iwl6000_ops = {
333 .ucode = &iwlagn_ucode,
334 .lib = &iwl6000_lib, 333 .lib = &iwl6000_lib,
335 .hcmd = &iwlagn_hcmd, 334 .hcmd = &iwlagn_hcmd,
336 .utils = &iwlagn_hcmd_utils, 335 .utils = &iwlagn_hcmd_utils,
@@ -404,7 +403,6 @@ static struct iwl_lib_ops iwl6050_lib = {
404}; 403};
405 404
406static const struct iwl_ops iwl6050_ops = { 405static const struct iwl_ops iwl6050_ops = {
407 .ucode = &iwlagn_ucode,
408 .lib = &iwl6050_lib, 406 .lib = &iwl6050_lib,
409 .hcmd = &iwlagn_hcmd, 407 .hcmd = &iwlagn_hcmd,
410 .utils = &iwlagn_hcmd_utils, 408 .utils = &iwlagn_hcmd_utils,
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
index c3e3283426a9..637286c396fe 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
@@ -182,55 +182,6 @@ int iwlagn_load_ucode(struct iwl_priv *priv)
182 return ret; 182 return ret;
183} 183}
184 184
185#define IWL_UCODE_GET(item) \
186static u32 iwlagn_ucode_get_##item(const struct iwl_ucode_header *ucode,\
187 u32 api_ver) \
188{ \
189 if (api_ver <= 2) \
190 return le32_to_cpu(ucode->u.v1.item); \
191 return le32_to_cpu(ucode->u.v2.item); \
192}
193
194static u32 iwlagn_ucode_get_header_size(u32 api_ver)
195{
196 if (api_ver <= 2)
197 return UCODE_HEADER_SIZE(1);
198 return UCODE_HEADER_SIZE(2);
199}
200
201static u32 iwlagn_ucode_get_build(const struct iwl_ucode_header *ucode,
202 u32 api_ver)
203{
204 if (api_ver <= 2)
205 return 0;
206 return le32_to_cpu(ucode->u.v2.build);
207}
208
209static u8 *iwlagn_ucode_get_data(const struct iwl_ucode_header *ucode,
210 u32 api_ver)
211{
212 if (api_ver <= 2)
213 return (u8 *) ucode->u.v1.data;
214 return (u8 *) ucode->u.v2.data;
215}
216
217IWL_UCODE_GET(inst_size);
218IWL_UCODE_GET(data_size);
219IWL_UCODE_GET(init_size);
220IWL_UCODE_GET(init_data_size);
221IWL_UCODE_GET(boot_size);
222
223struct iwl_ucode_ops iwlagn_ucode = {
224 .get_header_size = iwlagn_ucode_get_header_size,
225 .get_build = iwlagn_ucode_get_build,
226 .get_inst_size = iwlagn_ucode_get_inst_size,
227 .get_data_size = iwlagn_ucode_get_data_size,
228 .get_init_size = iwlagn_ucode_get_init_size,
229 .get_init_data_size = iwlagn_ucode_get_init_data_size,
230 .get_boot_size = iwlagn_ucode_get_boot_size,
231 .get_data = iwlagn_ucode_get_data,
232};
233
234/* 185/*
235 * Calibration 186 * Calibration
236 */ 187 */
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index f9c9c08ab88e..7bcc8a3aee4a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -1550,7 +1550,7 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
1550 size_t len; 1550 size_t len;
1551 u32 api_ver, build; 1551 u32 api_ver, build;
1552 u32 inst_size, data_size, init_size, init_data_size, boot_size; 1552 u32 inst_size, data_size, init_size, init_data_size, boot_size;
1553 int err; 1553 int err, hdr_size;
1554 u16 eeprom_ver; 1554 u16 eeprom_ver;
1555 char buildstr[25]; 1555 char buildstr[25];
1556 1556
@@ -1563,8 +1563,8 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
1563 IWL_DEBUG_INFO(priv, "Loaded firmware file '%s' (%zd bytes).\n", 1563 IWL_DEBUG_INFO(priv, "Loaded firmware file '%s' (%zd bytes).\n",
1564 priv->firmware_name, ucode_raw->size); 1564 priv->firmware_name, ucode_raw->size);
1565 1565
1566 /* Make sure that we got at least the v1 header! */ 1566 /* Make sure that we got at least the API version number */
1567 if (ucode_raw->size < priv->cfg->ops->ucode->get_header_size(1)) { 1567 if (ucode_raw->size < 4) {
1568 IWL_ERR(priv, "File size way too small!\n"); 1568 IWL_ERR(priv, "File size way too small!\n");
1569 goto try_again; 1569 goto try_again;
1570 } 1570 }
@@ -1574,14 +1574,47 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
1574 1574
1575 priv->ucode_ver = le32_to_cpu(ucode->ver); 1575 priv->ucode_ver = le32_to_cpu(ucode->ver);
1576 api_ver = IWL_UCODE_API(priv->ucode_ver); 1576 api_ver = IWL_UCODE_API(priv->ucode_ver);
1577 build = priv->cfg->ops->ucode->get_build(ucode, api_ver); 1577
1578 inst_size = priv->cfg->ops->ucode->get_inst_size(ucode, api_ver); 1578 switch (api_ver) {
1579 data_size = priv->cfg->ops->ucode->get_data_size(ucode, api_ver); 1579 default:
1580 init_size = priv->cfg->ops->ucode->get_init_size(ucode, api_ver); 1580 /*
1581 init_data_size = 1581 * 4965 doesn't revision the firmware file format
1582 priv->cfg->ops->ucode->get_init_data_size(ucode, api_ver); 1582 * along with the API version, it always uses v1
1583 boot_size = priv->cfg->ops->ucode->get_boot_size(ucode, api_ver); 1583 * file format.
1584 src = priv->cfg->ops->ucode->get_data(ucode, api_ver); 1584 */
1585 if (priv->cfg != &iwl4965_agn_cfg) {
1586 hdr_size = 28;
1587 if (ucode_raw->size < hdr_size) {
1588 IWL_ERR(priv, "File size too small!\n");
1589 goto try_again;
1590 }
1591 build = ucode->u.v2.build;
1592 inst_size = ucode->u.v2.inst_size;
1593 data_size = ucode->u.v2.data_size;
1594 init_size = ucode->u.v2.init_size;
1595 init_data_size = ucode->u.v2.init_data_size;
1596 boot_size = ucode->u.v2.boot_size;
1597 src = ucode->u.v2.data;
1598 break;
1599 }
1600 /* fall through for 4965 */
1601 case 0:
1602 case 1:
1603 case 2:
1604 hdr_size = 24;
1605 if (ucode_raw->size < hdr_size) {
1606 IWL_ERR(priv, "File size too small!\n");
1607 goto try_again;
1608 }
1609 build = 0;
1610 inst_size = ucode->u.v1.inst_size;
1611 data_size = ucode->u.v1.data_size;
1612 init_size = ucode->u.v1.init_size;
1613 init_data_size = ucode->u.v1.init_data_size;
1614 boot_size = ucode->u.v1.boot_size;
1615 src = ucode->u.v1.data;
1616 break;
1617 }
1585 1618
1586 /* api_ver should match the api version forming part of the 1619 /* api_ver should match the api version forming part of the
1587 * firmware filename ... but we don't check for that and only rely 1620 * 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)
1646 */ 1679 */
1647 1680
1648 /* Verify size of file vs. image size info in file's header */ 1681 /* Verify size of file vs. image size info in file's header */
1649 if (ucode_raw->size != 1682 if (ucode_raw->size != hdr_size + inst_size + data_size + init_size +
1650 priv->cfg->ops->ucode->get_header_size(api_ver) + 1683 init_data_size + boot_size) {
1651 inst_size + data_size + init_size +
1652 init_data_size + boot_size) {
1653 1684
1654 IWL_DEBUG_INFO(priv, 1685 IWL_DEBUG_INFO(priv,
1655 "uCode file size %d does not match expected size\n", 1686 "uCode file size %d does not match expected size\n",
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h
index a9ba9fc6740a..4a1e7b2b7a8e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.h
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.h
@@ -66,7 +66,6 @@
66#include "iwl-dev.h" 66#include "iwl-dev.h"
67 67
68extern struct iwl_mod_params iwlagn_mod_params; 68extern struct iwl_mod_params iwlagn_mod_params;
69extern struct iwl_ucode_ops iwlagn_ucode;
70extern struct iwl_hcmd_ops iwlagn_hcmd; 69extern struct iwl_hcmd_ops iwlagn_hcmd;
71extern struct iwl_hcmd_utils_ops iwlagn_hcmd_utils; 70extern struct iwl_hcmd_utils_ops iwlagn_hcmd_utils;
72 71
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h
index 0fa99650f75a..2f664a3f0484 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.h
+++ b/drivers/net/wireless/iwlwifi/iwl-core.h
@@ -131,17 +131,6 @@ struct iwl_temp_ops {
131 void (*set_calib_version)(struct iwl_priv *priv); 131 void (*set_calib_version)(struct iwl_priv *priv);
132}; 132};
133 133
134struct iwl_ucode_ops {
135 u32 (*get_header_size)(u32);
136 u32 (*get_build)(const struct iwl_ucode_header *, u32);
137 u32 (*get_inst_size)(const struct iwl_ucode_header *, u32);
138 u32 (*get_data_size)(const struct iwl_ucode_header *, u32);
139 u32 (*get_init_size)(const struct iwl_ucode_header *, u32);
140 u32 (*get_init_data_size)(const struct iwl_ucode_header *, u32);
141 u32 (*get_boot_size)(const struct iwl_ucode_header *, u32);
142 u8 * (*get_data)(const struct iwl_ucode_header *, u32);
143};
144
145struct iwl_lib_ops { 134struct iwl_lib_ops {
146 /* set hw dependent parameters */ 135 /* set hw dependent parameters */
147 int (*set_hw_params)(struct iwl_priv *priv); 136 int (*set_hw_params)(struct iwl_priv *priv);
@@ -222,7 +211,6 @@ struct iwl_led_ops {
222}; 211};
223 212
224struct iwl_ops { 213struct iwl_ops {
225 const struct iwl_ucode_ops *ucode;
226 const struct iwl_lib_ops *lib; 214 const struct iwl_lib_ops *lib;
227 const struct iwl_hcmd_ops *hcmd; 215 const struct iwl_hcmd_ops *hcmd;
228 const struct iwl_hcmd_utils_ops *utils; 216 const struct iwl_hcmd_utils_ops *utils;
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index e485465e4d56..fe938d9e43cb 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -541,7 +541,6 @@ struct iwl_ucode_header {
541 } v2; 541 } v2;
542 } u; 542 } u;
543}; 543};
544#define UCODE_HEADER_SIZE(ver) ((ver) == 1 ? 24 : 28)
545 544
546struct iwl4965_ibss_seq { 545struct iwl4965_ibss_seq {
547 u8 mac[ETH_ALEN]; 546 u8 mac[ETH_ALEN];
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index e9de10964c51..59c85f55e625 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -2117,7 +2117,7 @@ static u32 iwl3945_ucode_get_##item(const struct iwl_ucode_header *ucode)\
2117 2117
2118static u32 iwl3945_ucode_get_header_size(u32 api_ver) 2118static u32 iwl3945_ucode_get_header_size(u32 api_ver)
2119{ 2119{
2120 return UCODE_HEADER_SIZE(1); 2120 return 24;
2121} 2121}
2122 2122
2123static u8 *iwl3945_ucode_get_data(const struct iwl_ucode_header *ucode) 2123static u8 *iwl3945_ucode_get_data(const struct iwl_ucode_header *ucode)