aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt2400pci.c
diff options
context:
space:
mode:
authorIvo van Doorn <ivdoorn@gmail.com>2008-12-20 04:54:22 -0500
committerJohn W. Linville <linville@tuxdriver.com>2009-01-29 15:58:34 -0500
commiteb20b4e8a6998ca68d9ac0963ee36a1a36fe241d (patch)
treecf35161f1f7573f73b9e2da74fc562a77169e459 /drivers/net/wireless/rt2x00/rt2400pci.c
parent84e3196ff867c623056eea02c11a45e046490d89 (diff)
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/rt2400pci.c')
-rw-r--r--drivers/net/wireless/rt2x00/rt2400pci.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2400pci.c b/drivers/net/wireless/rt2x00/rt2400pci.c
index 1afba42cc128..e87ad43e8e8d 100644
--- a/drivers/net/wireless/rt2x00/rt2400pci.c
+++ b/drivers/net/wireless/rt2x00/rt2400pci.c
@@ -600,35 +600,36 @@ static void rt2400pci_link_stats(struct rt2x00_dev *rt2x00dev,
600 qual->false_cca = bbp; 600 qual->false_cca = bbp;
601} 601}
602 602
603static inline void rt2400pci_set_vgc(struct rt2x00_dev *rt2x00dev, u8 vgc_level)
604{
605 rt2400pci_bbp_write(rt2x00dev, 13, vgc_level);
606 rt2x00dev->link.vgc_level = vgc_level;
607 rt2x00dev->link.vgc_level_reg = vgc_level;
608}
609
603static void rt2400pci_reset_tuner(struct rt2x00_dev *rt2x00dev) 610static void rt2400pci_reset_tuner(struct rt2x00_dev *rt2x00dev)
604{ 611{
605 rt2400pci_bbp_write(rt2x00dev, 13, 0x08); 612 rt2400pci_set_vgc(rt2x00dev, 0x08);
606 rt2x00dev->link.vgc_level = 0x08;
607} 613}
608 614
609static void rt2400pci_link_tuner(struct rt2x00_dev *rt2x00dev) 615static void rt2400pci_link_tuner(struct rt2x00_dev *rt2x00dev)
610{ 616{
611 u8 reg; 617 struct link *link = &rt2x00dev->link;
612 618
613 /* 619 /*
614 * The link tuner should not run longer then 60 seconds, 620 * The link tuner should not run longer then 60 seconds,
615 * and should run once every 2 seconds. 621 * and should run once every 2 seconds.
616 */ 622 */
617 if (rt2x00dev->link.count > 60 || !(rt2x00dev->link.count & 1)) 623 if (link->count > 60 || !(link->count & 1))
618 return; 624 return;
619 625
620 /* 626 /*
621 * Base r13 link tuning on the false cca count. 627 * Base r13 link tuning on the false cca count.
622 */ 628 */
623 rt2400pci_bbp_read(rt2x00dev, 13, &reg); 629 if ((link->qual.false_cca > 512) && (link->vgc_level < 0x20))
624 630 rt2400pci_set_vgc(rt2x00dev, ++link->vgc_level);
625 if (rt2x00dev->link.qual.false_cca > 512 && reg < 0x20) { 631 else if ((link->qual.false_cca < 100) && (link->vgc_level > 0x08))
626 rt2400pci_bbp_write(rt2x00dev, 13, ++reg); 632 rt2400pci_set_vgc(rt2x00dev, --link->vgc_level);
627 rt2x00dev->link.vgc_level = reg;
628 } else if (rt2x00dev->link.qual.false_cca < 100 && reg > 0x08) {
629 rt2400pci_bbp_write(rt2x00dev, 13, --reg);
630 rt2x00dev->link.vgc_level = reg;
631 }
632} 633}
633 634
634/* 635/*