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/rt61pci.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/rt61pci.c')
-rw-r--r-- | drivers/net/wireless/rt2x00/rt61pci.c | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c index 94523f7f0d88..ed829879c941 100644 --- a/drivers/net/wireless/rt2x00/rt61pci.c +++ b/drivers/net/wireless/rt2x00/rt61pci.c | |||
@@ -1046,24 +1046,25 @@ static void rt61pci_link_stats(struct rt2x00_dev *rt2x00dev, | |||
1046 | qual->false_cca = rt2x00_get_field32(reg, STA_CSR1_FALSE_CCA_ERROR); | 1046 | qual->false_cca = rt2x00_get_field32(reg, STA_CSR1_FALSE_CCA_ERROR); |
1047 | } | 1047 | } |
1048 | 1048 | ||
1049 | static inline void rt61pci_set_vgc(struct rt2x00_dev *rt2x00dev, u8 vgc_level) | 1049 | static inline void rt61pci_set_vgc(struct rt2x00_dev *rt2x00dev, |
1050 | struct link_qual *qual, u8 vgc_level) | ||
1050 | { | 1051 | { |
1051 | if (rt2x00dev->link.vgc_level != vgc_level) { | 1052 | if (qual->vgc_level != vgc_level) { |
1052 | rt61pci_bbp_write(rt2x00dev, 17, vgc_level); | 1053 | rt61pci_bbp_write(rt2x00dev, 17, vgc_level); |
1053 | rt2x00dev->link.vgc_level = vgc_level; | 1054 | qual->vgc_level = vgc_level; |
1054 | rt2x00dev->link.vgc_level_reg = vgc_level; | 1055 | qual->vgc_level_reg = vgc_level; |
1055 | } | 1056 | } |
1056 | } | 1057 | } |
1057 | 1058 | ||
1058 | static void rt61pci_reset_tuner(struct rt2x00_dev *rt2x00dev) | 1059 | static void rt61pci_reset_tuner(struct rt2x00_dev *rt2x00dev, |
1060 | struct link_qual *qual) | ||
1059 | { | 1061 | { |
1060 | rt61pci_set_vgc(rt2x00dev, 0x20); | 1062 | rt61pci_set_vgc(rt2x00dev, qual, 0x20); |
1061 | } | 1063 | } |
1062 | 1064 | ||
1063 | static void rt61pci_link_tuner(struct rt2x00_dev *rt2x00dev) | 1065 | static void rt61pci_link_tuner(struct rt2x00_dev *rt2x00dev, |
1066 | struct link_qual *qual, const u32 count) | ||
1064 | { | 1067 | { |
1065 | struct link *link = &rt2x00dev->link; | ||
1066 | int rssi = rt2x00_get_link_rssi(link); | ||
1067 | u8 up_bound; | 1068 | u8 up_bound; |
1068 | u8 low_bound; | 1069 | u8 low_bound; |
1069 | 1070 | ||
@@ -1096,32 +1097,32 @@ static void rt61pci_link_tuner(struct rt2x00_dev *rt2x00dev) | |||
1096 | /* | 1097 | /* |
1097 | * Special big-R17 for very short distance | 1098 | * Special big-R17 for very short distance |
1098 | */ | 1099 | */ |
1099 | if (rssi >= -35) { | 1100 | if (qual->rssi >= -35) { |
1100 | rt61pci_set_vgc(rt2x00dev, 0x60); | 1101 | rt61pci_set_vgc(rt2x00dev, qual, 0x60); |
1101 | return; | 1102 | return; |
1102 | } | 1103 | } |
1103 | 1104 | ||
1104 | /* | 1105 | /* |
1105 | * Special big-R17 for short distance | 1106 | * Special big-R17 for short distance |
1106 | */ | 1107 | */ |
1107 | if (rssi >= -58) { | 1108 | if (qual->rssi >= -58) { |
1108 | rt61pci_set_vgc(rt2x00dev, up_bound); | 1109 | rt61pci_set_vgc(rt2x00dev, qual, up_bound); |
1109 | return; | 1110 | return; |
1110 | } | 1111 | } |
1111 | 1112 | ||
1112 | /* | 1113 | /* |
1113 | * Special big-R17 for middle-short distance | 1114 | * Special big-R17 for middle-short distance |
1114 | */ | 1115 | */ |
1115 | if (rssi >= -66) { | 1116 | if (qual->rssi >= -66) { |
1116 | rt61pci_set_vgc(rt2x00dev, low_bound + 0x10); | 1117 | rt61pci_set_vgc(rt2x00dev, qual, low_bound + 0x10); |
1117 | return; | 1118 | return; |
1118 | } | 1119 | } |
1119 | 1120 | ||
1120 | /* | 1121 | /* |
1121 | * Special mid-R17 for middle distance | 1122 | * Special mid-R17 for middle distance |
1122 | */ | 1123 | */ |
1123 | if (rssi >= -74) { | 1124 | if (qual->rssi >= -74) { |
1124 | rt61pci_set_vgc(rt2x00dev, low_bound + 0x08); | 1125 | rt61pci_set_vgc(rt2x00dev, qual, low_bound + 0x08); |
1125 | return; | 1126 | return; |
1126 | } | 1127 | } |
1127 | 1128 | ||
@@ -1129,12 +1130,12 @@ static void rt61pci_link_tuner(struct rt2x00_dev *rt2x00dev) | |||
1129 | * Special case: Change up_bound based on the rssi. | 1130 | * Special case: Change up_bound based on the rssi. |
1130 | * Lower up_bound when rssi is weaker then -74 dBm. | 1131 | * Lower up_bound when rssi is weaker then -74 dBm. |
1131 | */ | 1132 | */ |
1132 | up_bound -= 2 * (-74 - rssi); | 1133 | up_bound -= 2 * (-74 - qual->rssi); |
1133 | if (low_bound > up_bound) | 1134 | if (low_bound > up_bound) |
1134 | up_bound = low_bound; | 1135 | up_bound = low_bound; |
1135 | 1136 | ||
1136 | if (link->vgc_level > up_bound) { | 1137 | if (qual->vgc_level > up_bound) { |
1137 | rt61pci_set_vgc(rt2x00dev, up_bound); | 1138 | rt61pci_set_vgc(rt2x00dev, qual, up_bound); |
1138 | return; | 1139 | return; |
1139 | } | 1140 | } |
1140 | 1141 | ||
@@ -1144,10 +1145,10 @@ dynamic_cca_tune: | |||
1144 | * r17 does not yet exceed upper limit, continue and base | 1145 | * r17 does not yet exceed upper limit, continue and base |
1145 | * the r17 tuning on the false CCA count. | 1146 | * the r17 tuning on the false CCA count. |
1146 | */ | 1147 | */ |
1147 | if ((link->qual.false_cca > 512) && (link->vgc_level < up_bound)) | 1148 | if ((qual->false_cca > 512) && (qual->vgc_level < up_bound)) |
1148 | rt61pci_set_vgc(rt2x00dev, ++link->vgc_level); | 1149 | rt61pci_set_vgc(rt2x00dev, qual, ++qual->vgc_level); |
1149 | else if ((link->qual.false_cca < 100) && (link->vgc_level > low_bound)) | 1150 | else if ((qual->false_cca < 100) && (qual->vgc_level > low_bound)) |
1150 | rt61pci_set_vgc(rt2x00dev, --link->vgc_level); | 1151 | rt61pci_set_vgc(rt2x00dev, qual, --qual->vgc_level); |
1151 | } | 1152 | } |
1152 | 1153 | ||
1153 | /* | 1154 | /* |