[PATCH v2 2/6] Move channel and rates definitions to beginning of file

Olof Johansson dev at skyshaper.net
Fri Jun 14 02:36:40 EDT 2013


These will need to be accessed in different places across the file.
Move them to the beginning of the file for easy access.

Signed-off-by: Olof Johansson <dev at skyshaper.net>
---
 main.c | 291 +++++++++++++++++++++++++++++++++--------------------------------
 1 file changed, 146 insertions(+), 145 deletions(-)

diff --git a/main.c b/main.c
index e4eb7a4..8f5a66e 100644
--- a/main.c
+++ b/main.c
@@ -34,6 +34,152 @@ MODULE_PARM_DESC(debug_mask, "Debugging mask");
  */
 static struct ieee80211_hw *private_hw;

+#define CHAN2G(_freq, _idx) { \
+	.band = IEEE80211_BAND_2GHZ, \
+	.center_freq = (_freq), \
+	.hw_value = (_idx), \
+	.max_power = 25, \
+}
+
+#define CHAN5G(_freq, _idx) { \
+	.band = IEEE80211_BAND_5GHZ, \
+	.center_freq = (_freq), \
+	.hw_value = (_idx), \
+	.max_power = 25, \
+}
+
+/* The wcn firmware expects channel values to matching
+ * their mnemonic values. So use these for .hw_value. */
+static struct ieee80211_channel wcn_2ghz_channels[] = {
+	CHAN2G(2412, 1), /* Channel 1 */
+	CHAN2G(2417, 2), /* Channel 2 */
+	CHAN2G(2422, 3), /* Channel 3 */
+	CHAN2G(2427, 4), /* Channel 4 */
+	CHAN2G(2432, 5), /* Channel 5 */
+	CHAN2G(2437, 6), /* Channel 6 */
+	CHAN2G(2442, 7), /* Channel 7 */
+	CHAN2G(2447, 8), /* Channel 8 */
+	CHAN2G(2452, 9), /* Channel 9 */
+	CHAN2G(2457, 10), /* Channel 10 */
+	CHAN2G(2462, 11), /* Channel 11 */
+	CHAN2G(2467, 12), /* Channel 12 */
+	CHAN2G(2472, 13), /* Channel 13 */
+	CHAN2G(2484, 14)  /* Channel 14 */
+
+};
+
+static struct ieee80211_channel wcn_5ghz_channels[] = {
+	CHAN5G(5180, 36),
+	CHAN5G(5200, 40),
+	CHAN5G(5220, 44),
+	CHAN5G(5240, 48),
+	CHAN5G(5260, 52),
+	CHAN5G(5280, 56),
+	CHAN5G(5300, 60),
+	CHAN5G(5320, 64),
+	CHAN5G(5500, 100),
+	CHAN5G(5520, 104),
+	CHAN5G(5540, 108),
+	CHAN5G(5560, 112),
+	CHAN5G(5580, 116),
+	CHAN5G(5600, 120),
+	CHAN5G(5620, 124),
+	CHAN5G(5640, 128),
+	CHAN5G(5660, 132),
+	CHAN5G(5700, 140),
+	CHAN5G(5745, 149),
+	CHAN5G(5765, 153),
+	CHAN5G(5785, 157),
+	CHAN5G(5805, 161),
+	CHAN5G(5825, 165)
+};
+
+#define RATE(_bitrate, _hw_rate, _flags) { \
+	.bitrate        = (_bitrate),                   \
+	.flags          = (_flags),                     \
+	.hw_value       = (_hw_rate),                   \
+	.hw_value_short = (_hw_rate)  \
+}
+static struct ieee80211_rate wcn_legacy_rates[] = {
+	RATE(10, BIT(0), 0),
+	RATE(20, BIT(1), IEEE80211_RATE_SHORT_PREAMBLE),
+	RATE(55, BIT(2), IEEE80211_RATE_SHORT_PREAMBLE),
+	RATE(110, BIT(3), IEEE80211_RATE_SHORT_PREAMBLE),
+	RATE(60, BIT(4), 0),
+	RATE(90, BIT(5), 0),
+	RATE(120, BIT(6), 0),
+	RATE(180, BIT(7), 0),
+	RATE(240, BIT(8), 0),
+	RATE(360, BIT(9), 0),
+	RATE(480, BIT(10), 0),
+	RATE(540, BIT(11), 0)
+};
+
+static struct ieee80211_rate wcn_5ghz_rates[] = {
+	RATE(60, BIT(4), 0),
+	RATE(90, BIT(5), 0),
+	RATE(120, BIT(6), 0),
+	RATE(180, BIT(7), 0),
+	RATE(240, BIT(8), 0),
+	RATE(360, BIT(9), 0),
+	RATE(480, BIT(10), 0),
+	RATE(540, BIT(11), 0)
+};
+
+static struct ieee80211_supported_band wcn_band_2ghz = {
+	.channels	= wcn_2ghz_channels,
+	.n_channels	= ARRAY_SIZE(wcn_2ghz_channels),
+	.bitrates	= wcn_legacy_rates,
+	.n_bitrates	= ARRAY_SIZE(wcn_legacy_rates),
+	.ht_cap		= {
+		.cap = IEEE80211_HT_CAP_GRN_FLD | IEEE80211_HT_CAP_SGI_20 |
+			(1 << IEEE80211_HT_CAP_RX_STBC_SHIFT),
+		.ht_supported = true,
+		.ampdu_factor = IEEE80211_HT_MAX_AMPDU_8K,
+		.ampdu_density = IEEE80211_HT_MPDU_DENSITY_8,
+		.mcs = {
+			.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
+			.rx_highest = cpu_to_le16(72),
+			.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
+		}
+	}
+};
+
+static struct ieee80211_supported_band wcn_band_5ghz = {
+	.channels	= wcn_5ghz_channels,
+	.n_channels	= ARRAY_SIZE(wcn_5ghz_channels),
+	.bitrates	= wcn_5ghz_rates,
+	.n_bitrates	= ARRAY_SIZE(wcn_5ghz_rates),
+	.ht_cap		= {
+		.cap = IEEE80211_HT_CAP_GRN_FLD
+			| IEEE80211_HT_CAP_SGI_20
+			| IEEE80211_HT_CAP_DSSSCCK40
+			| IEEE80211_HT_CAP_LSIG_TXOP_PROT
+			| IEEE80211_HT_CAP_SGI_40
+			| IEEE80211_HT_CAP_SUP_WIDTH_20_40,
+		.ht_supported = true,
+		.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
+		.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
+		.mcs = {
+			.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
+			.rx_highest = cpu_to_le16(72),
+			.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
+		}
+	}
+};
+
+static const struct ieee80211_iface_limit if_limits[] = {
+	{ .max = 2, .types = BIT(NL80211_IFTYPE_STATION) },
+	{ .max = 1, .types = BIT(NL80211_IFTYPE_AP) },
+};
+
+static const struct ieee80211_iface_combination if_comb = {
+	.limits = if_limits,
+	.n_limits = ARRAY_SIZE(if_limits),
+	.max_interfaces = 2,
+	.num_different_channels = 1,
+};
+
 static int wcn36xx_start(struct ieee80211_hw *hw)
 {
 	struct wcn36xx *wcn = hw->priv;
@@ -503,151 +649,6 @@ static struct ieee80211_hw *wcn36xx_alloc_hw(void)
 	hw = ieee80211_alloc_hw(sizeof(struct wcn36xx), &wcn36xx_ops);
 	return hw;
 }
