aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStanislaw Gruszka <sgruszka@redhat.com>2012-02-03 11:31:58 -0500
committerJohn W. Linville <linville@tuxdriver.com>2012-02-06 14:56:11 -0500
commitc39ae9fd505ae314a7a4a159a41e3e022cfa317f (patch)
tree246d8cffde50f436bd598292d01a268fc7392431
parent83007196037cc2d0bffd9f7afbe56d675779a6cb (diff)
iwlegacy: move ops out of config
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/iwlegacy/3945-mac.c22
-rw-r--r--drivers/net/wireless/iwlegacy/3945.c13
-rw-r--r--drivers/net/wireless/iwlegacy/3945.h4
-rw-r--r--drivers/net/wireless/iwlegacy/4965-calib.c4
-rw-r--r--drivers/net/wireless/iwlegacy/4965-mac.c78
-rw-r--r--drivers/net/wireless/iwlegacy/4965.c34
-rw-r--r--drivers/net/wireless/iwlegacy/4965.h3
-rw-r--r--drivers/net/wireless/iwlegacy/common.c115
-rw-r--r--drivers/net/wireless/iwlegacy/common.h8
-rw-r--r--drivers/net/wireless/iwlegacy/debug.c13
10 files changed, 127 insertions, 167 deletions
diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
index b2e04c591c6e..40ce692b2c94 100644
--- a/drivers/net/wireless/iwlegacy/3945-mac.c
+++ b/drivers/net/wireless/iwlegacy/3945-mac.c
@@ -618,8 +618,7 @@ il3945_tx_skb(struct il_priv *il, struct sk_buff *skb)
618 618
619 /* Add buffer containing Tx command and MAC(!) header to TFD's 619 /* Add buffer containing Tx command and MAC(!) header to TFD's
620 * first entry */ 620 * first entry */
621 il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, txcmd_phys, len, 1, 621 il->ops->lib->txq_attach_buf_to_tfd(il, txq, txcmd_phys, len, 1, 0);
622 0);
623 622
624 /* Set up TFD's 2nd entry to point directly to remainder of skb, 623 /* Set up TFD's 2nd entry to point directly to remainder of skb,
625 * if any (802.11 null frames have no payload). */ 624 * if any (802.11 null frames have no payload). */
@@ -628,8 +627,8 @@ il3945_tx_skb(struct il_priv *il, struct sk_buff *skb)
628 phys_addr = 627 phys_addr =
629 pci_map_single(il->pci_dev, skb->data + hdr_len, len, 628 pci_map_single(il->pci_dev, skb->data + hdr_len, len,
630 PCI_DMA_TODEVICE); 629 PCI_DMA_TODEVICE);
631 il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, phys_addr, 630 il->ops->lib->txq_attach_buf_to_tfd(il, txq, phys_addr, len, 0,
632 len, 0, U32_PAD(len)); 631 U32_PAD(len));
633 } 632 }
634 633
635 /* Tell device the write idx *just past* this latest filled TFD */ 634 /* Tell device the write idx *just past* this latest filled TFD */
@@ -2416,7 +2415,7 @@ __il3945_up(struct il_priv *il)
2416 /* load bootstrap state machine, 2415 /* load bootstrap state machine,
2417 * load bootstrap program into processor's memory, 2416 * load bootstrap program into processor's memory,
2418 * prepare to load the "initialize" uCode */ 2417 * prepare to load the "initialize" uCode */
2419 rc = il->cfg->ops->lib->load_ucode(il); 2418 rc = il->ops->lib->load_ucode(il);
2420 2419
2421 if (rc) { 2420 if (rc) {
2422 IL_ERR("Unable to set up bootstrap uCode: %d\n", rc); 2421 IL_ERR("Unable to set up bootstrap uCode: %d\n", rc);
@@ -3458,7 +3457,7 @@ static struct attribute_group il3945_attribute_group = {
3458 .attrs = il3945_sysfs_entries, 3457 .attrs = il3945_sysfs_entries,
3459}; 3458};
3460 3459
3461struct ieee80211_ops il3945_hw_ops = { 3460struct ieee80211_ops il3945_mac_ops = {
3462 .tx = il3945_mac_tx, 3461 .tx = il3945_mac_tx,
3463 .start = il3945_mac_start, 3462 .start = il3945_mac_start,
3464 .stop = il3945_mac_stop, 3463 .stop = il3945_mac_stop,
@@ -3599,15 +3598,13 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
3599 * 1. Allocating HW data 3598 * 1. Allocating HW data
3600 * ********************/ 3599 * ********************/
3601 3600
3602 /* mac80211 allocates memory for this device instance, including 3601 hw = ieee80211_alloc_hw(sizeof(struct il_priv), &il3945_mac_ops);
3603 * space for this driver's ilate structure */ 3602 if (!hw) {
3604 hw = il_alloc_all(cfg);
3605 if (hw == NULL) {
3606 pr_err("Can not allocate network device\n");
3607 err = -ENOMEM; 3603 err = -ENOMEM;
3608 goto out; 3604 goto out;
3609 } 3605 }
3610 il = hw->priv; 3606 il = hw->priv;
3607 il->hw = hw;
3611 SET_IEEE80211_DEV(hw, &pdev->dev); 3608 SET_IEEE80211_DEV(hw, &pdev->dev);
3612 3609
3613 il->cmd_queue = IL39_CMD_QUEUE_NUM; 3610 il->cmd_queue = IL39_CMD_QUEUE_NUM;
@@ -3618,11 +3615,12 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
3618 */ 3615 */
3619 if (il3945_mod_params.disable_hw_scan) { 3616 if (il3945_mod_params.disable_hw_scan) {
3620 D_INFO("Disabling hw_scan\n"); 3617 D_INFO("Disabling hw_scan\n");
3621 il3945_hw_ops.hw_scan = NULL; 3618 il3945_mac_ops.hw_scan = NULL;
3622 } 3619 }
3623 3620
3624 D_INFO("*** LOAD DRIVER ***\n"); 3621 D_INFO("*** LOAD DRIVER ***\n");
3625 il->cfg = cfg; 3622 il->cfg = cfg;
3623 il->ops = &il3945_ops;
3626 il->pci_dev = pdev; 3624 il->pci_dev = pdev;
3627 il->inta_mask = CSR_INI_SET_MASK; 3625 il->inta_mask = CSR_INI_SET_MASK;
3628 3626
diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c
index 1e617c9fc3cc..918cbefd657a 100644
--- a/drivers/net/wireless/iwlegacy/3945.c
+++ b/drivers/net/wireless/iwlegacy/3945.c
@@ -303,7 +303,7 @@ il3945_tx_queue_reclaim(struct il_priv *il, int txq_id, int idx)
303 tx_info = &txq->txb[txq->q.read_ptr]; 303 tx_info = &txq->txb[txq->q.read_ptr];
304 ieee80211_tx_status_irqsafe(il->hw, tx_info->skb); 304 ieee80211_tx_status_irqsafe(il->hw, tx_info->skb);
305 tx_info->skb = NULL; 305 tx_info->skb = NULL;
306 il->cfg->ops->lib->txq_free_tfd(il, txq); 306 il->ops->lib->txq_free_tfd(il, txq);
307 } 307 }
308 308
309 if (il_queue_space(q) > q->low_mark && txq_id >= 0 && 309 if (il_queue_space(q) > q->low_mark && txq_id >= 0 &&
@@ -960,12 +960,12 @@ il3945_hw_nic_init(struct il_priv *il)
960 struct il_rx_queue *rxq = &il->rxq; 960 struct il_rx_queue *rxq = &il->rxq;
961 961
962 spin_lock_irqsave(&il->lock, flags); 962 spin_lock_irqsave(&il->lock, flags);
963 il->cfg->ops->lib->apm_ops.init(il); 963 il->ops->lib->apm_ops.init(il);
964 spin_unlock_irqrestore(&il->lock, flags); 964 spin_unlock_irqrestore(&il->lock, flags);
965 965
966 il3945_set_pwr_vmain(il); 966 il3945_set_pwr_vmain(il);
967 967
968 il->cfg->ops->lib->apm_ops.config(il); 968 il->ops->lib->apm_ops.config(il);
969 969
970 /* Allocate the RX queue, or reset if it is already allocated */ 970 /* Allocate the RX queue, or reset if it is already allocated */
971 if (!rxq->bd) { 971 if (!rxq->bd) {
@@ -1615,7 +1615,7 @@ il3945_hw_reg_comp_txpower_temp(struct il_priv *il)
1615 } 1615 }
1616 1616
1617 /* send Txpower command for current channel to ucode */ 1617 /* send Txpower command for current channel to ucode */
1618 return il->cfg->ops->lib->send_tx_power(il); 1618 return il->ops->lib->send_tx_power(il);
1619} 1619}
1620 1620
1621int 1621int
@@ -2685,13 +2685,12 @@ static struct il_hcmd_utils_ops il3945_hcmd_utils = {
2685 .post_scan = il3945_post_scan, 2685 .post_scan = il3945_post_scan,
2686}; 2686};
2687 2687
2688static const struct il_ops il3945_ops = { 2688const struct il_ops il3945_ops = {
2689 .lib = &il3945_lib, 2689 .lib = &il3945_lib,
2690 .hcmd = &il3945_hcmd, 2690 .hcmd = &il3945_hcmd,
2691 .utils = &il3945_hcmd_utils, 2691 .utils = &il3945_hcmd_utils,
2692 .led = &il3945_led_ops, 2692 .led = &il3945_led_ops,
2693 .legacy = &il3945_legacy_ops, 2693 .legacy = &il3945_legacy_ops,
2694 .ieee80211_ops = &il3945_hw_ops,
2695}; 2694};
2696 2695
2697static struct il_base_params il3945_base_params = { 2696static struct il_base_params il3945_base_params = {
@@ -2711,7 +2710,6 @@ static struct il_cfg il3945_bg_cfg = {
2711 .ucode_api_min = IL3945_UCODE_API_MIN, 2710 .ucode_api_min = IL3945_UCODE_API_MIN,
2712 .sku = IL_SKU_G, 2711 .sku = IL_SKU_G,
2713 .eeprom_ver = EEPROM_3945_EEPROM_VERSION, 2712 .eeprom_ver = EEPROM_3945_EEPROM_VERSION,
2714 .ops = &il3945_ops,
2715 .mod_params = &il3945_mod_params, 2713 .mod_params = &il3945_mod_params,
2716 .base_params = &il3945_base_params, 2714 .base_params = &il3945_base_params,
2717 .led_mode = IL_LED_BLINK, 2715 .led_mode = IL_LED_BLINK,
@@ -2724,7 +2722,6 @@ static struct il_cfg il3945_abg_cfg = {
2724 .ucode_api_min = IL3945_UCODE_API_MIN, 2722 .ucode_api_min = IL3945_UCODE_API_MIN,
2725 .sku = IL_SKU_A | IL_SKU_G, 2723 .sku = IL_SKU_A | IL_SKU_G,
2726 .eeprom_ver = EEPROM_3945_EEPROM_VERSION, 2724 .eeprom_ver = EEPROM_3945_EEPROM_VERSION,
2727 .ops = &il3945_ops,
2728 .mod_params = &il3945_mod_params, 2725 .mod_params = &il3945_mod_params,
2729 .base_params = &il3945_base_params, 2726 .base_params = &il3945_base_params,
2730 .led_mode = IL_LED_BLINK, 2727 .led_mode = IL_LED_BLINK,
diff --git a/drivers/net/wireless/iwlegacy/3945.h b/drivers/net/wireless/iwlegacy/3945.h
index 8bee127d413d..c00a8d30b6fe 100644
--- a/drivers/net/wireless/iwlegacy/3945.h
+++ b/drivers/net/wireless/iwlegacy/3945.h
@@ -36,6 +36,8 @@ extern const struct pci_device_id il3945_hw_card_ids[];
36 36
37#include "common.h" 37#include "common.h"
38 38
39extern const struct il_ops il3945_ops;
40
39/* Highest firmware API version supported */ 41/* Highest firmware API version supported */
40#define IL3945_UCODE_API_MAX 2 42#define IL3945_UCODE_API_MAX 2
41 43
@@ -261,8 +263,6 @@ extern int il3945_commit_rxon(struct il_priv *il);
261 */ 263 */
262extern u8 il3945_hw_find_station(struct il_priv *il, const u8 * bssid); 264extern u8 il3945_hw_find_station(struct il_priv *il, const u8 * bssid);
263 265
264extern struct ieee80211_ops il3945_hw_ops;
265
266extern __le32 il3945_get_antenna_flags(const struct il_priv *il); 266extern __le32 il3945_get_antenna_flags(const struct il_priv *il);
267extern int il3945_init_hw_rate_table(struct il_priv *il); 267extern int il3945_init_hw_rate_table(struct il_priv *il);
268extern void il3945_reg_txpower_periodic(struct il_priv *il); 268extern void il3945_reg_txpower_periodic(struct il_priv *il);
diff --git a/drivers/net/wireless/iwlegacy/4965-calib.c b/drivers/net/wireless/iwlegacy/4965-calib.c
index f302a6ac6286..bfb361dbba50 100644
--- a/drivers/net/wireless/iwlegacy/4965-calib.c
+++ b/drivers/net/wireless/iwlegacy/4965-calib.c
@@ -923,8 +923,8 @@ il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp)
923 /* Some power changes may have been made during the calibration. 923 /* Some power changes may have been made during the calibration.
924 * Update and commit the RXON 924 * Update and commit the RXON
925 */ 925 */
926 if (il->cfg->ops->lib->update_chain_flags) 926 if (il->ops->lib->update_chain_flags)
927 il->cfg->ops->lib->update_chain_flags(il); 927 il->ops->lib->update_chain_flags(il);
928 928
929 data->state = IL_CHAIN_NOISE_DONE; 929 data->state = IL_CHAIN_NOISE_DONE;
930 il_power_update_mode(il, false); 930 il_power_update_mode(il, false);
diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c
index 4be53cc91981..2bf743fc7829 100644
--- a/drivers/net/wireless/iwlegacy/4965-mac.c
+++ b/drivers/net/wireless/iwlegacy/4965-mac.c
@@ -201,7 +201,7 @@ il4965_hw_nic_init(struct il_priv *il)
201 201
202 /* nic_init */ 202 /* nic_init */
203 spin_lock_irqsave(&il->lock, flags); 203 spin_lock_irqsave(&il->lock, flags);
204 il->cfg->ops->lib->apm_ops.init(il); 204 il->ops->lib->apm_ops.init(il);
205 205
206 /* Set interrupt coalescing calibration timer to default (512 usecs) */ 206 /* Set interrupt coalescing calibration timer to default (512 usecs) */
207 il_write8(il, CSR_INT_COALESCING, IL_HOST_INT_CALIB_TIMEOUT_DEF); 207 il_write8(il, CSR_INT_COALESCING, IL_HOST_INT_CALIB_TIMEOUT_DEF);
@@ -210,7 +210,7 @@ il4965_hw_nic_init(struct il_priv *il)
210 210
211 il4965_set_pwr_vmain(il); 211 il4965_set_pwr_vmain(il);
212 212
213 il->cfg->ops->lib->apm_ops.config(il); 213 il->ops->lib->apm_ops.config(il);
214 214
215 /* Allocate the RX queue, or reset if it is already allocated */ 215 /* Allocate the RX queue, or reset if it is already allocated */
216 if (!rxq->bd) { 216 if (!rxq->bd) {
@@ -1381,8 +1381,8 @@ il4965_hdl_stats(struct il_priv *il, struct il_rx_buf *rxb)
1381 il4965_rx_calc_noise(il); 1381 il4965_rx_calc_noise(il);
1382 queue_work(il->workqueue, &il->run_time_calib_work); 1382 queue_work(il->workqueue, &il->run_time_calib_work);
1383 } 1383 }
1384 if (il->cfg->ops->lib->temp_ops.temperature && change) 1384 if (il->ops->lib->temp_ops.temperature && change)
1385 il->cfg->ops->lib->temp_ops.temperature(il); 1385 il->ops->lib->temp_ops.temperature(il);
1386} 1386}
1387 1387
1388void 1388void
@@ -1817,8 +1817,7 @@ il4965_tx_skb(struct il_priv *il, struct sk_buff *skb)
1817 dma_unmap_len_set(out_meta, len, firstlen); 1817 dma_unmap_len_set(out_meta, len, firstlen);
1818 /* Add buffer containing Tx command and MAC(!) header to TFD's 1818 /* Add buffer containing Tx command and MAC(!) header to TFD's
1819 * first entry */ 1819 * first entry */
1820 il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, txcmd_phys, firstlen, 1820 il->ops->lib->txq_attach_buf_to_tfd(il, txq, txcmd_phys, firstlen, 1, 0);
1821 1, 0);
1822 1821
1823 if (!ieee80211_has_morefrags(hdr->frame_control)) { 1822 if (!ieee80211_has_morefrags(hdr->frame_control)) {
1824 txq->need_update = 1; 1823 txq->need_update = 1;
@@ -1834,8 +1833,8 @@ il4965_tx_skb(struct il_priv *il, struct sk_buff *skb)
1834 phys_addr = 1833 phys_addr =
1835 pci_map_single(il->pci_dev, skb->data + hdr_len, secondlen, 1834 pci_map_single(il->pci_dev, skb->data + hdr_len, secondlen,
1836 PCI_DMA_TODEVICE); 1835 PCI_DMA_TODEVICE);
1837 il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, phys_addr, 1836 il->ops->lib->txq_attach_buf_to_tfd(il, txq, phys_addr,
1838 secondlen, 0, 0); 1837 secondlen, 0, 0);
1839 } 1838 }
1840 1839
1841 scratch_phys = 1840 scratch_phys =
@@ -1855,9 +1854,8 @@ il4965_tx_skb(struct il_priv *il, struct sk_buff *skb)
1855 1854
1856 /* Set up entry for this TFD in Tx byte-count array */ 1855 /* Set up entry for this TFD in Tx byte-count array */
1857 if (info->flags & IEEE80211_TX_CTL_AMPDU) 1856 if (info->flags & IEEE80211_TX_CTL_AMPDU)
1858 il->cfg->ops->lib->txq_update_byte_cnt_tbl(il, txq, 1857 il->ops->lib->txq_update_byte_cnt_tbl(il, txq,
1859 le16_to_cpu(tx_cmd-> 1858 le16_to_cpu(tx_cmd->len));
1860 len));
1861 1859
1862 pci_dma_sync_single_for_device(il->pci_dev, txcmd_phys, firstlen, 1860 pci_dma_sync_single_for_device(il->pci_dev, txcmd_phys, firstlen,
1863 PCI_DMA_BIDIRECTIONAL); 1861 PCI_DMA_BIDIRECTIONAL);
@@ -2479,7 +2477,7 @@ il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int idx)
2479 txq_id >= IL4965_FIRST_AMPDU_QUEUE); 2477 txq_id >= IL4965_FIRST_AMPDU_QUEUE);
2480 tx_info->skb = NULL; 2478 tx_info->skb = NULL;
2481 2479
2482 il->cfg->ops->lib->txq_free_tfd(il, txq); 2480 il->ops->lib->txq_free_tfd(il, txq);
2483 } 2481 }
2484 return nfreed; 2482 return nfreed;
2485} 2483}
@@ -3357,8 +3355,8 @@ il4965_sta_modify_sleep_tx_count(struct il_priv *il, int sta_id, int cnt)
3357void 3355void
3358il4965_update_chain_flags(struct il_priv *il) 3356il4965_update_chain_flags(struct il_priv *il)
3359{ 3357{
3360 if (il->cfg->ops->hcmd->set_rxon_chain) { 3358 if (il->ops->hcmd->set_rxon_chain) {
3361 il->cfg->ops->hcmd->set_rxon_chain(il); 3359 il->ops->hcmd->set_rxon_chain(il);
3362 if (il->active.rx_chain != il->staging.rx_chain) 3360 if (il->active.rx_chain != il->staging.rx_chain)
3363 il_commit_rxon(il); 3361 il_commit_rxon(il);
3364 } 3362 }
@@ -3878,7 +3876,7 @@ il4965_setup_handlers(struct il_priv *il)
3878 /* block ack */ 3876 /* block ack */
3879 il->handlers[N_COMPRESSED_BA] = il4965_hdl_compressed_ba; 3877 il->handlers[N_COMPRESSED_BA] = il4965_hdl_compressed_ba;
3880 /* Set up hardware specific Rx handlers */ 3878 /* Set up hardware specific Rx handlers */
3881 il->cfg->ops->lib->handler_setup(il); 3879 il->ops->lib->handler_setup(il);
3882} 3880}
3883 3881
3884/** 3882/**
@@ -4780,7 +4778,7 @@ il4965_dump_nic_error_log(struct il_priv *il)
4780 else 4778 else
4781 base = le32_to_cpu(il->card_alive.error_event_table_ptr); 4779 base = le32_to_cpu(il->card_alive.error_event_table_ptr);
4782 4780
4783 if (!il->cfg->ops->lib->is_valid_rtc_data_addr(base)) { 4781 if (!il->ops->lib->is_valid_rtc_data_addr(base)) {
4784 IL_ERR("Not valid error log pointer 0x%08X for %s uCode\n", 4782 IL_ERR("Not valid error log pointer 0x%08X for %s uCode\n",
4785 base, (il->ucode_type == UCODE_INIT) ? "Init" : "RT"); 4783 base, (il->ucode_type == UCODE_INIT) ? "Init" : "RT");
4786 return; 4784 return;
@@ -5009,8 +5007,8 @@ il4965_alive_start(struct il_priv *il)
5009 /* Initialize our rx_config data */ 5007 /* Initialize our rx_config data */
5010 il_connection_init_rx_config(il); 5008 il_connection_init_rx_config(il);
5011 5009
5012 if (il->cfg->ops->hcmd->set_rxon_chain) 5010 if (il->ops->hcmd->set_rxon_chain)
5013 il->cfg->ops->hcmd->set_rxon_chain(il); 5011 il->ops->hcmd->set_rxon_chain(il);
5014 } 5012 }
5015 5013
5016 /* Configure bluetooth coexistence if enabled */ 5014 /* Configure bluetooth coexistence if enabled */
@@ -5282,7 +5280,7 @@ __il4965_up(struct il_priv *il)
5282 /* load bootstrap state machine, 5280 /* load bootstrap state machine,
5283 * load bootstrap program into processor's memory, 5281 * load bootstrap program into processor's memory,
5284 * prepare to load the "initialize" uCode */ 5282 * prepare to load the "initialize" uCode */
5285 ret = il->cfg->ops->lib->load_ucode(il); 5283 ret = il->ops->lib->load_ucode(il);
5286 5284
5287 if (ret) { 5285 if (ret) {
5288 IL_ERR("Unable to set up bootstrap uCode: %d\n", ret); 5286 IL_ERR("Unable to set up bootstrap uCode: %d\n", ret);
@@ -5323,7 +5321,7 @@ il4965_bg_init_alive_start(struct work_struct *data)
5323 if (test_bit(S_EXIT_PENDING, &il->status)) 5321 if (test_bit(S_EXIT_PENDING, &il->status))
5324 goto out; 5322 goto out;
5325 5323
5326 il->cfg->ops->lib->init_alive_start(il); 5324 il->ops->lib->init_alive_start(il);
5327out: 5325out:
5328 mutex_unlock(&il->mutex); 5326 mutex_unlock(&il->mutex);
5329} 5327}
@@ -5755,7 +5753,7 @@ il4965_mac_channel_switch(struct ieee80211_hw *hw,
5755 if (!il_is_associated(il)) 5753 if (!il_is_associated(il))
5756 goto out; 5754 goto out;
5757 5755
5758 if (!il->cfg->ops->lib->set_channel_switch) 5756 if (!il->ops->lib->set_channel_switch)
5759 goto out; 5757 goto out;
5760 5758
5761 ch = channel->hw_value; 5759 ch = channel->hw_value;
@@ -5807,7 +5805,7 @@ il4965_mac_channel_switch(struct ieee80211_hw *hw,
5807 */ 5805 */
5808 set_bit(S_CHANNEL_SWITCH_PENDING, &il->status); 5806 set_bit(S_CHANNEL_SWITCH_PENDING, &il->status);
5809 il->switch_channel = cpu_to_le16(ch); 5807 il->switch_channel = cpu_to_le16(ch);
5810 if (il->cfg->ops->lib->set_channel_switch(il, ch_switch)) { 5808 if (il->ops->lib->set_channel_switch(il, ch_switch)) {
5811 clear_bit(S_CHANNEL_SWITCH_PENDING, &il->status); 5809 clear_bit(S_CHANNEL_SWITCH_PENDING, &il->status);
5812 il->switch_channel = 0; 5810 il->switch_channel = 0;
5813 ieee80211_chswitch_done(il->vif, false); 5811 ieee80211_chswitch_done(il->vif, false);
@@ -5890,7 +5888,7 @@ il4965_bg_txpower_work(struct work_struct *work)
5890 /* Regardless of if we are associated, we must reconfigure the 5888 /* Regardless of if we are associated, we must reconfigure the
5891 * TX power since frames can be sent on non-radar channels while 5889 * TX power since frames can be sent on non-radar channels while
5892 * not associated */ 5890 * not associated */
5893 il->cfg->ops->lib->send_tx_power(il); 5891 il->ops->lib->send_tx_power(il);
5894 5892
5895 /* Update last_temperature to keep is_calib_needed from running 5893 /* Update last_temperature to keep is_calib_needed from running
5896 * when it isn't needed... */ 5894 * when it isn't needed... */
@@ -5996,6 +5994,28 @@ il4965_tx_queue_set_status(struct il_priv *il, struct il_tx_queue *txq,
5996 scd_retry ? "BA" : "AC", txq_id, tx_fifo_id); 5994 scd_retry ? "BA" : "AC", txq_id, tx_fifo_id);
5997} 5995}
5998 5996
5997const struct ieee80211_ops il4965_mac_ops = {
5998 .tx = il4965_mac_tx,
5999 .start = il4965_mac_start,
6000 .stop = il4965_mac_stop,
6001 .add_interface = il_mac_add_interface,
6002 .remove_interface = il_mac_remove_interface,
6003 .change_interface = il_mac_change_interface,
6004 .config = il_mac_config,
6005 .configure_filter = il4965_configure_filter,
6006 .set_key = il4965_mac_set_key,
6007 .update_tkip_key = il4965_mac_update_tkip_key,
6008 .conf_tx = il_mac_conf_tx,
6009 .reset_tsf = il_mac_reset_tsf,
6010 .bss_info_changed = il_mac_bss_info_changed,
6011 .ampdu_action = il4965_mac_ampdu_action,
6012 .hw_scan = il_mac_hw_scan,
6013 .sta_add = il4965_mac_sta_add,
6014 .sta_remove = il_mac_sta_remove,
6015 .channel_switch = il4965_mac_channel_switch,
6016 .tx_last_beacon = il_mac_tx_last_beacon,
6017};
6018
5999static int 6019static int
6000il4965_init_drv(struct il_priv *il) 6020il4965_init_drv(struct il_priv *il)
6001{ 6021{
@@ -6020,8 +6040,8 @@ il4965_init_drv(struct il_priv *il)
6020 il->force_reset.reset_duration = IL_DELAY_NEXT_FORCE_FW_RELOAD; 6040 il->force_reset.reset_duration = IL_DELAY_NEXT_FORCE_FW_RELOAD;
6021 6041
6022 /* Choose which receivers/antennas to use */ 6042 /* Choose which receivers/antennas to use */
6023 if (il->cfg->ops->hcmd->set_rxon_chain) 6043 if (il->ops->hcmd->set_rxon_chain)
6024 il->cfg->ops->hcmd->set_rxon_chain(il); 6044 il->ops->hcmd->set_rxon_chain(il);
6025 6045
6026 il_init_scan_params(il); 6046 il_init_scan_params(il);
6027 6047
@@ -6081,7 +6101,7 @@ il4965_set_hw_params(struct il_priv *il)
6081 il->cfg->sku &= ~IL_SKU_N; 6101 il->cfg->sku &= ~IL_SKU_N;
6082 6102
6083 /* Device-specific setup */ 6103 /* Device-specific setup */
6084 return il->cfg->ops->lib->set_hw_params(il); 6104 return il->ops->lib->set_hw_params(il);
6085} 6105}
6086 6106
6087static int 6107static int
@@ -6098,18 +6118,18 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
6098 * 1. Allocating HW data 6118 * 1. Allocating HW data
6099 ************************/ 6119 ************************/
6100 6120
6101 hw = il_alloc_all(cfg); 6121 hw = ieee80211_alloc_hw(sizeof(struct il_priv), &il4965_mac_ops);
6102 if (!hw) { 6122 if (!hw) {
6103 err = -ENOMEM; 6123 err = -ENOMEM;
6104 goto out; 6124 goto out;
6105 } 6125 }
6106 il = hw->priv; 6126 il = hw->priv;
6107 /* At this point both hw and il are allocated. */ 6127 il->hw = hw;
6108
6109 SET_IEEE80211_DEV(hw, &pdev->dev); 6128 SET_IEEE80211_DEV(hw, &pdev->dev);
6110 6129
6111 D_INFO("*** LOAD DRIVER ***\n"); 6130 D_INFO("*** LOAD DRIVER ***\n");
6112 il->cfg = cfg; 6131 il->cfg = cfg;
6132 il->ops = &il4965_ops;
6113 il->pci_dev = pdev; 6133 il->pci_dev = pdev;
6114 il->inta_mask = CSR_INI_SET_MASK; 6134 il->inta_mask = CSR_INI_SET_MASK;
6115 6135
diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c
index 9d9197f7fa38..27feb533d025 100644
--- a/drivers/net/wireless/iwlegacy/4965.c
+++ b/drivers/net/wireless/iwlegacy/4965.c
@@ -2166,8 +2166,8 @@ il4965_post_associate(struct il_priv *il)
2166 2166
2167 il_set_rxon_ht(il, &il->current_ht_config); 2167 il_set_rxon_ht(il, &il->current_ht_config);
2168 2168
2169 if (il->cfg->ops->hcmd->set_rxon_chain) 2169 if (il->ops->hcmd->set_rxon_chain)
2170 il->cfg->ops->hcmd->set_rxon_chain(il); 2170 il->ops->hcmd->set_rxon_chain(il);
2171 2171
2172 il->staging.assoc_id = cpu_to_le16(vif->bss_conf.aid); 2172 il->staging.assoc_id = cpu_to_le16(vif->bss_conf.aid);
2173 2173
@@ -2241,8 +2241,8 @@ il4965_config_ap(struct il_priv *il)
2241 /* AP has all antennas */ 2241 /* AP has all antennas */
2242 il->chain_noise_data.active_chains = il->hw_params.valid_rx_ant; 2242 il->chain_noise_data.active_chains = il->hw_params.valid_rx_ant;
2243 il_set_rxon_ht(il, &il->current_ht_config); 2243 il_set_rxon_ht(il, &il->current_ht_config);
2244 if (il->cfg->ops->hcmd->set_rxon_chain) 2244 if (il->ops->hcmd->set_rxon_chain)
2245 il->cfg->ops->hcmd->set_rxon_chain(il); 2245 il->ops->hcmd->set_rxon_chain(il);
2246 2246
2247 il->staging.assoc_id = 0; 2247 il->staging.assoc_id = 0;
2248 2248
@@ -2323,35 +2323,12 @@ static const struct il_legacy_ops il4965_legacy_ops = {
2323 .update_bcast_stations = il4965_update_bcast_stations, 2323 .update_bcast_stations = il4965_update_bcast_stations,
2324}; 2324};
2325 2325
2326struct ieee80211_ops il4965_hw_ops = { 2326const struct il_ops il4965_ops = {
2327 .tx = il4965_mac_tx,
2328 .start = il4965_mac_start,
2329 .stop = il4965_mac_stop,
2330 .add_interface = il_mac_add_interface,
2331 .remove_interface = il_mac_remove_interface,
2332 .change_interface = il_mac_change_interface,
2333 .config = il_mac_config,
2334 .configure_filter = il4965_configure_filter,
2335 .set_key = il4965_mac_set_key,
2336 .update_tkip_key = il4965_mac_update_tkip_key,
2337 .conf_tx = il_mac_conf_tx,
2338 .reset_tsf = il_mac_reset_tsf,
2339 .bss_info_changed = il_mac_bss_info_changed,
2340 .ampdu_action = il4965_mac_ampdu_action,
2341 .hw_scan = il_mac_hw_scan,
2342 .sta_add = il4965_mac_sta_add,
2343 .sta_remove = il_mac_sta_remove,
2344 .channel_switch = il4965_mac_channel_switch,
2345 .tx_last_beacon = il_mac_tx_last_beacon,
2346};
2347
2348static const struct il_ops il4965_ops = {
2349 .lib = &il4965_lib, 2327 .lib = &il4965_lib,
2350 .hcmd = &il4965_hcmd, 2328 .hcmd = &il4965_hcmd,
2351 .utils = &il4965_hcmd_utils, 2329 .utils = &il4965_hcmd_utils,
2352 .led = &il4965_led_ops, 2330 .led = &il4965_led_ops,
2353 .legacy = &il4965_legacy_ops, 2331 .legacy = &il4965_legacy_ops,
2354 .ieee80211_ops = &il4965_hw_ops,
2355}; 2332};
2356 2333
2357static struct il_base_params il4965_base_params = { 2334static struct il_base_params il4965_base_params = {
@@ -2380,7 +2357,6 @@ struct il_cfg il4965_cfg = {
2380 .valid_rx_ant = ANT_ABC, 2357 .valid_rx_ant = ANT_ABC,
2381 .eeprom_ver = EEPROM_4965_EEPROM_VERSION, 2358 .eeprom_ver = EEPROM_4965_EEPROM_VERSION,
2382 .eeprom_calib_ver = EEPROM_4965_TX_POWER_VERSION, 2359 .eeprom_calib_ver = EEPROM_4965_TX_POWER_VERSION,
2383 .ops = &il4965_ops,
2384 .mod_params = &il4965_mod_params, 2360 .mod_params = &il4965_mod_params,
2385 .base_params = &il4965_base_params, 2361 .base_params = &il4965_base_params,
2386 .led_mode = IL_LED_BLINK, 2362 .led_mode = IL_LED_BLINK,
diff --git a/drivers/net/wireless/iwlegacy/4965.h b/drivers/net/wireless/iwlegacy/4965.h
index 67899602ee52..83ab60496388 100644
--- a/drivers/net/wireless/iwlegacy/4965.h
+++ b/drivers/net/wireless/iwlegacy/4965.h
@@ -38,11 +38,10 @@ struct il_rxon_context;
38 38
39/* configuration for the _4965 devices */ 39/* configuration for the _4965 devices */
40extern struct il_cfg il4965_cfg; 40extern struct il_cfg il4965_cfg;
41extern const struct il_ops il4965_ops;
41 42
42extern struct il_mod_params il4965_mod_params; 43extern struct il_mod_params il4965_mod_params;
43 44
44extern struct ieee80211_ops il4965_hw_ops;
45
46/* tx queue */ 45/* tx queue */
47void il4965_free_tfds_in_queue(struct il_priv *il, int sta_id, int tid, 46void il4965_free_tfds_in_queue(struct il_priv *il, int sta_id, int tid,
48 int freed); 47 int freed);
diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c
index bee11a3aeac0..3bd183336563 100644
--- a/drivers/net/wireless/iwlegacy/common.c
+++ b/drivers/net/wireless/iwlegacy/common.c
@@ -520,7 +520,7 @@ il_led_cmd(struct il_priv *il, unsigned long on, unsigned long off)
520 il_blink_compensation(il, off, 520 il_blink_compensation(il, off,
521 il->cfg->base_params->led_compensation); 521 il->cfg->base_params->led_compensation);
522 522
523 ret = il->cfg->ops->led->cmd(il, &led_cmd); 523 ret = il->ops->led->cmd(il, &led_cmd);
524 if (!ret) { 524 if (!ret) {
525 il->blink_on = on; 525 il->blink_on = on;
526 il->blink_off = off; 526 il->blink_off = off;
@@ -731,7 +731,7 @@ il_eeprom_init(struct il_priv *il)
731 } 731 }
732 e = (__le16 *) il->eeprom; 732 e = (__le16 *) il->eeprom;
733 733
734 il->cfg->ops->lib->apm_ops.init(il); 734 il->ops->lib->apm_ops.init(il);
735 735
736 ret = il_eeprom_verify_signature(il); 736 ret = il_eeprom_verify_signature(il);
737 if (ret < 0) { 737 if (ret < 0) {
@@ -741,7 +741,7 @@ il_eeprom_init(struct il_priv *il)
741 } 741 }
742 742
743 /* Make sure driver (instead of uCode) is allowed to read EEPROM */ 743 /* Make sure driver (instead of uCode) is allowed to read EEPROM */
744 ret = il->cfg->ops->lib->eeprom_ops.acquire_semaphore(il); 744 ret = il->ops->lib->eeprom_ops.acquire_semaphore(il);
745 if (ret < 0) { 745 if (ret < 0) {
746 IL_ERR("Failed to acquire EEPROM semaphore.\n"); 746 IL_ERR("Failed to acquire EEPROM semaphore.\n");
747 ret = -ENOENT; 747 ret = -ENOENT;
@@ -773,7 +773,7 @@ il_eeprom_init(struct il_priv *il)
773 773
774 ret = 0; 774 ret = 0;
775done: 775done:
776 il->cfg->ops->lib->eeprom_ops.release_semaphore(il); 776 il->ops->lib->eeprom_ops.release_semaphore(il);
777 777
778err: 778err:
779 if (ret) 779 if (ret)
@@ -800,7 +800,7 @@ il_init_band_reference(const struct il_priv *il, int eep_band,
800 const u8 **eeprom_ch_idx) 800 const u8 **eeprom_ch_idx)
801{ 801{
802 u32 offset = 802 u32 offset =
803 il->cfg->ops->lib->eeprom_ops.regulatory_bands[eep_band - 1]; 803 il->ops->lib->eeprom_ops.regulatory_bands[eep_band - 1];
804 switch (eep_band) { 804 switch (eep_band) {
805 case 1: /* 2.4GHz band */ 805 case 1: /* 2.4GHz band */
806 *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_1); 806 *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_1);
@@ -1001,9 +1001,9 @@ il_init_channel_map(struct il_priv *il)
1001 } 1001 }
1002 1002
1003 /* Check if we do have HT40 channels */ 1003 /* Check if we do have HT40 channels */
1004 if (il->cfg->ops->lib->eeprom_ops.regulatory_bands[5] == 1004 if (il->ops->lib->eeprom_ops.regulatory_bands[5] ==
1005 EEPROM_REGULATORY_BAND_NO_HT40 && 1005 EEPROM_REGULATORY_BAND_NO_HT40 &&
1006 il->cfg->ops->lib->eeprom_ops.regulatory_bands[6] == 1006 il->ops->lib->eeprom_ops.regulatory_bands[6] ==
1007 EEPROM_REGULATORY_BAND_NO_HT40) 1007 EEPROM_REGULATORY_BAND_NO_HT40)
1008 return 0; 1008 return 0;
1009 1009
@@ -1158,9 +1158,9 @@ il_power_set_mode(struct il_priv *il, struct il_powertable_cmd *cmd, bool force)
1158 if (!(cmd->flags & IL_POWER_DRIVER_ALLOW_SLEEP_MSK)) 1158 if (!(cmd->flags & IL_POWER_DRIVER_ALLOW_SLEEP_MSK))
1159 clear_bit(S_POWER_PMI, &il->status); 1159 clear_bit(S_POWER_PMI, &il->status);
1160 1160
1161 if (il->cfg->ops->lib->update_chain_flags && update_chains) 1161 if (il->ops->lib->update_chain_flags && update_chains)
1162 il->cfg->ops->lib->update_chain_flags(il); 1162 il->ops->lib->update_chain_flags(il);
1163 else if (il->cfg->ops->lib->update_chain_flags) 1163 else if (il->ops->lib->update_chain_flags)
1164 D_POWER("Cannot update the power, chain noise " 1164 D_POWER("Cannot update the power, chain noise "
1165 "calibration running: %d\n", 1165 "calibration running: %d\n",
1166 il->chain_noise_data.state); 1166 il->chain_noise_data.state);
@@ -1485,7 +1485,7 @@ il_scan_initiate(struct il_priv *il, struct ieee80211_vif *vif)
1485 1485
1486 lockdep_assert_held(&il->mutex); 1486 lockdep_assert_held(&il->mutex);
1487 1487
1488 if (WARN_ON(!il->cfg->ops->utils->request_scan)) 1488 if (WARN_ON(!il->ops->utils->request_scan))
1489 return -EOPNOTSUPP; 1489 return -EOPNOTSUPP;
1490 1490
1491 cancel_delayed_work(&il->scan_check); 1491 cancel_delayed_work(&il->scan_check);
@@ -1510,7 +1510,7 @@ il_scan_initiate(struct il_priv *il, struct ieee80211_vif *vif)
1510 set_bit(S_SCANNING, &il->status); 1510 set_bit(S_SCANNING, &il->status);
1511 il->scan_start = jiffies; 1511 il->scan_start = jiffies;
1512 1512
1513 ret = il->cfg->ops->utils->request_scan(il, vif); 1513 ret = il->ops->utils->request_scan(il, vif);
1514 if (ret) { 1514 if (ret) {
1515 clear_bit(S_SCANNING, &il->status); 1515 clear_bit(S_SCANNING, &il->status);
1516 return ret; 1516 return ret;
@@ -1672,7 +1672,7 @@ out_settings:
1672 il_power_set_mode(il, &il->power_data.sleep_cmd_next, false); 1672 il_power_set_mode(il, &il->power_data.sleep_cmd_next, false);
1673 il_set_tx_power(il, il->tx_power_next, false); 1673 il_set_tx_power(il, il->tx_power_next, false);
1674 1674
1675 il->cfg->ops->utils->post_scan(il); 1675 il->ops->utils->post_scan(il);
1676 1676
1677out: 1677out:
1678 mutex_unlock(&il->mutex); 1678 mutex_unlock(&il->mutex);
@@ -1814,7 +1814,7 @@ il_send_add_sta(struct il_priv *il, struct il_addsta_cmd *sta, u8 flags)
1814 might_sleep(); 1814 might_sleep();
1815 } 1815 }
1816 1816
1817 cmd.len = il->cfg->ops->utils->build_addsta_hcmd(sta, data); 1817 cmd.len = il->ops->utils->build_addsta_hcmd(sta, data);
1818 ret = il_send_cmd(il, &cmd); 1818 ret = il_send_cmd(il, &cmd);
1819 1819
1820 if (ret || (flags & CMD_ASYNC)) 1820 if (ret || (flags & CMD_ASYNC))
@@ -2722,7 +2722,7 @@ il_tx_queue_unmap(struct il_priv *il, int txq_id)
2722 return; 2722 return;
2723 2723
2724 while (q->write_ptr != q->read_ptr) { 2724 while (q->write_ptr != q->read_ptr) {
2725 il->cfg->ops->lib->txq_free_tfd(il, txq); 2725 il->ops->lib->txq_free_tfd(il, txq);
2726 q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd); 2726 q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd);
2727 } 2727 }
2728} 2728}
@@ -3024,7 +3024,7 @@ il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, int slots_num,
3024 il_queue_init(il, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id); 3024 il_queue_init(il, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id);
3025 3025
3026 /* Tell device where to find queue */ 3026 /* Tell device where to find queue */
3027 il->cfg->ops->lib->txq_init(il, txq); 3027 il->ops->lib->txq_init(il, txq);
3028 3028
3029 return 0; 3029 return 0;
3030err: 3030err:
@@ -3055,7 +3055,7 @@ il_tx_queue_reset(struct il_priv *il, struct il_tx_queue *txq, int slots_num,
3055 il_queue_init(il, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id); 3055 il_queue_init(il, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id);
3056 3056
3057 /* Tell device where to find queue */ 3057 /* Tell device where to find queue */
3058 il->cfg->ops->lib->txq_init(il, txq); 3058 il->ops->lib->txq_init(il, txq);
3059} 3059}
3060EXPORT_SYMBOL(il_tx_queue_reset); 3060EXPORT_SYMBOL(il_tx_queue_reset);
3061 3061
@@ -3083,7 +3083,7 @@ il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd)
3083 u32 idx; 3083 u32 idx;
3084 u16 fix_size; 3084 u16 fix_size;
3085 3085
3086 cmd->len = il->cfg->ops->utils->get_hcmd_size(cmd->id, cmd->len); 3086 cmd->len = il->ops->utils->get_hcmd_size(cmd->id, cmd->len);
3087 fix_size = (u16) (cmd->len + sizeof(out_cmd->hdr)); 3087 fix_size = (u16) (cmd->len + sizeof(out_cmd->hdr));
3088 3088
3089 /* If any of the command structures end up being larger than 3089 /* If any of the command structures end up being larger than
@@ -3162,9 +3162,9 @@ il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd)
3162#endif 3162#endif
3163 txq->need_update = 1; 3163 txq->need_update = 1;
3164 3164
3165 if (il->cfg->ops->lib->txq_update_byte_cnt_tbl) 3165 if (il->ops->lib->txq_update_byte_cnt_tbl)
3166 /* Set up entry in queue's byte count circular buffer */ 3166 /* Set up entry in queue's byte count circular buffer */
3167 il->cfg->ops->lib->txq_update_byte_cnt_tbl(il, txq, 0); 3167 il->ops->lib->txq_update_byte_cnt_tbl(il, txq, 0);
3168 3168
3169 phys_addr = 3169 phys_addr =
3170 pci_map_single(il->pci_dev, &out_cmd->hdr, fix_size, 3170 pci_map_single(il->pci_dev, &out_cmd->hdr, fix_size,
@@ -3172,8 +3172,8 @@ il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd)
3172 dma_unmap_addr_set(out_meta, mapping, phys_addr); 3172 dma_unmap_addr_set(out_meta, mapping, phys_addr);
3173 dma_unmap_len_set(out_meta, len, fix_size); 3173 dma_unmap_len_set(out_meta, len, fix_size);
3174 3174
3175 il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, phys_addr, fix_size, 3175 il->ops->lib->txq_attach_buf_to_tfd(il, txq, phys_addr, fix_size, 1,
3176 1, U32_PAD(cmd->len)); 3176 U32_PAD(cmd->len));
3177 3177
3178 /* Increment and update queue's write idx */ 3178 /* Increment and update queue's write idx */
3179 q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd); 3179 q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd);
@@ -3315,30 +3315,6 @@ EXPORT_SYMBOL(il_debug_level);
3315const u8 il_bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; 3315const u8 il_bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3316EXPORT_SYMBOL(il_bcast_addr); 3316EXPORT_SYMBOL(il_bcast_addr);
3317 3317
3318/* This function both allocates and initializes hw and il. */
3319struct ieee80211_hw *
3320il_alloc_all(struct il_cfg *cfg)
3321{
3322 struct il_priv *il;
3323 /* mac80211 allocates memory for this device instance, including
3324 * space for this driver's ilate structure */
3325 struct ieee80211_hw *hw;
3326
3327 hw = ieee80211_alloc_hw(sizeof(struct il_priv),
3328 cfg->ops->ieee80211_ops);
3329 if (hw == NULL) {
3330 pr_err("%s: Can not allocate network device\n", cfg->name);
3331 goto out;
3332 }
3333
3334 il = hw->priv;
3335 il->hw = hw;
3336
3337out:
3338 return hw;
3339}
3340EXPORT_SYMBOL(il_alloc_all);
3341
3342#define MAX_BIT_RATE_40_MHZ 150 /* Mbps */ 3318#define MAX_BIT_RATE_40_MHZ 150 /* Mbps */
3343#define MAX_BIT_RATE_20_MHZ 72 /* Mbps */ 3319#define MAX_BIT_RATE_20_MHZ 72 /* Mbps */
3344static void 3320static void
@@ -3871,8 +3847,8 @@ _il_set_rxon_ht(struct il_priv *il, struct il_ht_config *ht_conf)
3871 rxon->flags |= RXON_FLG_CHANNEL_MODE_LEGACY; 3847 rxon->flags |= RXON_FLG_CHANNEL_MODE_LEGACY;
3872 } 3848 }
3873 3849
3874 if (il->cfg->ops->hcmd->set_rxon_chain) 3850 if (il->ops->hcmd->set_rxon_chain)
3875 il->cfg->ops->hcmd->set_rxon_chain(il); 3851 il->ops->hcmd->set_rxon_chain(il);
3876 3852
3877 D_ASSOC("rxon flags 0x%X operation mode :0x%X " 3853 D_ASSOC("rxon flags 0x%X operation mode :0x%X "
3878 "extension channel offset 0x%x\n", le32_to_cpu(rxon->flags), 3854 "extension channel offset 0x%x\n", le32_to_cpu(rxon->flags),
@@ -4130,9 +4106,9 @@ il_irq_handle_error(struct il_priv *il)
4130 4106
4131 IL_ERR("Loaded firmware version: %s\n", il->hw->wiphy->fw_version); 4107 IL_ERR("Loaded firmware version: %s\n", il->hw->wiphy->fw_version);
4132 4108
4133 il->cfg->ops->lib->dump_nic_error_log(il); 4109 il->ops->lib->dump_nic_error_log(il);
4134 if (il->cfg->ops->lib->dump_fh) 4110 if (il->ops->lib->dump_fh)
4135 il->cfg->ops->lib->dump_fh(il, NULL, false); 4111 il->ops->lib->dump_fh(il, NULL, false);
4136#ifdef CONFIG_IWLEGACY_DEBUG 4112#ifdef CONFIG_IWLEGACY_DEBUG
4137 if (il_get_debug_level(il) & IL_DL_FW_ERRORS) 4113 if (il_get_debug_level(il) & IL_DL_FW_ERRORS)
4138 il_print_rx_config_cmd(il); 4114 il_print_rx_config_cmd(il);
@@ -4319,7 +4295,7 @@ il_set_tx_power(struct il_priv *il, s8 tx_power, bool force)
4319 if (il->tx_power_user_lmt == tx_power && !force) 4295 if (il->tx_power_user_lmt == tx_power && !force)
4320 return 0; 4296 return 0;
4321 4297
4322 if (!il->cfg->ops->lib->send_tx_power) 4298 if (!il->ops->lib->send_tx_power)
4323 return -EOPNOTSUPP; 4299 return -EOPNOTSUPP;
4324 4300
4325 /* 0 dBm mean 1 milliwatt */ 4301 /* 0 dBm mean 1 milliwatt */
@@ -4352,7 +4328,7 @@ il_set_tx_power(struct il_priv *il, s8 tx_power, bool force)
4352 prev_tx_power = il->tx_power_user_lmt; 4328 prev_tx_power = il->tx_power_user_lmt;
4353 il->tx_power_user_lmt = tx_power; 4329 il->tx_power_user_lmt = tx_power;
4354 4330
4355 ret = il->cfg->ops->lib->send_tx_power(il); 4331 ret = il->ops->lib->send_tx_power(il);
4356 4332
4357 /* if fail to set tx_power, restore the orig. tx power */ 4333 /* if fail to set tx_power, restore the orig. tx power */
4358 if (ret) { 4334 if (ret) {
@@ -4501,8 +4477,8 @@ il_set_mode(struct il_priv *il)
4501{ 4477{
4502 il_connection_init_rx_config(il); 4478 il_connection_init_rx_config(il);
4503 4479
4504 if (il->cfg->ops->hcmd->set_rxon_chain) 4480 if (il->ops->hcmd->set_rxon_chain)
4505 il->cfg->ops->hcmd->set_rxon_chain(il); 4481 il->ops->hcmd->set_rxon_chain(il);
4506 4482
4507 return il_commit_rxon(il); 4483 return il_commit_rxon(il);
4508} 4484}
@@ -5200,7 +5176,7 @@ il_mac_config(struct ieee80211_hw *hw, u32 changed)
5200 int scan_active = 0; 5176 int scan_active = 0;
5201 bool ht_changed = false; 5177 bool ht_changed = false;
5202 5178
5203 if (WARN_ON(!il->cfg->ops->legacy)) 5179 if (WARN_ON(!il->ops->legacy))
5204 return -EOPNOTSUPP; 5180 return -EOPNOTSUPP;
5205 5181
5206 mutex_lock(&il->mutex); 5182 mutex_lock(&il->mutex);
@@ -5225,8 +5201,8 @@ il_mac_config(struct ieee80211_hw *hw, u32 changed)
5225 * set up the SM PS mode to OFF if an HT channel is 5201 * set up the SM PS mode to OFF if an HT channel is
5226 * configured. 5202 * configured.
5227 */ 5203 */
5228 if (il->cfg->ops->hcmd->set_rxon_chain) 5204 if (il->ops->hcmd->set_rxon_chain)
5229 il->cfg->ops->hcmd->set_rxon_chain(il); 5205 il->ops->hcmd->set_rxon_chain(il);
5230 } 5206 }
5231 5207
5232 /* during scanning mac80211 will delay channel setting until 5208 /* during scanning mac80211 will delay channel setting until
@@ -5295,8 +5271,8 @@ il_mac_config(struct ieee80211_hw *hw, u32 changed)
5295 5271
5296 spin_unlock_irqrestore(&il->lock, flags); 5272 spin_unlock_irqrestore(&il->lock, flags);
5297 5273
5298 if (il->cfg->ops->legacy->update_bcast_stations) 5274 if (il->ops->legacy->update_bcast_stations)
5299 ret = il->cfg->ops->legacy->update_bcast_stations(il); 5275 ret = il->ops->legacy->update_bcast_stations(il);
5300 5276
5301set_ch_out: 5277set_ch_out:
5302 /* The list of supported rates and rate mask can be different 5278 /* The list of supported rates and rate mask can be different
@@ -5346,7 +5322,7 @@ il_mac_reset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
5346 struct il_priv *il = hw->priv; 5322 struct il_priv *il = hw->priv;
5347 unsigned long flags; 5323 unsigned long flags;
5348 5324
5349 if (WARN_ON(!il->cfg->ops->legacy)) 5325 if (WARN_ON(!il->ops->legacy))
5350 return; 5326 return;
5351 5327
5352 mutex_lock(&il->mutex); 5328 mutex_lock(&il->mutex);
@@ -5501,7 +5477,7 @@ il_beacon_update(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
5501 return; 5477 return;
5502 } 5478 }
5503 5479
5504 il->cfg->ops->legacy->post_associate(il); 5480 il->ops->legacy->post_associate(il);
5505} 5481}
5506 5482
5507void 5483void
@@ -5511,7 +5487,7 @@ il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
5511 struct il_priv *il = hw->priv; 5487 struct il_priv *il = hw->priv;
5512 int ret; 5488 int ret;
5513 5489
5514 if (WARN_ON(!il->cfg->ops->legacy)) 5490 if (WARN_ON(!il->ops->legacy))
5515 return; 5491 return;
5516 5492
5517 D_MAC80211("changes = 0x%X\n", changes); 5493 D_MAC80211("changes = 0x%X\n", changes);
@@ -5616,8 +5592,8 @@ il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
5616 if (changes & BSS_CHANGED_HT) { 5592 if (changes & BSS_CHANGED_HT) {
5617 il_ht_conf(il, vif); 5593 il_ht_conf(il, vif);
5618 5594
5619 if (il->cfg->ops->hcmd->set_rxon_chain) 5595 if (il->ops->hcmd->set_rxon_chain)
5620 il->cfg->ops->hcmd->set_rxon_chain(il); 5596 il->ops->hcmd->set_rxon_chain(il);
5621 } 5597 }
5622 5598
5623 if (changes & BSS_CHANGED_ASSOC) { 5599 if (changes & BSS_CHANGED_ASSOC) {
@@ -5626,7 +5602,7 @@ il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
5626 il->timestamp = bss_conf->timestamp; 5602 il->timestamp = bss_conf->timestamp;
5627 5603
5628 if (!il_is_rfkill(il)) 5604 if (!il_is_rfkill(il))
5629 il->cfg->ops->legacy->post_associate(il); 5605 il->ops->legacy->post_associate(il);
5630 } else 5606 } else
5631 il_set_no_assoc(il, vif); 5607 il_set_no_assoc(il, vif);
5632 } 5608 }
@@ -5646,16 +5622,15 @@ il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
5646 memcpy(il->staging.bssid_addr, bss_conf->bssid, 5622 memcpy(il->staging.bssid_addr, bss_conf->bssid,
5647 ETH_ALEN); 5623 ETH_ALEN);
5648 memcpy(il->bssid, bss_conf->bssid, ETH_ALEN); 5624 memcpy(il->bssid, bss_conf->bssid, ETH_ALEN);
5649 il->cfg->ops->legacy->config_ap(il); 5625 il->ops->legacy->config_ap(il);
5650 } else 5626 } else
5651 il_set_no_assoc(il, vif); 5627 il_set_no_assoc(il, vif);
5652 } 5628 }
5653 5629
5654 if (changes & BSS_CHANGED_IBSS) { 5630 if (changes & BSS_CHANGED_IBSS) {
5655 ret = 5631 ret =
5656 il->cfg->ops->legacy->manage_ibss_station(il, vif, 5632 il->ops->legacy->manage_ibss_station(il, vif,
5657 bss_conf-> 5633 bss_conf->ibss_joined);
5658 ibss_joined);
5659 if (ret) 5634 if (ret)
5660 IL_ERR("failed to %s IBSS station %pM\n", 5635 IL_ERR("failed to %s IBSS station %pM\n",
5661 bss_conf->ibss_joined ? "add" : "remove", 5636 bss_conf->ibss_joined ? "add" : "remove",
diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h
index 746eec08886d..2af861062de0 100644
--- a/drivers/net/wireless/iwlegacy/common.h
+++ b/drivers/net/wireless/iwlegacy/common.h
@@ -1167,6 +1167,7 @@ struct il_priv {
1167 struct ieee80211_channel *ieee_channels; 1167 struct ieee80211_channel *ieee_channels;
1168 struct ieee80211_rate *ieee_rates; 1168 struct ieee80211_rate *ieee_rates;
1169 struct il_cfg *cfg; 1169 struct il_cfg *cfg;
1170 const struct il_ops *ops;
1170 1171
1171 /* temporary frame storage list */ 1172 /* temporary frame storage list */
1172 struct list_head free_frames; 1173 struct list_head free_frames;
@@ -1668,7 +1669,6 @@ struct il_ops {
1668 const struct il_led_ops *led; 1669 const struct il_led_ops *led;
1669 const struct il_nic_ops *nic; 1670 const struct il_nic_ops *nic;
1670 const struct il_legacy_ops *legacy; 1671 const struct il_legacy_ops *legacy;
1671 const struct ieee80211_ops *ieee80211_ops;
1672}; 1672};
1673 1673
1674struct il_mod_params { 1674struct il_mod_params {
@@ -1777,7 +1777,6 @@ struct il_cfg {
1777 unsigned int sku; 1777 unsigned int sku;
1778 u16 eeprom_ver; 1778 u16 eeprom_ver;
1779 u16 eeprom_calib_ver; 1779 u16 eeprom_calib_ver;
1780 const struct il_ops *ops;
1781 /* module based parameters which can be set from modprobe cmd */ 1780 /* module based parameters which can be set from modprobe cmd */
1782 const struct il_mod_params *mod_params; 1781 const struct il_mod_params *mod_params;
1783 /* params not likely to change within a device family */ 1782 /* params not likely to change within a device family */
@@ -1791,7 +1790,6 @@ struct il_cfg {
1791 * L i b * 1790 * L i b *
1792 ***************************/ 1791 ***************************/
1793 1792
1794struct ieee80211_hw *il_alloc_all(struct il_cfg *cfg);
1795int il_mac_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 1793int il_mac_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1796 u16 queue, const struct ieee80211_tx_queue_params *params); 1794 u16 queue, const struct ieee80211_tx_queue_params *params);
1797int il_mac_tx_last_beacon(struct ieee80211_hw *hw); 1795int il_mac_tx_last_beacon(struct ieee80211_hw *hw);
@@ -2093,13 +2091,13 @@ int il_send_rxon_timing(struct il_priv *il);
2093static inline int 2091static inline int
2094il_send_rxon_assoc(struct il_priv *il) 2092il_send_rxon_assoc(struct il_priv *il)
2095{ 2093{
2096 return il->cfg->ops->hcmd->rxon_assoc(il); 2094 return il->ops->hcmd->rxon_assoc(il);
2097} 2095}
2098 2096
2099static inline int 2097static inline int
2100il_commit_rxon(struct il_priv *il) 2098il_commit_rxon(struct il_priv *il)
2101{ 2099{
2102 return il->cfg->ops->hcmd->commit_rxon(il); 2100 return il->ops->hcmd->commit_rxon(il);
2103} 2101}
2104 2102
2105static inline const struct ieee80211_supported_band * 2103static inline const struct ieee80211_supported_band *
diff --git a/drivers/net/wireless/iwlegacy/debug.c b/drivers/net/wireless/iwlegacy/debug.c
index 3a9609a88748..4fb769caef5a 100644
--- a/drivers/net/wireless/iwlegacy/debug.c
+++ b/drivers/net/wireless/iwlegacy/debug.c
@@ -901,8 +901,7 @@ il_dbgfs_ucode_rx_stats_read(struct file *file, char __user *user_buf,
901 size_t count, loff_t *ppos) 901 size_t count, loff_t *ppos)
902{ 902{
903 struct il_priv *il = file->private_data; 903 struct il_priv *il = file->private_data;
904 return il->cfg->ops->lib->debugfs_ops.rx_stats_read(file, user_buf, 904 return il->ops->lib->debugfs_ops.rx_stats_read(file, user_buf, count, ppos);
905 count, ppos);
906} 905}
907 906
908static ssize_t 907static ssize_t
@@ -910,8 +909,7 @@ il_dbgfs_ucode_tx_stats_read(struct file *file, char __user *user_buf,
910 size_t count, loff_t *ppos) 909 size_t count, loff_t *ppos)
911{ 910{
912 struct il_priv *il = file->private_data; 911 struct il_priv *il = file->private_data;
913 return il->cfg->ops->lib->debugfs_ops.tx_stats_read(file, user_buf, 912 return il->ops->lib->debugfs_ops.tx_stats_read(file, user_buf, count, ppos);
914 count, ppos);
915} 913}
916 914
917static ssize_t 915static ssize_t
@@ -919,8 +917,7 @@ il_dbgfs_ucode_general_stats_read(struct file *file, char __user *user_buf,
919 size_t count, loff_t *ppos) 917 size_t count, loff_t *ppos)
920{ 918{
921 struct il_priv *il = file->private_data; 919 struct il_priv *il = file->private_data;
922 return il->cfg->ops->lib->debugfs_ops.general_stats_read(file, user_buf, 920 return il->ops->lib->debugfs_ops.general_stats_read(file, user_buf, count, ppos);
923 count, ppos);
924} 921}
925 922
926static ssize_t 923static ssize_t
@@ -1178,8 +1175,8 @@ il_dbgfs_fh_reg_read(struct file *file, char __user *user_buf, size_t count,
1178 int pos = 0; 1175 int pos = 0;
1179 ssize_t ret = -EFAULT; 1176 ssize_t ret = -EFAULT;
1180 1177
1181 if (il->cfg->ops->lib->dump_fh) { 1178 if (il->ops->lib->dump_fh) {
1182 ret = pos = il->cfg->ops->lib->dump_fh(il, &buf, true); 1179 ret = pos = il->ops->lib->dump_fh(il, &buf, true);
1183 if (buf) { 1180 if (buf) {
1184 ret = 1181 ret =
1185 simple_read_from_buffer(user_buf, count, ppos, buf, 1182 simple_read_from_buffer(user_buf, count, ppos, buf,