Skip to content

Commit

Permalink
iwlegacy: merge all ops structures into one
Browse files Browse the repository at this point in the history
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Stanislaw Gruszka authored and John W. Linville committed Feb 22, 2012
1 parent 1600b87 commit c936355
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 131 deletions.
39 changes: 13 additions & 26 deletions drivers/net/wireless/iwlegacy/3945.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ il3945_send_led_cmd(struct il_priv *il, struct il_led_cmd *led_cmd)
return il_send_cmd(il, &cmd);
}

const struct il_led_ops il3945_led_ops = {
.cmd = il3945_send_led_cmd,
};

#define IL_DECLARE_RATE_INFO(r, ip, in, rp, rn, pp, np) \
[RATE_##r##M_IDX] = { RATE_##r##M_PLCP, \
RATE_##r##M_IEEE, \
Expand Down Expand Up @@ -2629,24 +2625,6 @@ il3945_load_bsm(struct il_priv *il)
return 0;
}

static struct il_hcmd_ops il3945_hcmd = {
.rxon_assoc = il3945_send_rxon_assoc,
.commit_rxon = il3945_commit_rxon,
};

static const struct il_legacy_ops il3945_legacy_ops = {
.post_associate = il3945_post_associate,
.config_ap = il3945_config_ap,
.manage_ibss_station = il3945_manage_ibss_station,
};

static struct il_hcmd_utils_ops il3945_hcmd_utils = {
.get_hcmd_size = il3945_get_hcmd_size,
.build_addsta_hcmd = il3945_build_addsta_hcmd,
.request_scan = il3945_request_scan,
.post_scan = il3945_post_scan,
};

