diff options
author | Ivo van Doorn <ivdoorn@gmail.com> | 2008-08-04 10:38:47 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-08-22 16:29:58 -0400 |
commit | 8c5e7a5f59f9d11597bd47de28334da318ea0e80 (patch) | |
tree | 46dc69607e8a196fd68b3b040b312bc1e7fc0559 /drivers/net/wireless/rt2x00/rt73usb.c | |
parent | 906c110fcc24bdd5bf0fa22d89ac75d99c747e53 (diff) |
rt2x00: Gather channel information in structure
Channel information which is read from EEPROM should
be read into an array containing per-channel information.
This removes the requirement of multiple arrays and makes
the channel handling a bit cleaner and easier to expand.
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt73usb.c')
-rw-r--r-- | drivers/net/wireless/rt2x00/rt73usb.c | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c index ddba747fed98..1bd6b3ffca09 100644 --- a/drivers/net/wireless/rt2x00/rt73usb.c +++ b/drivers/net/wireless/rt2x00/rt73usb.c | |||
@@ -2107,10 +2107,11 @@ static const struct rf_channel rf_vals_5225_2527[] = { | |||
2107 | }; | 2107 | }; |
2108 | 2108 | ||
2109 | 2109 | ||
2110 | static void rt73usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev) | 2110 | static int rt73usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev) |
2111 | { | 2111 | { |
2112 | struct hw_mode_spec *spec = &rt2x00dev->spec; | 2112 | struct hw_mode_spec *spec = &rt2x00dev->spec; |
2113 | u8 *txpower; | 2113 | struct channel_info *info; |
2114 | char *tx_power; | ||
2114 | unsigned int i; | 2115 | unsigned int i; |
2115 | 2116 | ||
2116 | /* | 2117 | /* |
@@ -2127,20 +2128,10 @@ static void rt73usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev) | |||
2127 | EEPROM_MAC_ADDR_0)); | 2128 | EEPROM_MAC_ADDR_0)); |
2128 | 2129 | ||
2129 | /* | 2130 | /* |
2130 | * Convert tx_power array in eeprom. | ||
2131 | */ | ||
2132 | txpower = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_G_START); | ||
2133 | for (i = 0; i < 14; i++) | ||
2134 | txpower[i] = TXPOWER_FROM_DEV(txpower[i]); | ||
2135 | |||
2136 | /* | ||
2137 | * Initialize hw_mode information. | 2131 | * Initialize hw_mode information. |
2138 | */ | 2132 | */ |
2139 | spec->supported_bands = SUPPORT_BAND_2GHZ; | 2133 | spec->supported_bands = SUPPORT_BAND_2GHZ; |
2140 | spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM; | 2134 | spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM; |
2141 | spec->tx_power_a = NULL; | ||
2142 | spec->tx_power_bg = txpower; | ||
2143 | spec->tx_power_default = DEFAULT_TXPOWER; | ||
2144 | 2135 | ||
2145 | if (rt2x00_rf(&rt2x00dev->chip, RF2528)) { | 2136 | if (rt2x00_rf(&rt2x00dev->chip, RF2528)) { |
2146 | spec->num_channels = ARRAY_SIZE(rf_vals_bg_2528); | 2137 | spec->num_channels = ARRAY_SIZE(rf_vals_bg_2528); |
@@ -2158,14 +2149,26 @@ static void rt73usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev) | |||
2158 | spec->channels = rf_vals_5225_2527; | 2149 | spec->channels = rf_vals_5225_2527; |
2159 | } | 2150 | } |
2160 | 2151 | ||
2161 | if (rt2x00_rf(&rt2x00dev->chip, RF5225) || | 2152 | /* |
2162 | rt2x00_rf(&rt2x00dev->chip, RF5226)) { | 2153 | * Create channel information array |
2163 | txpower = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A_START); | 2154 | */ |
2164 | for (i = 0; i < 14; i++) | 2155 | info = kzalloc(spec->num_channels * sizeof(*info), GFP_KERNEL); |
2165 | txpower[i] = TXPOWER_FROM_DEV(txpower[i]); | 2156 | if (!info) |
2157 | return -ENOMEM; | ||
2166 | 2158 | ||
2167 | spec->tx_power_a = txpower; | 2159 | spec->channels_info = info; |
2160 | |||
2161 | tx_power = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_G_START); | ||
2162 | for (i = 0; i < 14; i++) | ||
2163 | info[i].tx_power1 = TXPOWER_FROM_DEV(tx_power[i]); | ||
2164 | |||
2165 | if (spec->num_channels > 14) { | ||
2166 | tx_power = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A_START); | ||
2167 | for (i = 14; i < spec->num_channels; i++) | ||
2168 | info[i].tx_power1 = TXPOWER_FROM_DEV(tx_power[i]); | ||
2168 | } | 2169 | } |
2170 | |||
2171 | return 0; | ||
2169 | } | 2172 | } |
2170 | 2173 | ||
2171 | static int rt73usb_probe_hw(struct rt2x00_dev *rt2x00dev) | 2174 | static int rt73usb_probe_hw(struct rt2x00_dev *rt2x00dev) |
@@ -2186,7 +2189,9 @@ static int rt73usb_probe_hw(struct rt2x00_dev *rt2x00dev) | |||
2186 | /* | 2189 | /* |
2187 | * Initialize hw specifications. | 2190 | * Initialize hw specifications. |
2188 | */ | 2191 | */ |
2189 | rt73usb_probe_hw_mode(rt2x00dev); | 2192 | retval = rt73usb_probe_hw_mode(rt2x00dev); |
2193 | if (retval) | ||
2194 | return retval; | ||
2190 | 2195 | ||
2191 | /* | 2196 | /* |
2192 | * This device requires firmware. | 2197 | * This device requires firmware. |