Skip to contentSkip to conversation

b43: clean channel handling

PATCH New Rafał Miłecki 1 participant 10 messages May 31, 2014 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

cover b43: clean channel handling

This patchset cleans channel handling in the driver which became a bit messy recently. We get rid of too many variables in PHY struct switching to a simple struct cfg80211_chan_def (unsigned int channel is still there because a lot of code depends on it).

This also slightly changes PHY ops to make PHY re-init possible with the current channel (this will be needed for band switching).

This has been basically tested for regressions on the following cards:
14e4:4312 BCM4311 G-PHY rev 8
14e4:4315 BCM4312 LP-PHY rev 1
14e4:4328 BCM4321 N-PHY rev 2
14e4:432b BCM4322 N-PHY rev 4
14e4:4353 BCM43224 N-PHY rev 6
(note 14e4:4312 was never working correctly for me).

John: it's the last "big thing" I wanted for 3.16. It's a bit late, so to minimalize a risk I gave it some testing on many devices. If you manage to get it for 3.16, that will be cool for me. Still, it's up to you, not a big pressure.

Rafa? Mi?ecki (9):
b43: drop B43_DEFAULT_CHANNEL
b43: b43_op_config: drop check for core change
b43: b43_op_config: use IEEE80211_CONF_CHANGE_CHANNEL
b43: PHY: don't force default channel during init
b43: b43_op_config: set channel info before switching band
b43: store current channel using struct cfg80211_chan_def
b43: PHY: drop own channel_freq (get it from chandef when needed)
b43: PHY: drop is_40mhz (get width info from chandef)
b43: PHY: drop channel_type (we can get this info from chandef)

 drivers/net/wireless/b43/main.c        | 46 ++++++------------
 drivers/net/wireless/b43/phy_common.c  | 21 ++++----
 drivers/net/wireless/b43/phy_common.h  | 12 +----
 drivers/net/wireless/b43/phy_ht.c      |  2 +-
 drivers/net/wireless/b43/phy_n.c       | 88 ++++++++++++++++++----------------
 drivers/net/wireless/b43/tables_nphy.c |  2 +-
 6 files changed, 75 insertions(+), 96 deletions(-)
Signature · 1 line
1.8.4.5
#1 lore raw

PATCH 1/9 b43: drop B43_DEFAULT_CHANNEL

It was never used, b43_switch_channel is always called with hw_value (from mac80211) or whatever get_default_chan returns.

---
 drivers/net/wireless/b43/phy_common.c | 3 ---
 drivers/net/wireless/b43/phy_common.h | 4 ----
 2 files changed, 7 deletions(-)
drivers/net/wireless/b43/phy_common.c +0 -3
index 08244b3..ac4cf2b 100644
@@ -408,9 +408,6 @@ int b43_switch_channel(struct b43_wldev *dev, unsigned int new_channel)
 	u16 channelcookie, savedcookie;
 	int err;
 
-	if (new_channel == B43_DEFAULT_CHANNEL)
-		new_channel = phy->ops->get_default_chan(dev);
-
 	/* First we set the channel radio code to prevent the
 	 * firmware from sending ghost packets.
 	 */
drivers/net/wireless/b43/phy_common.h +0 -4
index 4ad6240..9a92df4 100644
@@ -400,10 +400,6 @@ void b43_phy_take_out_of_reset(struct b43_wldev *dev);
  * b43_switch_channel - Switch to another channel
  */
 int b43_switch_channel(struct b43_wldev *dev, unsigned int new_channel);
-/**
- * B43_DEFAULT_CHANNEL - Switch to the default channel.
- */
-#define B43_DEFAULT_CHANNEL	UINT_MAX
 
 /**
  * b43_software_rfkill - Turn the radio ON or OFF in software.
Signature · 1 line
1.8.4.5
#2 lore raw

PATCH 2/9 b43: b43_op_config: drop check for core change

In reply to Rafał Miłecki

There aren't devices with multiple 802.11 cores supported by b43.

---
 drivers/net/wireless/b43/main.c | 20 ++------------------
 1 file changed, 2 insertions(+), 18 deletions(-)
drivers/net/wireless/b43/main.c +2 -18
index 32538ac..a9e50ee 100644
@@ -3798,17 +3798,13 @@ static void b43_set_retry_limits(struct b43_wldev *dev,
 static int b43_op_config(struct ieee80211_hw *hw, u32 changed)
 {
 	struct b43_wl *wl = hw_to_b43_wl(hw);
-	struct b43_wldev *dev;
-	struct b43_phy *phy;
+	struct b43_wldev *dev = wl->current_dev;
+	struct b43_phy *phy = &dev->phy;
 	struct ieee80211_conf *conf = &hw->conf;
 	int antenna;
 	int err = 0;
-	bool reload_bss = false;
 
 	mutex_lock(&wl->mutex);
-
-	dev = wl->current_dev;
-
 	b43_mac_suspend(dev);
 
 	/* Switch the band (if necessary). This might change the active core. */