const struct il_ops il3945_ops = {
.txq_attach_buf_to_tfd = il3945_hw_txq_attach_buf_to_tfd,
.txq_free_tfd = il3945_hw_txq_free_tfd,
Expand All @@ -2659,10 +2637,19 @@ const struct il_ops il3945_ops = {
.eeprom_acquire_semaphore = il3945_eeprom_acquire_semaphore,
.eeprom_release_semaphore = il3945_eeprom_release_semaphore,

.hcmd = &il3945_hcmd,
.utils = &il3945_hcmd_utils,
.led = &il3945_led_ops,
.legacy = &il3945_legacy_ops,
.rxon_assoc = il3945_send_rxon_assoc,
.commit_rxon = il3945_commit_rxon,

.get_hcmd_size = il3945_get_hcmd_size,
.build_addsta_hcmd = il3945_build_addsta_hcmd,
.request_scan = il3945_request_scan,
.post_scan = il3945_post_scan,

.post_associate = il3945_post_associate,
.config_ap = il3945_config_ap,
.manage_ibss_station = il3945_manage_ibss_station,

.send_led_cmd = il3945_send_led_cmd,
};

static struct il_cfg il3945_bg_cfg = {
Expand Down
17 changes: 8 additions & 9 deletions drivers/net/wireless/iwlegacy/4965-mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -3649,8 +3649,8 @@ il4965_sta_modify_sleep_tx_count(struct il_priv *il, int sta_id, int cnt)
void
il4965_update_chain_flags(struct il_priv *il)
{
if (il->ops->hcmd->set_rxon_chain) {
il->ops->hcmd->set_rxon_chain(il);
if (il->ops->set_rxon_chain) {
il->ops->set_rxon_chain(il);
if (il->active.rx_chain != il->staging.rx_chain)
il_commit_rxon(il);
}
Expand Down Expand Up @@ -4399,9 +4399,8 @@ il4965_irq_tasklet(struct il_priv *il)
/* HW RF KILL switch toggled */
if (inta & CSR_INT_BIT_RF_KILL) {
int hw_rf_kill = 0;
if (!
(_il_rd(il, CSR_GP_CNTRL) &
CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW))

if (!(_il_rd(il, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW))
hw_rf_kill = 1;

IL_WARN("RF_KILL bit toggled to %s.\n",
Expand Down Expand Up @@ -5300,8 +5299,8 @@ il4965_alive_start(struct il_priv *il)
/* Initialize our rx_config data */
il_connection_init_rx_config(il);

if (il->ops->hcmd->set_rxon_chain)
il->ops->hcmd->set_rxon_chain(il);
if (il->ops->set_rxon_chain)
il->ops->set_rxon_chain(il);
}

/* Configure bluetooth coexistence if enabled */
Expand Down Expand Up @@ -6333,8 +6332,8 @@ il4965_init_drv(struct il_priv *il)
il->force_reset.reset_duration = IL_DELAY_NEXT_FORCE_FW_RELOAD;

/* Choose which receivers/antennas to use */
if (il->ops->hcmd->set_rxon_chain)
il->ops->hcmd->set_rxon_chain(il);
if (il->ops->set_rxon_chain)
il->ops->set_rxon_chain(il);

il_init_scan_params(il);

Expand Down
51 changes: 19 additions & 32 deletions drivers/net/wireless/iwlegacy/4965.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,6 @@ il4965_led_enable(struct il_priv *il)
_il_wr(il, CSR_LED_REG, CSR_LED_REG_TRUN_ON);
}

const struct il_led_ops il4965_led_ops = {
.cmd = il4965_send_led_cmd,
};

static int il4965_send_tx_power(struct il_priv *il);
static int il4965_hw_get_temperature(struct il_priv *il);

Expand Down Expand Up @@ -1737,12 +1733,6 @@ il4965_build_addsta_hcmd(const struct il_addsta_cmd *cmd, u8 * data)
return (u16) sizeof(struct il4965_addsta_cmd);
}

static struct il_hcmd_ops il4965_hcmd = {
.rxon_assoc = il4965_send_rxon_assoc,
.commit_rxon = il4965_commit_rxon,
.set_rxon_chain = il4965_set_rxon_chain,
};

static void
il4965_post_scan(struct il_priv *il)
{
Expand Down Expand Up @@ -1782,8 +1772,8 @@ il4965_post_associate(struct il_priv *il)

il_set_rxon_ht(il, &il->current_ht_config);

if (il->ops->hcmd->set_rxon_chain)
il->ops->hcmd->set_rxon_chain(il);
if (il->ops->set_rxon_chain)
il->ops->set_rxon_chain(il);

il->staging.assoc_id = cpu_to_le16(vif->bss_conf.aid);

Expand Down Expand Up @@ -1857,8 +1847,8 @@ il4965_config_ap(struct il_priv *il)
/* AP has all antennas */
il->chain_noise_data.active_chains = il->hw_params.valid_rx_ant;
il_set_rxon_ht(il, &il->current_ht_config);
if (il->ops->hcmd->set_rxon_chain)
il->ops->hcmd->set_rxon_chain(il);
if (il->ops->set_rxon_chain)
il->ops->set_rxon_chain(il);

il->staging.assoc_id = 0;

Expand All @@ -1882,20 +1872,6 @@ il4965_config_ap(struct il_priv *il)
il4965_send_beacon_cmd(il);
}

static struct il_hcmd_utils_ops il4965_hcmd_utils = {
.get_hcmd_size = il4965_get_hcmd_size,
.build_addsta_hcmd = il4965_build_addsta_hcmd,
.request_scan = il4965_request_scan,
.post_scan = il4965_post_scan,
};

static const struct il_legacy_ops il4965_legacy_ops = {
.post_associate = il4965_post_associate,
.config_ap = il4965_config_ap,
.manage_ibss_station = il4965_manage_ibss_station,
.update_bcast_stations = il4965_update_bcast_stations,
};

const struct il_ops il4965_ops = {
.txq_update_byte_cnt_tbl = il4965_txq_update_byte_cnt_tbl,
.txq_attach_buf_to_tfd = il4965_hw_txq_attach_buf_to_tfd,
Expand All @@ -1913,10 +1889,21 @@ const struct il_ops il4965_ops = {
.eeprom_acquire_semaphore = il4965_eeprom_acquire_semaphore,
.eeprom_release_semaphore = il4965_eeprom_release_semaphore,

.hcmd = &il4965_hcmd,
.utils = &il4965_hcmd_utils,
.led = &il4965_led_ops,
.legacy = &il4965_legacy_ops,
.rxon_assoc = il4965_send_rxon_assoc,
.commit_rxon = il4965_commit_rxon,
.set_rxon_chain = il4965_set_rxon_chain,

.get_hcmd_size = il4965_get_hcmd_size,
.build_addsta_hcmd = il4965_build_addsta_hcmd,
.request_scan = il4965_request_scan,
.post_scan = il4965_post_scan,

.post_associate = il4965_post_associate,
.config_ap = il4965_config_ap,
.manage_ibss_station = il4965_manage_ibss_station,
.update_bcast_stations = il4965_update_bcast_stations,

.send_led_cmd = il4965_send_led_cmd,
};

struct il_cfg il4965_cfg = {
Expand Down
50 changes: 19 additions & 31 deletions drivers/net/wireless/iwlegacy/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ il_led_cmd(struct il_priv *il, unsigned long on, unsigned long off)
il_blink_compensation(il, off,
il->cfg->led_compensation);

ret = il->ops->led->cmd(il, &led_cmd);
ret = il->ops->send_led_cmd(il, &led_cmd);
if (!ret) {
il->blink_on = on;
il->blink_off = off;
Expand Down Expand Up @@ -1482,9 +1482,6 @@ il_scan_initiate(struct il_priv *il, struct ieee80211_vif *vif)

lockdep_assert_held(&il->mutex);

if (WARN_ON(!il->ops->utils->request_scan))
return -EOPNOTSUPP;

cancel_delayed_work(&il->scan_check);

if (!il_is_ready_rf(il)) {
Expand All @@ -1507,7 +1504,7 @@ il_scan_initiate(struct il_priv *il, struct ieee80211_vif *vif)
set_bit(S_SCANNING, &il->status);
il->scan_start = jiffies;

ret = il->ops->utils->request_scan(il, vif);
ret = il->ops->request_scan(il, vif);
if (ret) {
clear_bit(S_SCANNING, &il->status);
return ret;
Expand Down Expand Up @@ -1669,7 +1666,7 @@ il_bg_scan_completed(struct work_struct *work)
il_power_set_mode(il, &il->power_data.sleep_cmd_next, false);
il_set_tx_power(il, il->tx_power_next, false);

il->ops->utils->post_scan(il);
il->ops->post_scan(il);

out:
mutex_unlock(&il->mutex);
Expand Down Expand Up @@ -1811,7 +1808,7 @@ il_send_add_sta(struct il_priv *il, struct il_addsta_cmd *sta, u8 flags)
might_sleep();
}

cmd.len = il->ops->utils->build_addsta_hcmd(sta, data);
cmd.len = il->ops->build_addsta_hcmd(sta, data);
ret = il_send_cmd(il, &cmd);

if (ret || (flags & CMD_ASYNC))
Expand Down Expand Up @@ -3078,7 +3075,7 @@ il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd)
u32 idx;
u16 fix_size;

cmd->len = il->ops->utils->get_hcmd_size(cmd->id, cmd->len);
cmd->len = il->ops->get_hcmd_size(cmd->id, cmd->len);
fix_size = (u16) (cmd->len + sizeof(out_cmd->hdr));

/* If any of the command structures end up being larger than
Expand Down Expand Up @@ -3842,8 +3839,8 @@ _il_set_rxon_ht(struct il_priv *il, struct il_ht_config *ht_conf)
rxon->flags |= RXON_FLG_CHANNEL_MODE_LEGACY;
}

if (il->ops->hcmd->set_rxon_chain)
il->ops->hcmd->set_rxon_chain(il);
if (il->ops->set_rxon_chain)
il->ops->set_rxon_chain(il);

D_ASSOC("rxon flags 0x%X operation mode :0x%X "
"extension channel offset 0x%x\n", le32_to_cpu(rxon->flags),
Expand Down Expand Up @@ -4472,8 +4469,8 @@ il_set_mode(struct il_priv *il)
{
il_connection_init_rx_config(il);

if (il->ops->hcmd->set_rxon_chain)
il->ops->hcmd->set_rxon_chain(il);
if (il->ops->set_rxon_chain)
il->ops->set_rxon_chain(il);

return il_commit_rxon(il);
}
Expand Down Expand Up @@ -5171,9 +5168,6 @@ il_mac_config(struct ieee80211_hw *hw, u32 changed)
int scan_active = 0;
bool ht_changed = false;

if (WARN_ON(!il->ops->legacy))
return -EOPNOTSUPP;

mutex_lock(&il->mutex);

D_MAC80211("enter to channel %d changed 0x%X\n", channel->hw_value,
Expand All @@ -5196,8 +5190,8 @@ il_mac_config(struct ieee80211_hw *hw, u32 changed)
* set up the SM PS mode to OFF if an HT channel is
* configured.
*/
if (il->ops->hcmd->set_rxon_chain)
il->ops->hcmd->set_rxon_chain(il);
if (il->ops->set_rxon_chain)
il->ops->set_rxon_chain(il);
}

/* during scanning mac80211 will delay channel setting until
Expand Down Expand Up @@ -5266,8 +5260,8 @@ il_mac_config(struct ieee80211_hw *hw, u32 changed)

spin_unlock_irqrestore(&il->lock, flags);

if (il->ops->legacy->update_bcast_stations)
ret = il->ops->legacy->update_bcast_stations(il);
if (il->ops->update_bcast_stations)
ret = il->ops->update_bcast_stations(il);

set_ch_out:
/* The list of supported rates and rate mask can be different
Expand Down Expand Up @@ -5317,9 +5311,6 @@ il_mac_reset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
struct il_priv *il = hw->priv;
unsigned long flags;

if (WARN_ON(!il->ops->legacy))
return;

mutex_lock(&il->mutex);
D_MAC80211("enter\n");

Expand Down Expand Up @@ -5472,7 +5463,7 @@ il_beacon_update(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
return;
}

il->ops->legacy->post_associate(il);
il->ops->post_associate(il);
}

void
Expand All @@ -5482,9 +5473,6 @@ il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
struct il_priv *il = hw->priv;
int ret;

if (WARN_ON(!il->ops->legacy))
return;

D_MAC80211("changes = 0x%X\n", changes);

mutex_lock(&il->mutex);
Expand Down Expand Up @@ -5587,8 +5575,8 @@ il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
if (changes & BSS_CHANGED_HT) {
il_ht_conf(il, vif);

if (il->ops->hcmd->set_rxon_chain)
il->ops->hcmd->set_rxon_chain(il);
if (il->ops->set_rxon_chain)
il->ops->set_rxon_chain(il);
}

if (changes & BSS_CHANGED_ASSOC) {
Expand All @@ -5597,7 +5585,7 @@ il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
il->timestamp = bss_conf->timestamp;

if (!il_is_rfkill(il))
il->ops->legacy->post_associate(il);
il->ops->post_associate(il);
} else
il_set_no_assoc(il, vif);
}
Expand All @@ -5617,14 +5605,14 @@ il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
memcpy(il->staging.bssid_addr, bss_conf->bssid,
ETH_ALEN);
memcpy(il->bssid, bss_conf->bssid, ETH_ALEN);
il->ops->legacy->config_ap(il);
il->ops->config_ap(il);
} else
il_set_no_assoc(il, vif);
}

if (changes & BSS_CHANGED_IBSS) {
ret =
il->ops->legacy->manage_ibss_station(il, vif,
il->ops->manage_ibss_station(il, vif,
bss_conf->ibss_joined);
if (ret)
IL_ERR("failed to %s IBSS station %pM\n",
Expand Down
Loading

0 comments on commit c936355

Please sign in to comment.