aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi
diff options
context:
space:
mode:
authorWey-Yi Guy <wey-yi.w.guy@intel.com>2010-03-16 13:23:29 -0400
committerReinette Chatre <reinette.chatre@intel.com>2010-03-25 14:17:04 -0400
commit792bc3cbe06cddabd865acc3122ee0415f854a11 (patch)
treecf50819d0950d45429f9f4cf8b7d0241ee9d727a /drivers/net/wireless/iwlwifi
parent872c8ddcbec06995c1c7caa3e41c921290a8b6df (diff)
iwlwifi: move ucode loading related code to separated file
Multiple iwlagn based devices shared the same ucode loading procedure. Move loading related code from iwl-5000.c to iwl-agn-ucode.c file. Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com> Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi')
-rw-r--r--drivers/net/wireless/iwlwifi/Makefile1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-1000.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-5000.c54
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-6000.c4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-ucode.c84
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.h2
6 files changed, 92 insertions, 55 deletions
diff --git a/drivers/net/wireless/iwlwifi/Makefile b/drivers/net/wireless/iwlwifi/Makefile
index e31a5ccebea2..cc4fe20c45eb 100644
--- a/drivers/net/wireless/iwlwifi/Makefile
+++ b/drivers/net/wireless/iwlwifi/Makefile
@@ -10,6 +10,7 @@ CFLAGS_iwl-devtrace.o := -I$(src)
10# AGN 10# AGN
11obj-$(CONFIG_IWLAGN) += iwlagn.o 11obj-$(CONFIG_IWLAGN) += iwlagn.o
12iwlagn-objs := iwl-agn.o iwl-agn-rs.o iwl-agn-led.o iwl-agn-ict.o 12iwlagn-objs := iwl-agn.o iwl-agn-rs.o iwl-agn-led.o iwl-agn-ict.o
13iwlagn-objs += iwl-agn-ucode.o
13 14
14iwlagn-$(CONFIG_IWL4965) += iwl-4965.o 15iwlagn-$(CONFIG_IWL4965) += iwl-4965.o
15iwlagn-$(CONFIG_IWL5000) += iwl-5000.o 16iwlagn-$(CONFIG_IWL5000) += iwl-5000.o
diff --git a/drivers/net/wireless/iwlwifi/iwl-1000.c b/drivers/net/wireless/iwlwifi/iwl-1000.c
index 9e392896005d..ad61464703cb 100644
--- a/drivers/net/wireless/iwlwifi/iwl-1000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-1000.c
@@ -218,7 +218,7 @@ static struct iwl_lib_ops iwl1000_lib = {
218}; 218};
219 219
220static const struct iwl_ops iwl1000_ops = { 220static const struct iwl_ops iwl1000_ops = {
221 .ucode = &iwl5000_ucode, 221 .ucode = &iwlagn_ucode,
222 .lib = &iwl1000_lib, 222 .lib = &iwl1000_lib,
223 .hcmd = &iwl5000_hcmd, 223 .hcmd = &iwl5000_hcmd,
224 .utils = &iwl5000_hcmd_utils, 224 .utils = &iwl5000_hcmd_utils,
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c
index 2267cad49cbf..bbcb9c5dde6a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-5000.c
@@ -1348,45 +1348,6 @@ static int iwl5000_send_tx_ant_config(struct iwl_priv *priv, u8 valid_tx_ant)
1348 } 1348 }
1349} 1349}
1350 1350
1351
1352#define IWL5000_UCODE_GET(item) \
1353static u32 iwl5000_ucode_get_##item(const struct iwl_ucode_header *ucode,\
1354 u32 api_ver) \
1355{ \
1356 if (api_ver <= 2) \
1357 return le32_to_cpu(ucode->u.v1.item); \
1358 return le32_to_cpu(ucode->u.v2.item); \
1359}
1360
1361static u32 iwl5000_ucode_get_header_size(u32 api_ver)
1362{
1363 if (api_ver <= 2)
1364 return UCODE_HEADER_SIZE(1);
1365 return UCODE_HEADER_SIZE(2);
1366}
1367
1368static u32 iwl5000_ucode_get_build(const struct iwl_ucode_header *ucode,
1369 u32 api_ver)
1370{
1371 if (api_ver <= 2)
1372 return 0;
1373 return le32_to_cpu(ucode->u.v2.build);
1374}
1375
1376static u8 *iwl5000_ucode_get_data(const struct iwl_ucode_header *ucode,
1377 u32 api_ver)
1378{
1379 if (api_ver <= 2)
1380 return (u8 *) ucode->u.v1.data;
1381 return (u8 *) ucode->u.v2.data;
1382}
1383
1384IWL5000_UCODE_GET(inst_size);
1385IWL5000_UCODE_GET(data_size);
1386IWL5000_UCODE_GET(init_size);
1387IWL5000_UCODE_GET(init_data_size);
1388IWL5000_UCODE_GET(boot_size);
1389
1390static int iwl5000_hw_channel_switch(struct iwl_priv *priv, u16 channel) 1351static int iwl5000_hw_channel_switch(struct iwl_priv *priv, u16 channel)
1391{ 1352{
1392 struct iwl5000_channel_switch_cmd cmd; 1353 struct iwl5000_channel_switch_cmd cmd;
@@ -1435,17 +1396,6 @@ struct iwl_hcmd_utils_ops iwl5000_hcmd_utils = {
1435 .calc_rssi = iwl5000_calc_rssi, 1396 .calc_rssi = iwl5000_calc_rssi,
1436}; 1397};
1437 1398
1438struct iwl_ucode_ops iwl5000_ucode = {
1439 .get_header_size = iwl5000_ucode_get_header_size,
1440 .get_build = iwl5000_ucode_get_build,
1441 .get_inst_size = iwl5000_ucode_get_inst_size,
1442 .get_data_size = iwl5000_ucode_get_data_size,
1443 .get_init_size = iwl5000_ucode_get_init_size,
1444 .get_init_data_size = iwl5000_ucode_get_init_data_size,
1445 .get_boot_size = iwl5000_ucode_get_boot_size,
1446 .get_data = iwl5000_ucode_get_data,
1447};
1448
1449struct iwl_lib_ops iwl5000_lib = { 1399struct iwl_lib_ops iwl5000_lib = {
1450 .set_hw_params = iwl5000_hw_set_hw_params, 1400 .set_hw_params = iwl5000_hw_set_hw_params,
1451 .txq_update_byte_cnt_tbl = iwl5000_txq_update_byte_cnt_tbl, 1401 .txq_update_byte_cnt_tbl = iwl5000_txq_update_byte_cnt_tbl,
@@ -1562,7 +1512,7 @@ static struct iwl_lib_ops iwl5150_lib = {
1562}; 1512};
1563 1513
1564static const struct iwl_ops iwl5000_ops = { 1514static const struct iwl_ops iwl5000_ops = {
1565 .ucode = &iwl5000_ucode, 1515 .ucode = &iwlagn_ucode,
1566 .lib = &iwl5000_lib, 1516 .lib = &iwl5000_lib,
1567 .hcmd = &iwl5000_hcmd, 1517 .hcmd = &iwl5000_hcmd,
1568 .utils = &iwl5000_hcmd_utils, 1518 .utils = &iwl5000_hcmd_utils,
@@ -1570,7 +1520,7 @@ static const struct iwl_ops iwl5000_ops = {
1570}; 1520};
1571 1521
1572static const struct iwl_ops iwl5150_ops = { 1522static const struct iwl_ops iwl5150_ops = {
1573 .ucode = &iwl5000_ucode, 1523 .ucode = &iwlagn_ucode,
1574 .lib = &iwl5150_lib, 1524 .lib = &iwl5150_lib,
1575 .hcmd = &iwl5000_hcmd, 1525 .hcmd = &iwl5000_hcmd,
1576 .utils = &iwl5000_hcmd_utils, 1526 .utils = &iwl5000_hcmd_utils,
diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c
index d75799946a7e..4026eb4e7faa 100644
--- a/drivers/net/wireless/iwlwifi/iwl-6000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-6000.c
@@ -284,7 +284,7 @@ static struct iwl_lib_ops iwl6000_lib = {
284}; 284};
285 285
286static const struct iwl_ops iwl6000_ops = { 286static const struct iwl_ops iwl6000_ops = {
287 .ucode = &iwl5000_ucode, 287 .ucode = &iwlagn_ucode,
288 .lib = &iwl6000_lib, 288 .lib = &iwl6000_lib,
289 .hcmd = &iwl5000_hcmd, 289 .hcmd = &iwl5000_hcmd,
290 .utils = &iwl5000_hcmd_utils, 290 .utils = &iwl5000_hcmd_utils,
@@ -352,7 +352,7 @@ static struct iwl_lib_ops iwl6050_lib = {
352}; 352};
353 353
354static const struct iwl_ops iwl6050_ops = { 354static const struct iwl_ops iwl6050_ops = {
355 .ucode = &iwl5000_ucode, 355 .ucode = &iwlagn_ucode,
356 .lib = &iwl6050_lib, 356 .lib = &iwl6050_lib,
357 .hcmd = &iwl5000_hcmd, 357 .hcmd = &iwl5000_hcmd,
358 .utils = &iwl5000_hcmd_utils, 358 .utils = &iwl5000_hcmd_utils,
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
new file mode 100644
index 000000000000..67f15c0d2a4a
--- /dev/null
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
@@ -0,0 +1,84 @@
1/******************************************************************************
2 *
3 * GPL LICENSE SUMMARY
4 *
5 * Copyright(c) 2008 - 2010 Intel Corporation. All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of version 2 of the GNU General Public License as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
19 * USA
20 *
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
23 *
24 * Contact Information:
25 * Intel Linux Wireless <ilw@linux.intel.com>
26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *
28 *****************************************************************************/
29
30#include <linux/kernel.h>
31#include <linux/module.h>
32#include <linux/init.h>
33
34#include "iwl-dev.h"
35#include "iwl-core.h"
36
37#define IWL_UCODE_GET(item) \
38static u32 iwlagn_ucode_get_##item(const struct iwl_ucode_header *ucode,\
39 u32 api_ver) \
40{ \
41 if (api_ver <= 2) \
42 return le32_to_cpu(ucode->u.v1.item); \
43 return le32_to_cpu(ucode->u.v2.item); \
44}
45
46static u32 iwlagn_ucode_get_header_size(u32 api_ver)
47{
48 if (api_ver <= 2)
49 return UCODE_HEADER_SIZE(1);
50 return UCODE_HEADER_SIZE(2);
51}
52
53static u32 iwlagn_ucode_get_build(const struct iwl_ucode_header *ucode,
54 u32 api_ver)
55{
56 if (api_ver <= 2)
57 return 0;
58 return le32_to_cpu(ucode->u.v2.build);
59}
60
61static u8 *iwlagn_ucode_get_data(const struct iwl_ucode_header *ucode,
62 u32 api_ver)
63{
64 if (api_ver <= 2)
65 return (u8 *) ucode->u.v1.data;
66 return (u8 *) ucode->u.v2.data;
67}
68
69IWL_UCODE_GET(inst_size);
70IWL_UCODE_GET(data_size);
71IWL_UCODE_GET(init_size);
72IWL_UCODE_GET(init_data_size);
73IWL_UCODE_GET(boot_size);
74
75struct iwl_ucode_ops iwlagn_ucode = {
76 .get_header_size = iwlagn_ucode_get_header_size,
77 .get_build = iwlagn_ucode_get_build,
78 .get_inst_size = iwlagn_ucode_get_inst_size,
79 .get_data_size = iwlagn_ucode_get_data_size,
80 .get_init_size = iwlagn_ucode_get_init_size,
81 .get_init_data_size = iwlagn_ucode_get_init_data_size,
82 .get_boot_size = iwlagn_ucode_get_boot_size,
83 .get_data = iwlagn_ucode_get_data,
84};
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h
index 42c291b12546..a266649a8bf5 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.h
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.h
@@ -65,6 +65,8 @@
65 65
66#include "iwl-dev.h" 66#include "iwl-dev.h"
67 67
68extern struct iwl_ucode_ops iwlagn_ucode;
69
68int iwl_reset_ict(struct iwl_priv *priv); 70int iwl_reset_ict(struct iwl_priv *priv);
69void iwl_disable_ict(struct iwl_priv *priv); 71void iwl_disable_ict(struct iwl_priv *priv);
70int iwl_alloc_isr_ict(struct iwl_priv *priv); 72int iwl_alloc_isr_ict(struct iwl_priv *priv);