summaryrefslogtreecommitdiff
path: root/drivers/net/wireless/rt2x00/rt61pci.c
diff options
context:
space:
mode:
authorIvo van Doorn <ivdoorn@gmail.com>2008-12-20 10:54:22 +0100
committerJohn W. Linville <linville@tuxdriver.com>2009-01-29 15:58:34 -0500
commiteb20b4e8a6998ca68d9ac0963ee36a1a36fe241d (patch)
treecf35161f1f7573f73b9e2da74fc562a77169e459 /drivers/net/wireless/rt2x00/rt61pci.c
parent84e3196ff867c623056eea02c11a45e046490d89 (diff)
downloadlwn-eb20b4e8a6998ca68d9ac0963ee36a1a36fe241d.tar.gz
lwn-eb20b4e8a6998ca68d9ac0963ee36a1a36fe241d.zip
rt2x00: Reduce calls to bbp_read()
The link_tuner() function will always call bbp_read() at the start of the function. Because this is an indirect register access has some costs attached to it (especially for USB hardware). We already store the value read from the register into the vgc_level value inside the link structure. Instead of reading from the register we can read that field directly and base the tuner on that value. This reduces the time the registers are locked with the csr_mutex and speeds up the link_tuner processing. 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.c49
1 files changed, 22 insertions, 27 deletions
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c
index c7ab744f0052..94523f7f0d88 100644
--- a/drivers/net/wireless/rt2x00/rt61pci.c
+++ b/drivers/net/wireless/rt2x00/rt61pci.c
@@ -1046,21 +1046,27 @@ static void rt61pci_link_stats(struct rt2x00_dev *rt2x00dev,
qual->false_cca = rt2x00_get_field32(reg, STA_CSR1_FALSE_CCA_ERROR);
}
+static inline void rt61pci_set_vgc(struct rt2x00_dev *rt2x00dev, u8 vgc_level)
+{
+ if (rt2x00dev->link.vgc_level != vgc_level) {
+ rt61pci_bbp_write(rt2x00dev, 17, vgc_level);
+ rt2x00dev->link.vgc_level = vgc_level;
+ rt2x00dev->link.vgc_level_reg = vgc_level;
+ }
+}
+
static void rt61pci_reset_tuner(struct rt2x00_dev *rt2x00dev)
{
- rt61pci_bbp_write(rt2x00dev, 17, 0x20);
- rt2x00dev->link.vgc_level = 0x20;
+ rt61pci_set_vgc(rt2x00dev, 0x20);
}
static void rt61pci_link_tuner(struct rt2x00_dev *rt2x00dev)
{
- int rssi = rt2x00_get_link_rssi(&rt2x00dev->link);
- u8 r17;
+ struct link *link = &rt2x00dev->link;
+ int rssi = rt2x00_get_link_rssi(link);
u8 up_bound;
u8 low_bound;
- rt61pci_bbp_read(rt2x00dev, 17, &r17);
-
/*
* Determine r17 bounds.
*/
@@ -1091,8 +1097,7 @@ static void rt61pci_link_tuner(struct rt2x00_dev *rt2x00dev)
* Special big-R17 for very short distance
*/
if (rssi >= -35) {
- if (r17 != 0x60)
- rt61pci_bbp_write(rt2x00dev, 17, 0x60);
+ rt61pci_set_vgc(rt2x00dev, 0x60);
return;
}
@@ -1100,8 +1105,7 @@ static void rt61pci_link_tuner(struct rt2x00_dev *rt2x00dev)
* Special big-R17 for short distance
*/
if (rssi >= -58) {
- if (r17 != up_bound)
- rt61pci_bbp_write(rt2x00dev, 17, up_bound);
+ rt61pci_set_vgc(rt2x00dev, up_bound);
return;
}
@@ -1109,9 +1113,7 @@ static void rt61pci_link_tuner(struct rt2x00_dev *rt2x00dev)
* Special big-R17 for middle-short distance
*/
if (rssi >= -66) {
- low_bound += 0x10;
- if (r17 != low_bound)
- rt61pci_bbp_write(rt2x00dev, 17, low_bound);
+ rt61pci_set_vgc(rt2x00dev, low_bound + 0x10);
return;
}
@@ -1119,9 +1121,7 @@ static void rt61pci_link_tuner(struct rt2x00_dev *rt2x00dev)
* Special mid-R17 for middle distance
*/
if (rssi >= -74) {
- low_bound += 0x08;
- if (r17 != low_bound)
- rt61pci_bbp_write(rt2x00dev, 17, low_bound);
+ rt61pci_set_vgc(rt2x00dev, low_bound + 0x08);
return;
}
@@ -1133,8 +1133,8 @@ static void rt61pci_link_tuner(struct rt2x00_dev *rt2x00dev)
if (low_bound > up_bound)
up_bound = low_bound;
- if (r17 > up_bound) {
- rt61pci_bbp_write(rt2x00dev, 17, up_bound);
+ if (link->vgc_level > up_bound) {
+ rt61pci_set_vgc(rt2x00dev, up_bound);
return;
}
@@ -1144,15 +1144,10 @@ dynamic_cca_tune:
* r17 does not yet exceed upper limit, continue and base
* the r17 tuning on the false CCA count.
*/
- if (rt2x00dev->link.qual.false_cca > 512 && r17 < up_bound) {
- if (++r17 > up_bound)
- r17 = up_bound;
- rt61pci_bbp_write(rt2x00dev, 17, r17);
- } else if (rt2x00dev->link.qual.false_cca < 100 && r17 > low_bound) {
- if (--r17 < low_bound)
- r17 = low_bound;
- rt61pci_bbp_write(rt2x00dev, 17, r17);
- }
+ if ((link->qual.false_cca > 512) && (link->vgc_level < up_bound))
+ rt61pci_set_vgc(rt2x00dev, ++link->vgc_level);
+ else if ((link->qual.false_cca < 100) && (link->vgc_level > low_bound))
+ rt61pci_set_vgc(rt2x00dev, --link->vgc_level);
}
/*