@@ -3816,15 +3812,6 @@ static int b43_op_config(struct ieee80211_hw *hw, u32 changed)
 	if (err)
 		goto out_unlock_mutex;
 
-	/* Need to reload all settings if the core changed */
-	if (dev != wl->current_dev) {
-		dev = wl->current_dev;
-		changed = ~0;
-		reload_bss = true;
-	}
-
-	phy = &dev->phy;
-
 	if (conf_is_ht(conf))
 		phy->is_40mhz =
 			(conf_is_ht40_minus(conf) || conf_is_ht40_plus(conf));
@@ -3881,9 +3868,6 @@ out_mac_enable:
 out_unlock_mutex:
 	mutex_unlock(&wl->mutex);
 
-	if (wl->vif && reload_bss)
-		b43_op_bss_info_changed(hw, wl->vif, &wl->vif->bss_conf, ~0);
-
 	return err;
 }
 
Signature · 1 line
1.8.4.5
#3 lore raw

PATCH 3/9 b43: b43_op_config: use IEEE80211_CONF_CHANGE_CHANNEL

In reply to Rafał Miłecki

This is tiny optimization and grouping band/channel ops.

---
 drivers/net/wireless/b43/main.c | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)
drivers/net/wireless/b43/main.c +16 -15
index a9e50ee..59aa4fd 100644
@@ -3807,16 +3807,23 @@ static int b43_op_config(struct ieee80211_hw *hw, u32 changed)
 	mutex_lock(&wl->mutex);
 	b43_mac_suspend(dev);
 
-	/* Switch the band (if necessary). This might change the active core. */
-	err = b43_switch_band(dev, conf->chandef.chan);
-	if (err)
-		goto out_unlock_mutex;
+	if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
+		if (conf_is_ht(conf))
+			phy->is_40mhz = conf_is_ht40_minus(conf) ||
+					conf_is_ht40_plus(conf);
+		else
+			phy->is_40mhz = false;
 
-	if (conf_is_ht(conf))
-		phy->is_40mhz =
-			(conf_is_ht40_minus(conf) || conf_is_ht40_plus(conf));
-	else
-		phy->is_40mhz = false;
+		/* Switch the band (if necessary). */
+		err = b43_switch_band(dev, conf->chandef.chan);
+		if (err)
+			goto out_mac_enable;
+
+		/* Switch to the requested channel.
+		 * The firmware takes care of races with the TX handler.
+		 */
+		b43_switch_channel(dev, conf->chandef.chan->hw_value);
+	}
 
 	if (changed & IEEE80211_CONF_CHANGE_RETRY_LIMITS)
 		b43_set_retry_limits(dev, conf->short_frame_max_tx_count,
@@ -3825,11 +3832,6 @@ static int b43_op_config(struct ieee80211_hw *hw, u32 changed)
 	if (!changed)
 		goto out_mac_enable;
 
-	/* Switch to the requested channel.
-	 * The firmware takes care of races with the TX handler. */
-	if (conf->chandef.chan->hw_value != phy->channel)
-		b43_switch_channel(dev, conf->chandef.chan->hw_value);
-
 	dev->wl->radiotap_enabled = !!(conf->flags & IEEE80211_CONF_MONITOR);
 
 	/* Adjust the desired TX power level. */
@@ -3865,7 +3867,6 @@ static int b43_op_config(struct ieee80211_hw *hw, u32 changed)
 
 out_mac_enable:
 	b43_mac_enable(dev);
-out_unlock_mutex:
 	mutex_unlock(&wl->mutex);
 
 	return err;
Signature · 1 line
1.8.4.5
#4 lore raw

PATCH 4/9 b43: PHY: don't force default channel during init

In reply to Rafał Miłecki

PHY may need to be re-initialized during runtime (e.g. on band switch).

---
 drivers/net/wireless/b43/phy_common.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/net/wireless/b43/phy_common.c +3 -4
index ac4cf2b..3bfb795 100644
@@ -94,7 +94,8 @@ int b43_phy_init(struct b43_wldev *dev)
 	const struct b43_phy_operations *ops = phy->ops;
 	int err;
 
-	phy->channel = ops->get_default_chan(dev);
+	if (!phy->channel)
+		phy->channel = ops->get_default_chan(dev);
 
 	phy->ops->switch_analog(dev, true);
 	b43_software_rfkill(dev, false);
@@ -106,9 +107,7 @@ int b43_phy_init(struct b43_wldev *dev)
 	}
 	phy->do_full_init = false;
 
