aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt2500usb.c
diff options
context:
space:
mode:
authorIvo van Doorn <ivdoorn@gmail.com>2008-08-04 10:38:47 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-08-22 16:29:58 -0400
commit8c5e7a5f59f9d11597bd47de28334da318ea0e80 (patch)
tree46dc69607e8a196fd68b3b040b312bc1e7fc0559 /drivers/net/wireless/rt2x00/rt2500usb.c
parent906c110fcc24bdd5bf0fa22d89ac75d99c747e53 (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/rt2500usb.c')
-rw-r--r--drivers/net/wireless/rt2x00/rt2500usb.c39
1 files changed, 26 insertions, 13 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c
index cd5af656932d..3b90ed622148 100644
--- a/drivers/net/wireless/rt2x00/rt2500usb.c
+++ b/drivers/net/wireless/rt2x00/rt2500usb.c
@@ -1665,10 +1665,11 @@ static const struct rf_channel rf_vals_5222[] = {
1665 { 161, 0x00022020, 0x000090be, 0x00000101, 0x00000a07 }, 1665 { 161, 0x00022020, 0x000090be, 0x00000101, 0x00000a07 },
1666}; 1666};
1667 1667
1668static void rt2500usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev) 1668static int rt2500usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
1669{ 1669{
1670 struct hw_mode_spec *spec = &rt2x00dev->spec; 1670 struct hw_mode_spec *spec = &rt2x00dev->spec;
1671 u8 *txpower; 1671 struct channel_info *info;
1672 char *tx_power;
1672 unsigned int i; 1673 unsigned int i;
1673 1674
1674 /* 1675 /*
@@ -1687,20 +1688,10 @@ static void rt2500usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
1687 EEPROM_MAC_ADDR_0)); 1688 EEPROM_MAC_ADDR_0));
1688 1689
1689 /* 1690 /*
1690 * Convert tx_power array in eeprom.
1691 */
1692 txpower = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_START);
1693 for (i = 0; i < 14; i++)
1694 txpower[i] = TXPOWER_FROM_DEV(txpower[i]);
1695
1696 /*
1697 * Initialize hw_mode information. 1691 * Initialize hw_mode information.
1698 */ 1692 */
1699 spec->supported_bands = SUPPORT_BAND_2GHZ; 1693 spec->supported_bands = SUPPORT_BAND_2GHZ;
1700 spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM; 1694 spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM;
1701 spec->tx_power_a = NULL;
1702 spec->tx_power_bg = txpower;
1703 spec->tx_power_default = DEFAULT_TXPOWER;
1704 1695
1705 if (rt2x00_rf(&rt2x00dev->chip, RF2522)) { 1696 if (rt2x00_rf(&rt2x00dev->chip, RF2522)) {
1706 spec->num_channels = ARRAY_SIZE(rf_vals_bg_2522); 1697 spec->num_channels = ARRAY_SIZE(rf_vals_bg_2522);
@@ -1722,6 +1713,26 @@ static void rt2500usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
1722 spec->num_channels = ARRAY_SIZE(rf_vals_5222); 1713 spec->num_channels = ARRAY_SIZE(rf_vals_5222);
1723 spec->channels = rf_vals_5222; 1714 spec->channels = rf_vals_5222;
1724 } 1715 }
1716
1717 /*
1718 * Create channel information array
1719 */
1720 info = kzalloc(spec->num_channels * sizeof(*info), GFP_KERNEL);
1721 if (!info)
1722 return -ENOMEM;
1723
1724 spec->channels_info = info;
1725
1726 tx_power = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_START);
1727 for (i = 0; i < 14; i++)
1728 info[i].tx_power1 = TXPOWER_FROM_DEV(tx_power[i]);
1729
1730 if (spec->num_channels > 14) {
1731 for (i = 14; i < spec->num_channels; i++)
1732 info[i].tx_power1 = DEFAULT_TXPOWER;
1733 }
1734
1735 return 0;
1725} 1736}
1726 1737
1727static int rt2500usb_probe_hw(struct rt2x00_dev *rt2x00dev) 1738static int rt2500usb_probe_hw(struct rt2x00_dev *rt2x00dev)
@@ -1742,7 +1753,9 @@ static int rt2500usb_probe_hw(struct rt2x00_dev *rt2x00dev)
1742 /* 1753 /*
1743 * Initialize hw specifications. 1754 * Initialize hw specifications.
1744 */ 1755 */
1745 rt2500usb_probe_hw_mode(rt2x00dev); 1756 retval = rt2500usb_probe_hw_mode(rt2x00dev);
1757 if (retval)
1758 return retval;
1746 1759
1747 /* 1760 /*
1748 * This device requires the atim queue 1761 * This device requires the atim queue