From 6c4b37be98bdfb9a83c9f3900c7a0366b5c8e65c Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 15 Jun 2016 15:47:49 +0200 Subject: [PATCH] move dev->chandef to mt76 struct Signed-off-by: Felix Fietkau --- mac80211.c | 1 + mt76.h | 1 + mt7603.h | 1 - mt7603_init.c | 4 ---- mt7603_mac.c | 4 ++-- mt7603_main.c | 2 +- mt7603_mcu.c | 6 +++--- mt76x2.h | 1 - mt76x2_eeprom.c | 12 ++++++------ mt76x2_eeprom.h | 2 +- mt76x2_init.c | 5 ----- mt76x2_mac.c | 8 ++++---- mt76x2_phy.c | 18 +++++++++--------- 13 files changed, 28 insertions(+), 37 deletions(-) diff --git a/mac80211.c b/mac80211.c index 1d97eda5..0719fba5 100644 --- a/mac80211.c +++ b/mac80211.c @@ -93,6 +93,7 @@ mt76_init_sband(struct mt76_dev *dev, struct ieee80211_supported_band *sband, sband->n_channels = n_chan; sband->bitrates = rates; sband->n_bitrates = n_rates; + dev->chandef.chan = &sband->channels[0]; ht_cap = &sband->ht_cap; ht_cap->ht_supported = true; diff --git a/mt76.h b/mt76.h index 1a543311..95087d68 100644 --- a/mt76.h +++ b/mt76.h @@ -174,6 +174,7 @@ struct mt76_driver_ops { struct mt76_dev { struct ieee80211_hw *hw; + struct cfg80211_chan_def chandef; spinlock_t lock; const struct mt76_bus_ops *bus; diff --git a/mt7603.h b/mt7603.h index ae9caeb4..327b076e 100644 --- a/mt7603.h +++ b/mt7603.h @@ -107,7 +107,6 @@ struct mt7603_dev { struct mt76_dev mt76; /* must be first */ struct mutex mutex; - struct cfg80211_chan_def chandef; u32 irqmask; spinlock_t irq_lock; diff --git a/mt7603_init.c b/mt7603_init.c index 0be81836..edf735c1 100644 --- a/mt7603_init.c +++ b/mt7603_init.c @@ -336,7 +336,6 @@ static const struct ieee80211_iface_combination if_comb[] = { int mt7603_register_device(struct mt7603_dev *dev) { struct ieee80211_hw *hw = mt76_hw(dev); - struct ieee80211_supported_band *sband; struct wiphy *wiphy = hw->wiphy; int ret; @@ -373,9 +372,6 @@ int mt7603_register_device(struct mt7603_dev *dev) if (ret) return ret; - sband = wiphy->bands[NL80211_BAND_2GHZ]; - dev->chandef.chan = &sband->channels[0]; - mt7603_init_debugfs(dev); return 0; diff --git a/mt7603_mac.c b/mt7603_mac.c index 6fbd60a0..bb302d1e 100644 --- a/mt7603_mac.c +++ b/mt7603_mac.c @@ -52,7 +52,7 @@ void mt7603_mac_set_timing(struct mt7603_dev *dev) MT76_SET(MT_TIMEOUT_VAL_CCA, offset); int sifs; - if (dev->chandef.chan->band == NL80211_BAND_5GHZ) + if (dev->mt76.chandef.chan->band == NL80211_BAND_5GHZ) sifs = 16; else sifs = 10; @@ -443,7 +443,7 @@ mt7603_mac_tx_rate_val(struct mt7603_dev *dev, *bw = 1; } else { const struct ieee80211_rate *r; - int band = dev->chandef.chan->band; + int band = dev->mt76.chandef.chan->band; u16 val; nss = 1; diff --git a/mt7603_main.c b/mt7603_main.c index 08ca585e..483a58e7 100644 --- a/mt7603_main.c +++ b/mt7603_main.c @@ -129,7 +129,7 @@ mt7603_set_channel(struct mt7603_dev *dev, struct cfg80211_chan_def *def) mt7603_mac_stop(dev); - dev->chandef = *def; + dev->mt76.chandef = *def; mt76_rmw_field(dev, MT_AGG_BWCR, MT_AGG_BWCR_BW, bw); ret = mt7603_mcu_set_channel(dev); if (ret) diff --git a/mt7603_mcu.c b/mt7603_mcu.c index db947c11..542e4254 100644 --- a/mt7603_mcu.c +++ b/mt7603_mcu.c @@ -428,7 +428,7 @@ static int mt7603_mcu_set_tx_power(struct mt7603_dev *dev) u8 temp_comp_power[17]; u8 reserved; } req = { - .center_channel = dev->chandef.chan->hw_value, + .center_channel = dev->mt76.chandef.chan->hw_value, #define EEP_VAL(n) ((u8 *) dev->mt76.eeprom.data)[n] .tssi = EEP_VAL(MT_EE_NIC_CONF_1 + 1), .temp_comp = EEP_VAL(MT_EE_NIC_CONF_1), @@ -472,8 +472,8 @@ int mt7603_mcu_set_channel(struct mt7603_dev *dev) u8 txpower[21]; u8 _res1[3]; } req = { - .control_chan = dev->chandef.chan->hw_value, - .center_chan = dev->chandef.chan->hw_value, + .control_chan = dev->mt76.chandef.chan->hw_value, + .center_chan = dev->mt76.chandef.chan->hw_value, .bw = MT_BW_20, .tx_streams = dev->tx_chains, .rx_streams = dev->rx_chains, diff --git a/mt76x2.h b/mt76x2.h index b70cf91a..2ccc8be5 100644 --- a/mt76x2.h +++ b/mt76x2.h @@ -95,7 +95,6 @@ struct mt76x2_dev { const u16 *beacon_offsets; unsigned long wcid_mask[256 / BITS_PER_LONG]; - struct cfg80211_chan_def chandef; int txpower_conf; int txpower_cur; diff --git a/mt76x2_eeprom.c b/mt76x2_eeprom.c index e636dae7..e464a605 100644 --- a/mt76x2_eeprom.c +++ b/mt76x2_eeprom.c @@ -336,7 +336,7 @@ mt76x2_get_5g_rx_gain(struct mt76x2_dev *dev, u8 channel) void mt76x2_read_rx_gain(struct mt76x2_dev *dev) { - struct ieee80211_channel *chan = dev->chandef.chan; + struct ieee80211_channel *chan = dev->mt76.chandef.chan; int channel = chan->hw_value; s8 lna_5g[3], lna_2g; u8 lna; @@ -415,7 +415,7 @@ void mt76x2_get_rate_power(struct mt76x2_dev *dev, struct mt76x2_rate_power *t) bool is_5ghz = false; u16 val; - is_5ghz = dev->chandef.chan->band == NL80211_BAND_5GHZ; + is_5ghz = dev->mt76.chandef.chan->band == NL80211_BAND_5GHZ; memset(t, 0, sizeof(*t)); @@ -471,7 +471,7 @@ static void mt76x2_get_power_info_2g(struct mt76x2_dev *dev, struct mt76x2_tx_power_info *t, int chain, int offset) { - int channel = dev->chandef.chan->hw_value; + int channel = dev->mt76.chandef.chan->hw_value; int delta_idx; u8 data[6]; u16 val; @@ -498,7 +498,7 @@ static void mt76x2_get_power_info_5g(struct mt76x2_dev *dev, struct mt76x2_tx_power_info *t, int chain, int offset) { - int channel = dev->chandef.chan->hw_value; + int channel = dev->mt76.chandef.chan->hw_value; enum mt76x2_cal_channel_group group = mt76x2_get_cal_channel_group(channel); int delta_idx; u16 val; @@ -550,7 +550,7 @@ void mt76x2_get_power_info(struct mt76x2_dev *dev, struct mt76x2_tx_power_info * bw40 = mt76x2_eeprom_get(dev, MT_EE_TX_POWER_DELTA_BW40); bw80 = mt76x2_eeprom_get(dev, MT_EE_TX_POWER_DELTA_BW80); - if (dev->chandef.chan->band == NL80211_BAND_5GHZ) { + if (dev->mt76.chandef.chan->band == NL80211_BAND_5GHZ) { bw40 >>= 8; mt76x2_get_power_info_5g(dev, t, 0, MT_EE_TX_POWER_0_START_5G); mt76x2_get_power_info_5g(dev, t, 1, MT_EE_TX_POWER_1_START_5G); @@ -568,7 +568,7 @@ void mt76x2_get_power_info(struct mt76x2_dev *dev, struct mt76x2_tx_power_info * int mt76x2_get_temp_comp(struct mt76x2_dev *dev, struct mt76x2_temp_comp *t) { - enum nl80211_band band = dev->chandef.chan->band; + enum nl80211_band band = dev->mt76.chandef.chan->band; u16 val, slope; u8 bounds; diff --git a/mt76x2_eeprom.h b/mt76x2_eeprom.h index e6abf8fc..aad513fe 100644 --- a/mt76x2_eeprom.h +++ b/mt76x2_eeprom.h @@ -170,7 +170,7 @@ mt76x2_has_ext_lna(struct mt76x2_dev *dev) { u32 val = mt76x2_eeprom_get(dev, MT_EE_NIC_CONF_1); - if (dev->chandef.chan->band == NL80211_BAND_2GHZ) + if (dev->mt76.chandef.chan->band == NL80211_BAND_2GHZ) return val & MT_EE_NIC_CONF_1_LNA_EXT_2G; else return val & MT_EE_NIC_CONF_1_LNA_EXT_5G; diff --git a/mt76x2_init.c b/mt76x2_init.c index 4266930d..c3fd7944 100644 --- a/mt76x2_init.c +++ b/mt76x2_init.c @@ -684,7 +684,6 @@ static const struct ieee80211_iface_combination if_comb[] = { int mt76x2_register_device(struct mt76x2_dev *dev) { struct ieee80211_hw *hw = mt76_hw(dev); - struct ieee80211_supported_band *sband; struct wiphy *wiphy = hw->wiphy; void *status_fifo; int fifo_size; @@ -740,10 +739,6 @@ int mt76x2_register_device(struct mt76x2_dev *dev) if (ret) goto fail; - sband = wiphy->bands[dev->mt76.cap.has_5ghz ? NL80211_BAND_5GHZ : - NL80211_BAND_2GHZ]; - dev->chandef.chan = &sband->channels[0]; - mt76x2_init_debugfs(dev); return 0; diff --git a/mt76x2_mac.c b/mt76x2_mac.c index 02790063..9f715f9e 100644 --- a/mt76x2_mac.c +++ b/mt76x2_mac.c @@ -118,7 +118,7 @@ mt76x2_mac_tx_rate_val(struct mt76x2_dev *dev, const struct ieee80211_tx_rate *r bw = 1; } else { const struct ieee80211_rate *r; - int band = dev->chandef.chan->band; + int band = dev->mt76.chandef.chan->band; u16 val; r = &mt76_hw(dev)->wiphy->bands[band]->bitrates[rate->idx]; @@ -237,8 +237,8 @@ int mt76x2_mac_process_rx(struct mt76x2_dev *dev, struct sk_buff *skb, void *rxi status->chain_signal[0] = mt76x2_phy_get_rssi(dev, rxwi->rssi[0], 0); status->chain_signal[1] = mt76x2_phy_get_rssi(dev, rxwi->rssi[1], 1); status->signal = max(status->chain_signal[0], status->chain_signal[1]); - status->freq = dev->chandef.chan->center_freq; - status->band = dev->chandef.chan->band; + status->freq = dev->mt76.chandef.chan->center_freq; + status->band = dev->mt76.chandef.chan->band; mt76x2_mac_process_rate(status, rate); @@ -312,7 +312,7 @@ mt76x2_mac_fill_tx_status(struct mt76x2_dev *dev, struct ieee80211_tx_info *info last_rate = min_t(int, st->retry, IEEE80211_TX_MAX_RATES - 1); mt76x2_mac_process_tx_rate(&rate[last_rate], st->rate, - dev->chandef.chan->band); + dev->mt76.chandef.chan->band); if (last_rate < IEEE80211_TX_MAX_RATES - 1) rate[last_rate + 1].idx = -1; diff --git a/mt76x2_phy.c b/mt76x2_phy.c index 59e54f36..bb1ed2cc 100644 --- a/mt76x2_phy.c +++ b/mt76x2_phy.c @@ -113,7 +113,7 @@ mt76x2_get_max_power(struct mt76x2_rate_power *r) void mt76x2_phy_set_txpower(struct mt76x2_dev *dev) { - enum nl80211_chan_width width = dev->chandef.width; + enum nl80211_chan_width width = dev->mt76.chandef.width; struct mt76x2_tx_power_info txp; int txp_0, txp_1, delta = 0; struct mt76x2_rate_power t = {}; @@ -170,7 +170,7 @@ void mt76x2_phy_set_txpower(struct mt76x2_dev *dev) static bool mt76x2_channel_silent(struct mt76x2_dev *dev) { - struct ieee80211_channel *chan = dev->chandef.chan; + struct ieee80211_channel *chan = dev->mt76.chandef.chan; return ((chan->flags & IEEE80211_CHAN_RADAR) && chan->dfs_state != NL80211_DFS_AVAILABLE); @@ -179,7 +179,7 @@ mt76x2_channel_silent(struct mt76x2_dev *dev) static bool mt76x2_phy_tssi_init_cal(struct mt76x2_dev *dev) { - struct ieee80211_channel *chan = dev->chandef.chan; + struct ieee80211_channel *chan = dev->mt76.chandef.chan; u32 flag = 0; if (!mt76x2_tssi_enabled(dev)) @@ -202,7 +202,7 @@ mt76x2_phy_tssi_init_cal(struct mt76x2_dev *dev) static void mt76x2_phy_channel_calibrate(struct mt76x2_dev *dev, bool mac_stopped) { - struct ieee80211_channel *chan = dev->chandef.chan; + struct ieee80211_channel *chan = dev->mt76.chandef.chan; bool is_5ghz = chan->band == NL80211_BAND_5GHZ; if (dev->cal.channel_cal_done) @@ -391,7 +391,7 @@ mt76x2_get_agc_gain(struct mt76x2_dev *dev, u8 *dest) static int mt76x2_get_rssi_gain_thresh(struct mt76x2_dev *dev) { - switch (dev->chandef.width) { + switch (dev->mt76.chandef.width) { case NL80211_CHAN_WIDTH_80: return -62; case NL80211_CHAN_WIDTH_40: @@ -420,14 +420,14 @@ mt76x2_phy_update_channel_gain(struct mt76x2_dev *dev) dev->cal.low_gain = low_gain; - if (dev->chandef.width >= NL80211_CHAN_WIDTH_40) + if (dev->mt76.chandef.width >= NL80211_CHAN_WIDTH_40) val = 0x1e42 << 16; else val = 0x1836 << 16; val |= 0xf8; - if (dev->chandef.width == NL80211_CHAN_WIDTH_80) + if (dev->mt76.chandef.width == NL80211_CHAN_WIDTH_80) mt76_wr(dev, MT_BBP(RXO, 14), 0x00560411); else mt76_wr(dev, MT_BBP(RXO, 14), 0x00560423); @@ -487,7 +487,7 @@ int mt76x2_phy_set_channel(struct mt76x2_dev *dev, int ret; u8 sifs = 13; - dev->chandef = *chandef; + dev->mt76.chandef = *chandef; dev->cal.channel_cal_done = false; freq = chandef->chan->center_freq; freq1 = chandef->center_freq1; @@ -590,7 +590,7 @@ int mt76x2_phy_set_channel(struct mt76x2_dev *dev, static void mt76x2_phy_tssi_compensate(struct mt76x2_dev *dev) { - struct ieee80211_channel *chan = dev->chandef.chan; + struct ieee80211_channel *chan = dev->mt76.chandef.chan; struct mt76x2_tx_power_info txp; struct mt76x2_tssi_comp t = {};