-	/* Make sure to switch hardware and firmware (SHM) to
-	 * the default channel. */
-	err = b43_switch_channel(dev, ops->get_default_chan(dev));
+	err = b43_switch_channel(dev, phy->channel);
 	if (err) {
 		b43err(dev->wl, "PHY init: Channel switch to default failed\n");
 		goto err_phy_exit;
Signature · 1 line
1.8.4.5
#5 lore raw

PATCH 5/9 b43: b43_op_config: set channel info before switching band

In reply to Rafał Miłecki

Band switching code needs to know what channel we switch to.

---
 drivers/net/wireless/b43/main.c       | 3 ++-
 drivers/net/wireless/b43/phy_common.c | 1 -
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/b43/main.c +2 -1
index 59aa4fd..5e4eed3 100644
@@ -3808,6 +3808,7 @@ static int b43_op_config(struct ieee80211_hw *hw, u32 changed)
 	b43_mac_suspend(dev);
 
 	if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
+		phy->channel = conf->chandef.chan->hw_value;
 		if (conf_is_ht(conf))
 			phy->is_40mhz = conf_is_ht40_minus(conf) ||
 					conf_is_ht40_plus(conf);
@@ -3822,7 +3823,7 @@ static int b43_op_config(struct ieee80211_hw *hw, u32 changed)
 		/* Switch to the requested channel.
 		 * The firmware takes care of races with the TX handler.
 		 */
-		b43_switch_channel(dev, conf->chandef.chan->hw_value);
+		b43_switch_channel(dev, phy->channel);
 	}
 
 	if (changed & IEEE80211_CONF_CHANGE_RETRY_LIMITS)
drivers/net/wireless/b43/phy_common.c +0 -1
index 3bfb795..b465011 100644
@@ -424,7 +424,6 @@ int b43_switch_channel(struct b43_wldev *dev, unsigned int new_channel)
 	if (err)
 		goto err_restore_cookie;
 
-	dev->phy.channel = new_channel;
 	/* Wait for the radio to tune to the channel and stabilize. */
 	msleep(8);
 
Signature · 1 line
1.8.4.5
#6 lore raw

PATCH 6/9 b43: store current channel using struct cfg80211_chan_def

In reply to Rafał Miłecki
---
 drivers/net/wireless/b43/main.c       | 1 +
 drivers/net/wireless/b43/phy_common.c | 9 +++++++--
 drivers/net/wireless/b43/phy_common.h | 1 +
 3 files changed, 9 insertions(+), 2 deletions(-)
drivers/net/wireless/b43/main.c +1 -0
index 5e4eed3..2b99ed3 100644
@@ -3808,6 +3808,7 @@ static int b43_op_config(struct ieee80211_hw *hw, u32 changed)
 	b43_mac_suspend(dev);
 
 	if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
+		phy->chandef = &conf->chandef;
 		phy->channel = conf->chandef.chan->hw_value;
 		if (conf_is_ht(conf))
 			phy->is_40mhz = conf_is_ht40_minus(conf) ||
drivers/net/wireless/b43/phy_common.c +7 -2
index b465011..9aa6c9c 100644
@@ -94,8 +94,13 @@ int b43_phy_init(struct b43_wldev *dev)
 	const struct b43_phy_operations *ops = phy->ops;
 	int err;
 