-#define CHAN2G(_freq, _idx) { \
-	.band = IEEE80211_BAND_2GHZ, \
-	.center_freq = (_freq), \
-	.hw_value = (_idx), \
-	.max_power = 25, \
-}
-
-#define CHAN5G(_freq, _idx) { \
-	.band = IEEE80211_BAND_5GHZ, \
-	.center_freq = (_freq), \
-	.hw_value = (_idx), \
-	.max_power = 25, \
-}
-
-/* The wcn firmware expects channel values to matching
- * their mnemonic values. So use these for .hw_value. */
-static struct ieee80211_channel wcn_2ghz_channels[] = {
-	CHAN2G(2412, 1), /* Channel 1 */
-	CHAN2G(2417, 2), /* Channel 2 */
-	CHAN2G(2422, 3), /* Channel 3 */
-	CHAN2G(2427, 4), /* Channel 4 */
-	CHAN2G(2432, 5), /* Channel 5 */
-	CHAN2G(2437, 6), /* Channel 6 */
-	CHAN2G(2442, 7), /* Channel 7 */
-	CHAN2G(2447, 8), /* Channel 8 */
-	CHAN2G(2452, 9), /* Channel 9 */
-	CHAN2G(2457, 10), /* Channel 10 */
-	CHAN2G(2462, 11), /* Channel 11 */
-	CHAN2G(2467, 12), /* Channel 12 */
-	CHAN2G(2472, 13), /* Channel 13 */
-	CHAN2G(2484, 14)  /* Channel 14 */
-
-};
-
-static struct ieee80211_channel wcn_5ghz_channels[] = {
-	CHAN5G(5180, 36),
-	CHAN5G(5200, 40),
-	CHAN5G(5220, 44),
-	CHAN5G(5240, 48),
-	CHAN5G(5260, 52),
-	CHAN5G(5280, 56),
-	CHAN5G(5300, 60),
-	CHAN5G(5320, 64),
-	CHAN5G(5500, 100),
-	CHAN5G(5520, 104),
-	CHAN5G(5540, 108),
-	CHAN5G(5560, 112),
-	CHAN5G(5580, 116),
-	CHAN5G(5600, 120),
-	CHAN5G(5620, 124),
-	CHAN5G(5640, 128),
-	CHAN5G(5660, 132),
-	CHAN5G(5700, 140),
-	CHAN5G(5745, 149),
-	CHAN5G(5765, 153),
-	CHAN5G(5785, 157),
-	CHAN5G(5805, 161),
-	CHAN5G(5825, 165)
-};
-
-#define RATE(_bitrate, _hw_rate, _flags) { \
-	.bitrate        = (_bitrate),                   \
-	.flags          = (_flags),                     \
-	.hw_value       = (_hw_rate),                   \
-	.hw_value_short = (_hw_rate)  \
-}
-static struct ieee80211_rate wcn_legacy_rates[] = {
-	RATE(10, BIT(0), 0),
-	RATE(20, BIT(1), IEEE80211_RATE_SHORT_PREAMBLE),
-	RATE(55, BIT(2), IEEE80211_RATE_SHORT_PREAMBLE),
-	RATE(110, BIT(3), IEEE80211_RATE_SHORT_PREAMBLE),
-	RATE(60, BIT(4), 0),
-	RATE(90, BIT(5), 0),
-	RATE(120, BIT(6), 0),
-	RATE(180, BIT(7), 0),
-	RATE(240, BIT(8), 0),
-	RATE(360, BIT(9), 0),
-	RATE(480, BIT(10), 0),
-	RATE(540, BIT(11), 0)
-};
-
-static struct ieee80211_rate wcn_5ghz_rates[] = {
-	RATE(60, BIT(4), 0),
-	RATE(90, BIT(5), 0),
-	RATE(120, BIT(6), 0),
-	RATE(180, BIT(7), 0),
-	RATE(240, BIT(8), 0),
-	RATE(360, BIT(9), 0),
-	RATE(480, BIT(10), 0),
-	RATE(540, BIT(11), 0)
-};
-
-static struct ieee80211_supported_band wcn_band_2ghz = {
-	.channels	= wcn_2ghz_channels,
-	.n_channels	= ARRAY_SIZE(wcn_2ghz_channels),
-	.bitrates	= wcn_legacy_rates,
-	.n_bitrates	= ARRAY_SIZE(wcn_legacy_rates),
-	.ht_cap		= {
-		.cap = IEEE80211_HT_CAP_GRN_FLD | IEEE80211_HT_CAP_SGI_20 |
-			(1 << IEEE80211_HT_CAP_RX_STBC_SHIFT),
-		.ht_supported = true,
-		.ampdu_factor = IEEE80211_HT_MAX_AMPDU_8K,
-		.ampdu_density = IEEE80211_HT_MPDU_DENSITY_8,
-		.mcs = {
-			.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
-			.rx_highest = cpu_to_le16(72),
-			.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
-		}
-	}
-};
-
-static struct ieee80211_supported_band wcn_band_5ghz = {
-	.channels	= wcn_5ghz_channels,
-	.n_channels	= ARRAY_SIZE(wcn_5ghz_channels),
-	.bitrates	= wcn_5ghz_rates,
-	.n_bitrates	= ARRAY_SIZE(wcn_5ghz_rates),
-	.ht_cap		= {
-		.cap = IEEE80211_HT_CAP_GRN_FLD
-			| IEEE80211_HT_CAP_SGI_20
-			| IEEE80211_HT_CAP_DSSSCCK40
-			| IEEE80211_HT_CAP_LSIG_TXOP_PROT
-			| IEEE80211_HT_CAP_SGI_40
-			| IEEE80211_HT_CAP_SUP_WIDTH_20_40,
-		.ht_supported = true,
-		.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
-		.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
-		.mcs = {
-			.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
-			.rx_highest = cpu_to_le16(72),
-			.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
-		}
-	}
-};
-
-static const struct ieee80211_iface_limit if_limits[] = {
-	{ .max = 2, .types = BIT(NL80211_IFTYPE_STATION) },
-	{ .max = 1, .types = BIT(NL80211_IFTYPE_AP) },
-};
-
-static const struct ieee80211_iface_combination if_comb = {
-	.limits = if_limits,
-	.n_limits = ARRAY_SIZE(if_limits),
-	.max_interfaces = 2,
-	.num_different_channels = 1,
-};

 static int wcn36xx_init_ieee80211(struct wcn36xx *wcn)
 {
-- 
1.8.2.2



More information about the wcn36xx mailing list