aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt2x00dev.c
diff options
context:
space:
mode:
authorIvo van Doorn <ivdoorn@gmail.com>2008-02-17 11:35:05 -0500
committerJohn W. Linville <linville@tuxdriver.com>2008-02-29 15:37:23 -0500
commit31562e802a72caf0757f351fff563d558d48d087 (patch)
treeac2875b80508ab156dd3ef0302673530ca058bf8 /drivers/net/wireless/rt2x00/rt2x00dev.c
parentde99ff82cdc2e5b596d01000eed9e0d05566f2d7 (diff)
rt2x00: Cleanup mode registration
Don't wildly pass any number for num_rates to rt2x00lib, instead pass which type of rates are supported (CCK, OFDM). Same for num_modes but then for the 2GHZ and 5GHZ band. This makes the interface look much nicer and makes extending it later easier. 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/rt2x00dev.c')
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00dev.c80
1 files changed, 40 insertions, 40 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index 6ccbfc7cbf91..a644b9a7ca8f 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -767,25 +767,25 @@ EXPORT_SYMBOL_GPL(rt2x00lib_write_tx_desc);
767 */ 767 */
768const struct rt2x00_rate rt2x00_supported_rates[12] = { 768const struct rt2x00_rate rt2x00_supported_rates[12] = {
769 { 769 {
770 .flags = 0, 770 .flags = DEV_RATE_CCK,
771 .bitrate = 10, 771 .bitrate = 10,
772 .ratemask = DEV_RATEMASK_1MB, 772 .ratemask = DEV_RATEMASK_1MB,
773 .plcp = 0x00, 773 .plcp = 0x00,
774 }, 774 },
775 { 775 {
776 .flags = DEV_RATE_SHORT_PREAMBLE, 776 .flags = DEV_RATE_CCK | DEV_RATE_SHORT_PREAMBLE,
777 .bitrate = 20, 777 .bitrate = 20,
778 .ratemask = DEV_RATEMASK_2MB, 778 .ratemask = DEV_RATEMASK_2MB,
779 .plcp = 0x01, 779 .plcp = 0x01,
780 }, 780 },
781 { 781 {
782 .flags = DEV_RATE_SHORT_PREAMBLE, 782 .flags = DEV_RATE_CCK | DEV_RATE_SHORT_PREAMBLE,
783 .bitrate = 55, 783 .bitrate = 55,
784 .ratemask = DEV_RATEMASK_5_5MB, 784 .ratemask = DEV_RATEMASK_5_5MB,
785 .plcp = 0x02, 785 .plcp = 0x02,
786 }, 786 },
787 { 787 {
788 .flags = DEV_RATE_SHORT_PREAMBLE, 788 .flags = DEV_RATE_CCK | DEV_RATE_SHORT_PREAMBLE,
789 .bitrate = 110, 789 .bitrate = 110,
790 .ratemask = DEV_RATEMASK_11MB, 790 .ratemask = DEV_RATEMASK_11MB,
791 .plcp = 0x03, 791 .plcp = 0x03,
@@ -868,67 +868,64 @@ static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev,
868 struct hw_mode_spec *spec) 868 struct hw_mode_spec *spec)
869{ 869{
870 struct ieee80211_hw *hw = rt2x00dev->hw; 870 struct ieee80211_hw *hw = rt2x00dev->hw;
871 struct ieee80211_supported_band *sbands;
872 struct ieee80211_channel *channels; 871 struct ieee80211_channel *channels;
873 struct ieee80211_rate *rates; 872 struct ieee80211_rate *rates;
873 unsigned int num_rates;
874 unsigned int i; 874 unsigned int i;
875 unsigned char tx_power; 875 unsigned char tx_power;
876 876
877 sbands = &rt2x00dev->bands[0]; 877 num_rates = 0;
878 if (spec->supported_rates & SUPPORT_RATE_CCK)
879 num_rates += 4;
880 if (spec->supported_rates & SUPPORT_RATE_OFDM)
881 num_rates += 8;
878 882
879 channels = kzalloc(sizeof(*channels) * spec->num_channels, GFP_KERNEL); 883 channels = kzalloc(sizeof(*channels) * spec->num_channels, GFP_KERNEL);
880 if (!channels) 884 if (!channels)
881 return -ENOMEM; 885 return -ENOMEM;
882 886
883 rates = kzalloc(sizeof(*rates) * spec->num_rates, GFP_KERNEL); 887 rates = kzalloc(sizeof(*rates) * num_rates, GFP_KERNEL);
884 if (!rates) 888 if (!rates)
885 goto exit_free_channels; 889 goto exit_free_channels;
886 890
887 /* 891 /*
888 * Initialize Rate list. 892 * Initialize Rate list.
889 */ 893 */
890 for (i = 0; i < spec->num_rates; i++) 894 for (i = 0; i < num_rates; i++)
891 rt2x00lib_rate(&rates[i], i, rt2x00_get_rate(i)); 895 rt2x00lib_rate(&rates[i], i, rt2x00_get_rate(i));
892 896
893 /* 897 /*
894 * Initialize Channel list. 898 * Initialize Channel list.
895 */ 899 */
896 for (i = 0; i < spec->num_channels; i++) { 900 for (i = 0; i < spec->num_channels; i++) {
897 if (spec->channels[i].channel <= 14) 901 if (spec->channels[i].channel <= 14) {
898 tx_power = spec->tx_power_bg[i]; 902 if (spec->tx_power_bg)
899 else if (spec->tx_power_a) 903 tx_power = spec->tx_power_bg[i];
900 tx_power = spec->tx_power_a[i]; 904 else
901 else 905 tx_power = spec->tx_power_default;
902 tx_power = spec->tx_power_default; 906 } else {
907 if (spec->tx_power_a)
908 tx_power = spec->tx_power_a[i];
909 else
910 tx_power = spec->tx_power_default;
911 }
903 912
904 rt2x00lib_channel(&channels[i], 913 rt2x00lib_channel(&channels[i],
905 spec->channels[i].channel, tx_power, i); 914 spec->channels[i].channel, tx_power, i);
906 } 915 }
907 916
908 /* 917 /*
909 * Intitialize 802.11b 918 * Intitialize 802.11b, 802.11g
910 * Rates: CCK.
911 * Channels: 2.4 GHz
912 */
913 if (spec->num_modes > 0) {
914 sbands[IEEE80211_BAND_2GHZ].n_channels = 14;
915 sbands[IEEE80211_BAND_2GHZ].n_bitrates = 4;
916 sbands[IEEE80211_BAND_2GHZ].channels = channels;
917 sbands[IEEE80211_BAND_2GHZ].bitrates = rates;
918 hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &rt2x00dev->bands[IEEE80211_BAND_2GHZ];
919 }
920
921 /*
922 * Intitialize 802.11g
923 * Rates: CCK, OFDM. 919 * Rates: CCK, OFDM.
924 * Channels: 2.4 GHz 920 * Channels: 2.4 GHz
925 */ 921 */
926 if (spec->num_modes > 1) { 922 if (spec->supported_bands > SUPPORT_BAND_2GHZ) {
927 sbands[IEEE80211_BAND_2GHZ].n_channels = 14; 923 rt2x00dev->bands[IEEE80211_BAND_2GHZ].n_channels = 14;
928 sbands[IEEE80211_BAND_2GHZ].n_bitrates = spec->num_rates; 924 rt2x00dev->bands[IEEE80211_BAND_2GHZ].n_bitrates = num_rates;
929 sbands[IEEE80211_BAND_2GHZ].channels = channels; 925 rt2x00dev->bands[IEEE80211_BAND_2GHZ].channels = channels;
930 sbands[IEEE80211_BAND_2GHZ].bitrates = rates; 926 rt2x00dev->bands[IEEE80211_BAND_2GHZ].bitrates = rates;
931 hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &rt2x00dev->bands[IEEE80211_BAND_2GHZ]; 927 hw->wiphy->bands[IEEE80211_BAND_2GHZ] =
928 &rt2x00dev->bands[IEEE80211_BAND_2GHZ];
932 } 929 }
933 930
934 /* 931 /*
@@ -936,12 +933,15 @@ static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev,
936 * Rates: OFDM. 933 * Rates: OFDM.
937 * Channels: OFDM, UNII, HiperLAN2. 934 * Channels: OFDM, UNII, HiperLAN2.
938 */ 935 */
939 if (spec->num_modes > 2) { 936 if (spec->supported_bands > SUPPORT_BAND_5GHZ) {
940 sbands[IEEE80211_BAND_5GHZ].n_channels = spec->num_channels - 14; 937 rt2x00dev->bands[IEEE80211_BAND_5GHZ].n_channels =
941 sbands[IEEE80211_BAND_5GHZ].n_bitrates = spec->num_rates - 4; 938 spec->num_channels - 14;
942 sbands[IEEE80211_BAND_5GHZ].channels = &channels[14]; 939 rt2x00dev->bands[IEEE80211_BAND_5GHZ].n_bitrates =
943 sbands[IEEE80211_BAND_5GHZ].bitrates = &rates[4]; 940 num_rates - 4;
944 hw->wiphy->bands[IEEE80211_BAND_5GHZ] = &rt2x00dev->bands[IEEE80211_BAND_5GHZ]; 941 rt2x00dev->bands[IEEE80211_BAND_5GHZ].channels = &channels[14];
942 rt2x00dev->bands[IEEE80211_BAND_5GHZ].bitrates = &rates[4];
943 hw->wiphy->bands[IEEE80211_BAND_5GHZ] =
944 &rt2x00dev->bands[IEEE80211_BAND_5GHZ];
945 } 945 }
946 946
947 return 0; 947 return 0;