-	if (!phy->channel)
-		phy->channel = ops->get_default_chan(dev);
+	/* During PHY init we need to use some channel. On the first init this
+	 * function is called *before* b43_op_config, so our pointer is NULL.
+	 */
+	if (!phy->chandef) {
+		phy->chandef = &dev->wl->hw->conf.chandef;
+		phy->channel = phy->chandef->chan->hw_value;
+	}
 
 	phy->ops->switch_analog(dev, true);
 	b43_software_rfkill(dev, false);
drivers/net/wireless/b43/phy_common.h +1 -0
index 9a92df4..56dfe7a 100644
@@ -267,6 +267,7 @@ struct b43_phy {
 	unsigned long next_txpwr_check_time;
 
 	/* Current channel */
+	struct cfg80211_chan_def *chandef;
 	unsigned int channel;
 	u16 channel_freq;
 	enum nl80211_channel_type channel_type;
Signature · 1 line
1.8.4.5
#7 lore raw

PATCH 7/9 b43: PHY: drop own channel_freq (get it from chandef when needed)

In reply to Rafał Miłecki
---
 drivers/net/wireless/b43/phy_common.h |  1 -
 drivers/net/wireless/b43/phy_ht.c     |  2 +-
 drivers/net/wireless/b43/phy_n.c      | 24 ++++++++++++++----------
 3 files changed, 15 insertions(+), 12 deletions(-)
drivers/net/wireless/b43/phy_common.h +0 -1
index 56dfe7a..3990820 100644
@@ -269,7 +269,6 @@ struct b43_phy {
 	/* Current channel */
 	struct cfg80211_chan_def *chandef;
 	unsigned int channel;
-	u16 channel_freq;
 	enum nl80211_channel_type channel_type;
 
 	/* PHY TX errors counter. */
drivers/net/wireless/b43/phy_ht.c +1 -1
index 5d6833f..f2974c6 100644
@@ -596,7 +596,7 @@ static void b43_phy_ht_tx_power_ctl_setup(struct b43_wldev *dev)
 	u8 target[3];
 	s16 a1[3], b0[3], b1[3];
 
-	u16 freq = dev->phy.channel_freq;
+	u16 freq = dev->phy.chandef->chan->center_freq;
 	int i, c;
 
 	if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) {
drivers/net/wireless/b43/phy_n.c +14 -10
index 86569f6..dc62f02 100644
@@ -798,6 +798,7 @@ static void b43_chantab_radio_2056_upload(struct b43_wldev *dev,
 static void b43_radio_2056_setup(struct b43_wldev *dev,
 				const struct b43_nphy_channeltab_entry_rev3 *e)
 {
+	struct b43_phy *phy = &dev->phy;
 	struct ssb_sprom *sprom = dev->dev->bus_sprom;
 	enum ieee80211_band band = b43_current_band(dev->wl);
 	u16 offset;
@@ -909,7 +910,7 @@ static void b43_radio_2056_setup(struct b43_wldev *dev,
 			b43_radio_write(dev, offset | B2056_TX_PA_SPARE1, 0xee);
 		}
 	} else if (dev->phy.n->ipa5g_on && band == IEEE80211_BAND_5GHZ) {
-		u16 freq = dev->phy.channel_freq;
+		u16 freq = phy->chandef->chan->center_freq;
 		if (freq < 5100) {
 			paa_boost = 0xA;
 			pada_boost = 0x77;
@@ -1675,6 +1676,7 @@ static int b43_nphy_poll_rssi(struct b43_wldev *dev, enum n_rssi_type rssi_type,
 /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RSSICalRev3 */
 static void b43_nphy_rev3_rssi_cal(struct b43_wldev *dev)
 {
+	struct b43_phy *phy = &dev->phy;
 	struct b43_phy_n *nphy = dev->phy.n;
 
 	u16 saved_regs_phy_rfctl[2];
@@ -1897,9 +1899,9 @@ static void b43_nphy_rev3_rssi_cal(struct b43_wldev *dev)
 
 	/* Remember for which channel we store configuration */
 	if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ)
-		nphy->rssical_chanspec_2G.center_freq = dev->phy.channel_freq;
+		nphy->rssical_chanspec_2G.center_freq = phy->chandef->chan->center_freq;
 	else
-		nphy->rssical_chanspec_5G.center_freq = dev->phy.channel_freq;
+		nphy->rssical_chanspec_5G.center_freq = phy->chandef->chan->center_freq;
 
 	/* End of calibration, restore configuration */
 	b43_nphy_classifier(dev, 7, class);
@@ -2528,7 +2530,7 @@ static void b43_nphy_workarounds_rev7plus(struct b43_wldev *dev)
 				}
 			}
 		} else {
-			u16 freq = phy->channel_freq;
+			u16 freq = phy->chandef->chan->center_freq;
 			if ((freq >= 5180 && freq <= 5230) ||
 			    (freq >= 5745 && freq <= 5805)) {
 				b43_radio_write(dev, 0x7D, 0xFF);
@@ -3184,12 +3186,13 @@ static void b43_nphy_tx_power_ctrl(struct b43_wldev *dev, bool enable)
 /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/TxPwrFix */
 static void b43_nphy_tx_power_fix(struct b43_wldev *dev)
 {
+	struct b43_phy *phy = &dev->phy;
 	struct b43_phy_n *nphy = dev->phy.n;
 	struct ssb_sprom *sprom = dev->dev->bus_sprom;
 
 	u8 txpi[2], bbmult, i;
 	u16 tmp, radio_gain, dac_gain;
-	u16 freq = dev->phy.channel_freq;
+	u16 freq = phy->chandef->chan->center_freq;
 	u32 txgain;
 	/* u32 gaintbl; rev3+ */
 
@@ -3474,6 +3477,7 @@ static void b43_nphy_tx_prepare_adjusted_power_table(struct b43_wldev *dev)
 /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/TxPwrCtrlSetup */
 static void b43_nphy_tx_power_ctl_setup(struct b43_wldev *dev)
 {
+	struct b43_phy *phy = &dev->phy;
 	struct b43_phy_n *nphy = dev->phy.n;
 	struct ssb_sprom *sprom = dev->dev->bus_sprom;
 
@@ -3483,7 +3487,7 @@ static void b43_nphy_tx_power_ctl_setup(struct b43_wldev *dev)
 	s32 num, den, pwr;
 	u32 regval[64];
 
-	u16 freq = dev->phy.channel_freq;
+	u16 freq = phy->chandef->chan->center_freq;
 	u16 tmp;
 	u16 r; /* routing */
 	u8 i, c;
@@ -4500,7 +4504,7 @@ static void b43_nphy_save_cal(struct b43_wldev *dev)
 		txcal_radio_regs[2] = b43_radio_read(dev, 0x8D);
 		txcal_radio_regs[3] = b43_radio_read(dev, 0xBC);
 	}
-	iqcal_chanspec->center_freq = dev->phy.channel_freq;
+	iqcal_chanspec->center_freq = dev->phy.chandef->chan->center_freq;
 	iqcal_chanspec->channel_type = dev->phy.channel_type;
 	b43_ntab_read_bulk(dev, B43_NTAB16(15, 80), 8, table);
 
@@ -4581,6 +4585,7 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev *dev,
 				struct nphy_txgains target,
 				bool full, bool mphase)
 {
+	struct b43_phy *phy = &dev->phy;
 	struct b43_phy_n *nphy = dev->phy.n;
 	int i;
 	int error = 0;
@@ -4773,7 +4778,7 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev *dev,
 						nphy->txiqlocal_bestc);
 			nphy->txiqlocal_coeffsvalid = true;
 			nphy->txiqlocal_chanspec.center_freq =
-							dev->phy.channel_freq;
+						phy->chandef->chan->center_freq;
 			nphy->txiqlocal_chanspec.channel_type =
 							dev->phy.channel_type;
 		} else {
@@ -4811,7 +4816,7 @@ static void b43_nphy_reapply_tx_cal_coeffs(struct b43_wldev *dev)
 	bool equal = true;
 
 	if (!nphy->txiqlocal_coeffsvalid ||
-	    nphy->txiqlocal_chanspec.center_freq != dev->phy.channel_freq ||
+	    nphy->txiqlocal_chanspec.center_freq != dev->phy.chandef->chan->center_freq ||
 	    nphy->txiqlocal_chanspec.channel_type != dev->phy.channel_type)
 		return;
 
@@ -5502,7 +5507,6 @@ static int b43_nphy_set_channel(struct b43_wldev *dev,
 	/* Channel is set later in common code, but we need to set it on our
 	   own to let this function's subcalls work properly. */
 	phy->channel = channel->hw_value;
-	phy->channel_freq = channel->center_freq;
 
 	if (b43_channel_type_is_40mhz(phy->channel_type) !=
 		b43_channel_type_is_40mhz(channel_type))
Signature · 1 line
1.8.4.5
#8 lore raw

PATCH 8/9 b43: PHY: drop is_40mhz (get width info from chandef)

In reply to Rafał Miłecki
---
 drivers/net/wireless/b43/main.c       |  5 ----
 drivers/net/wireless/b43/phy_common.c |  5 ++++
 drivers/net/wireless/b43/phy_common.h |  5 ++--
 drivers/net/wireless/b43/phy_n.c      | 53 +++++++++++++++++------------------
 4 files changed, 33 insertions(+), 35 deletions(-)
drivers/net/wireless/b43/main.c +0 -5
index 2b99ed3..4b662d0 100644
@@ -3810,11 +3810,6 @@ static int b43_op_config(struct ieee80211_hw *hw, u32 changed)
 	if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
 		phy->chandef = &conf->chandef;
 		phy->channel = conf->chandef.chan->hw_value;
-		if (conf_is_ht(conf))
-			phy->is_40mhz = conf_is_ht40_minus(conf) ||
-					conf_is_ht40_plus(conf);
-		else
-			phy->is_40mhz = false;
 
 		/* Switch the band (if necessary). */
 		err = b43_switch_band(dev, conf->chandef.chan);
drivers/net/wireless/b43/phy_common.c +5 -0
index 9aa6c9c..e7e8383 100644
@@ -553,6 +553,11 @@ bool b43_channel_type_is_40mhz(enum nl80211_channel_type channel_type)
 		channel_type == NL80211_CHAN_HT40PLUS);
 }
 
+bool b43_is_40mhz(struct b43_wldev *dev)
+{
+	return dev->phy.chandef->width == NL80211_CHAN_WIDTH_40;
+}
+
 /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/BmacPhyClkFgc */
 void b43_phy_force_clock(struct b43_wldev *dev, bool force)
 {
drivers/net/wireless/b43/phy_common.h +2 -3
index 3990820..674422f 100644
@@ -228,9 +228,6 @@ struct b43_phy {
 	bool supports_2ghz;
 	bool supports_5ghz;
 
-	/* HT info */
-	bool is_40mhz;
-
 	/* Is GMODE (2 GHz mode) bit enabled? */
 	bool gmode;
 
@@ -452,6 +449,8 @@ void b43_phyop_switch_analog_generic(struct b43_wldev *dev, bool on);
 
 bool b43_channel_type_is_40mhz(enum nl80211_channel_type channel_type);
 
+bool b43_is_40mhz(struct b43_wldev *dev);
+
 void b43_phy_force_clock(struct b43_wldev *dev, bool force);
 
 struct b43_c32 b43_cordic(int theta);
drivers/net/wireless/b43/phy_n.c +26 -27

191 lines not on this page · raw message

Signature · 1 line
1.8.4.5
#9 lore raw

PATCH 9/9 b43: PHY: drop channel_type (we can get this info from chandef)

In reply to Rafał Miłecki
---
 drivers/net/wireless/b43/phy_common.c  |  6 ------
 drivers/net/wireless/b43/phy_common.h  |  3 ---
 drivers/net/wireless/b43/phy_n.c       | 11 +++++++----
 drivers/net/wireless/b43/tables_nphy.c |  2 +-
 4 files changed, 8 insertions(+), 14 deletions(-)
drivers/net/wireless/b43/phy_common.c +0 -6
index e7e8383..2d05b59 100644
@@ -547,12 +547,6 @@ void b43_phyop_switch_analog_generic(struct b43_wldev *dev, bool on)
 }
 
 
-bool b43_channel_type_is_40mhz(enum nl80211_channel_type channel_type)
-{
-	return (channel_type == NL80211_CHAN_HT40MINUS ||
-		channel_type == NL80211_CHAN_HT40PLUS);
-}
-
 bool b43_is_40mhz(struct b43_wldev *dev)
 {
 	return dev->phy.chandef->width == NL80211_CHAN_WIDTH_40;
drivers/net/wireless/b43/phy_common.h +0 -3
index 674422f..3912274 100644
@@ -266,7 +266,6 @@ struct b43_phy {
 	/* Current channel */
 	struct cfg80211_chan_def *chandef;
 	unsigned int channel;
-	enum nl80211_channel_type channel_type;
 
 	/* PHY TX errors counter. */
 	atomic_t txerr_cnt;
@@ -447,8 +446,6 @@ int b43_phy_shm_tssi_read(struct b43_wldev *dev, u16 shm_offset);
  */
 void b43_phyop_switch_analog_generic(struct b43_wldev *dev, bool on);
 
-bool b43_channel_type_is_40mhz(enum nl80211_channel_type channel_type);
-
 bool b43_is_40mhz(struct b43_wldev *dev);
 
 void b43_phy_force_clock(struct b43_wldev *dev, bool force);
drivers/net/wireless/b43/phy_n.c +7 -4
index dc12493..6398c7e 100644
@@ -4504,7 +4504,8 @@ static void b43_nphy_save_cal(struct b43_wldev *dev)
 		txcal_radio_regs[3] = b43_radio_read(dev, 0xBC);
 	}
 	iqcal_chanspec->center_freq = dev->phy.chandef->chan->center_freq;
-	iqcal_chanspec->channel_type = dev->phy.channel_type;
+	iqcal_chanspec->channel_type =
+				cfg80211_get_chandef_type(dev->phy.chandef);
 	b43_ntab_read_bulk(dev, B43_NTAB16(15, 80), 8, table);
 
 	if (nphy->hang_avoid)
@@ -4779,7 +4780,7 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev *dev,
 			nphy->txiqlocal_chanspec.center_freq =
 						phy->chandef->chan->center_freq;
 			nphy->txiqlocal_chanspec.channel_type =
-							dev->phy.channel_type;
+					cfg80211_get_chandef_type(phy->chandef);
 		} else {
 			length = 11;
 			if (dev->phy.rev < 3)
@@ -4816,7 +4817,7 @@ static void b43_nphy_reapply_tx_cal_coeffs(struct b43_wldev *dev)
 
 	if (!nphy->txiqlocal_coeffsvalid ||
 	    nphy->txiqlocal_chanspec.center_freq != dev->phy.chandef->chan->center_freq ||
-	    nphy->txiqlocal_chanspec.channel_type != dev->phy.channel_type)
+	    nphy->txiqlocal_chanspec.channel_type != cfg80211_get_chandef_type(dev->phy.chandef))
 		return;
 
 	b43_ntab_read_bulk(dev, B43_NTAB16(15, 80), 7, buffer);
@@ -5441,7 +5442,7 @@ static void b43_nphy_channel_setup(struct b43_wldev *dev,
 		bool avoid = false;
 		if (dev->phy.n->spur_avoid == B43_SPUR_AVOID_FORCE) {
 			avoid = true;
-		} else if (!b43_channel_type_is_40mhz(phy->channel_type)) {
+		} else if (!b43_is_40mhz(dev)) {
 			if ((ch >= 5 && ch <= 8) || ch == 13 || ch == 14)
 				avoid = true;
 		} else { /* 40MHz */
@@ -5507,9 +5508,11 @@ static int b43_nphy_set_channel(struct b43_wldev *dev,
 	   own to let this function's subcalls work properly. */
 	phy->channel = channel->hw_value;
 
+#if 0
 	if (b43_channel_type_is_40mhz(phy->channel_type) !=
 		b43_channel_type_is_40mhz(channel_type))
 		; /* TODO: BMAC BW Set (channel_type) */
+#endif
 
 	if (channel_type == NL80211_CHAN_HT40PLUS)
 		b43_phy_set(dev, B43_NPHY_RXCTL,
drivers/net/wireless/b43/tables_nphy.c +1 -1
index 4047c05..b221715 100644
@@ -3191,7 +3191,7 @@ struct nphy_gain_ctl_workaround_entry *b43_nphy_get_gain_ctl_workaround_ent(
 	/* Some workarounds to the workarounds... */
 	if (ghz5 && dev->phy.rev >= 6) {
 		if (dev->phy.radio_rev == 11 &&
-		    !b43_channel_type_is_40mhz(dev->phy.channel_type))
+		    !b43_is_40mhz(dev))
 			e->cliplo_gain = 0x2d;
 	} else if (!ghz5 && dev->phy.rev >= 5) {
 		static const int gain_data[] = {0x0062, 0x0064, 0x006a, 0x106a,
Signature · 1 line
1.8.4.5