diff options
author | Ivo van Doorn <ivdoorn@gmail.com> | 2008-12-20 04:54:54 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-01-29 15:58:35 -0500 |
commit | 5352ff6510422d9a9bf13b7272f865eb53247f4d (patch) | |
tree | ec85fd9933b3d79cf4ae844c36f0803168203f06 /drivers/net/wireless/rt2x00/rt73usb.c | |
parent | eb20b4e8a6998ca68d9ac0963ee36a1a36fe241d (diff) |
rt2x00: Restrict interface between rt2x00link and drivers
Restrict drivers to only access link_qual structure during
link tuning. The contents of these fields are for the drivers
and all fields are allowed to be changed to values the driver
considers correct.
This means that some fields need to be moved outside of this
structure to restrict access only to rt2x00link itself.
This allows some code to be moved outside of the rt2x00.h header
and into rt2x00link.c.
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 | 57 |
1 files changed, 29 insertions, 28 deletions
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c index b5443148d621..e99bcacfc191 100644 --- a/drivers/net/wireless/rt2x00/rt73usb.c +++ b/drivers/net/wireless/rt2x00/rt73usb.c | |||
@@ -924,24 +924,25 @@ static void rt73usb_link_stats(struct rt2x00_dev *rt2x00dev, | |||
924 | qual->false_cca = rt2x00_get_field32(reg, STA_CSR1_FALSE_CCA_ERROR); | 924 | qual->false_cca = rt2x00_get_field32(reg, STA_CSR1_FALSE_CCA_ERROR); |
925 | } | 925 | } |
926 | 926 | ||
927 | static inline void rt73usb_set_vgc(struct rt2x00_dev *rt2x00dev, u8 vgc_level) | 927 | static inline void rt73usb_set_vgc(struct rt2x00_dev *rt2x00dev, |
928 | struct link_qual *qual, u8 vgc_level) | ||
928 | { | 929 | { |
929 | if (rt2x00dev->link.vgc_level != vgc_level) { | 930 | if (qual->vgc_level != vgc_level) { |
930 | rt73usb_bbp_write(rt2x00dev, 17, vgc_level); | 931 | rt73usb_bbp_write(rt2x00dev, 17, vgc_level); |
931 | rt2x00dev->link.vgc_level = vgc_level; | 932 | qual->vgc_level = vgc_level; |
932 | rt2x00dev->link.vgc_level_reg = vgc_level; | 933 | qual->vgc_level_reg = vgc_level; |
933 | } | 934 | } |
934 | } | 935 | } |
935 | 936 | ||
936 | static void rt73usb_reset_tuner(struct rt2x00_dev *rt2x00dev) | 937 | static void rt73usb_reset_tuner(struct rt2x00_dev *rt2x00dev, |
938 | struct link_qual *qual) | ||
937 | { | 939 | { |
938 | rt73usb_set_vgc(rt2x00dev, 0x20); | 940 | rt73usb_set_vgc(rt2x00dev, qual, 0x20); |
939 | } | 941 | } |
940 | 942 | ||
941 | static void rt73usb_link_tuner(struct rt2x00_dev *rt2x00dev) | 943 | static void rt73usb_link_tuner(struct rt2x00_dev *rt2x00dev, |
944 | struct link_qual *qual, const u32 count) | ||
942 | { | 945 | { |
943 | struct link *link = &rt2x00dev->link; | ||
944 | int rssi = rt2x00_get_link_rssi(link); | ||
945 | u8 up_bound; | 946 | u8 up_bound; |
946 | u8 low_bound; | 947 | u8 low_bound; |
947 | 948 | ||
@@ -957,10 +958,10 @@ static void rt73usb_link_tuner(struct rt2x00_dev *rt2x00dev) | |||
957 | up_bound += 0x10; | 958 | up_bound += 0x10; |
958 | } | 959 | } |
959 | } else { | 960 | } else { |
960 | if (rssi > -82) { | 961 | if (qual->rssi > -82) { |
961 | low_bound = 0x1c; | 962 | low_bound = 0x1c; |
962 | up_bound = 0x40; | 963 | up_bound = 0x40; |
963 | } else if (rssi > -84) { | 964 | } else if (qual->rssi > -84) { |
964 | low_bound = 0x1c; | 965 | low_bound = 0x1c; |
965 | up_bound = 0x20; | 966 | up_bound = 0x20; |
966 | } else { | 967 | } else { |
@@ -984,32 +985,32 @@ static void rt73usb_link_tuner(struct rt2x00_dev *rt2x00dev) | |||
984 | /* | 985 | /* |
985 | * Special big-R17 for very short distance | 986 | * Special big-R17 for very short distance |
986 | */ | 987 | */ |
987 | if (rssi > -35) { | 988 | if (qual->rssi > -35) { |
988 | rt73usb_set_vgc(rt2x00dev, 0x60); | 989 | rt73usb_set_vgc(rt2x00dev, qual, 0x60); |
989 | return; | 990 | return; |
990 | } | 991 | } |
991 | 992 | ||
992 | /* | 993 | /* |
993 | * Special big-R17 for short distance | 994 | * Special big-R17 for short distance |
994 | */ | 995 | */ |
995 | if (rssi >= -58) { | 996 | if (qual->rssi >= -58) { |
996 | rt73usb_set_vgc(rt2x00dev, up_bound); | 997 | rt73usb_set_vgc(rt2x00dev, qual, up_bound); |
997 | return; | 998 | return; |
998 | } | 999 | } |
999 | 1000 | ||
1000 | /* | 1001 | /* |
1001 | * Special big-R17 for middle-short distance | 1002 | * Special big-R17 for middle-short distance |
1002 | */ | 1003 | */ |
1003 | if (rssi >= -66) { | 1004 | if (qual->rssi >= -66) { |
1004 | rt73usb_set_vgc(rt2x00dev, low_bound + 0x10); | 1005 | rt73usb_set_vgc(rt2x00dev, qual, low_bound + 0x10); |
1005 | return; | 1006 | return; |
1006 | } | 1007 | } |
1007 | 1008 | ||
1008 | /* | 1009 | /* |
1009 | * Special mid-R17 for middle distance | 1010 | * Special mid-R17 for middle distance |
1010 | */ | 1011 | */ |
1011 | if (rssi >= -74) { | 1012 | if (qual->rssi >= -74) { |
1012 | rt73usb_set_vgc(rt2x00dev, low_bound + 0x08); | 1013 | rt73usb_set_vgc(rt2x00dev, qual, low_bound + 0x08); |
1013 | return; | 1014 | return; |
1014 | } | 1015 | } |
1015 | 1016 | ||
@@ -1017,12 +1018,12 @@ static void rt73usb_link_tuner(struct rt2x00_dev *rt2x00dev) | |||
1017 | * Special case: Change up_bound based on the rssi. | 1018 | * Special case: Change up_bound based on the rssi. |
1018 | * Lower up_bound when rssi is weaker then -74 dBm. | 1019 | * Lower up_bound when rssi is weaker then -74 dBm. |
1019 | */ | 1020 | */ |
1020 | up_bound -= 2 * (-74 - rssi); | 1021 | up_bound -= 2 * (-74 - qual->rssi); |
1021 | if (low_bound > up_bound) | 1022 | if (low_bound > up_bound) |
1022 | up_bound = low_bound; | 1023 | up_bound = low_bound; |
1023 | 1024 | ||
1024 | if (link->vgc_level > up_bound) { | 1025 | if (qual->vgc_level > up_bound) { |
1025 | rt73usb_set_vgc(rt2x00dev, up_bound); | 1026 | rt73usb_set_vgc(rt2x00dev, qual, up_bound); |
1026 | return; | 1027 | return; |
1027 | } | 1028 | } |
1028 | 1029 | ||
@@ -1032,12 +1033,12 @@ dynamic_cca_tune: | |||
1032 | * r17 does not yet exceed upper limit, continue and base | 1033 | * r17 does not yet exceed upper limit, continue and base |
1033 | * the r17 tuning on the false CCA count. | 1034 | * the r17 tuning on the false CCA count. |
1034 | */ | 1035 | */ |
1035 | if ((link->qual.false_cca > 512) && (link->vgc_level < up_bound)) | 1036 | if ((qual->false_cca > 512) && (qual->vgc_level < up_bound)) |
1036 | rt73usb_set_vgc(rt2x00dev, | 1037 | rt73usb_set_vgc(rt2x00dev, qual, |
1037 | min_t(u8, link->vgc_level + 4, up_bound)); | 1038 | min_t(u8, qual->vgc_level + 4, up_bound)); |
1038 | else if ((link->qual.false_cca < 100) && (link->vgc_level > low_bound)) | 1039 | else if ((qual->false_cca < 100) && (qual->vgc_level > low_bound)) |
1039 | rt73usb_set_vgc(rt2x00dev, | 1040 | rt73usb_set_vgc(rt2x00dev, qual, |
1040 | max_t(u8, link->vgc_level - 4, low_bound)); | 1041 | max_t(u8, qual->vgc_level - 4, low_bound)); |
1041 | } | 1042 | } |
1042 | 1043 | ||
1043 | /* | 1044 | /* |