aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvo van Doorn <ivdoorn@gmail.com>2010-07-11 06:25:17 -0400
committerJohn W. Linville <linville@tuxdriver.com>2010-07-12 16:05:33 -0400
commit223dcc26591aa8e4a6bf623164b775b5bd89c9e1 (patch)
treec9d3da2954fe84248437434cbbc9c0d53490d22a
parentd8147f9d9ed6abfa105234a21f05af4a4839eb80 (diff)
rt2x00: Fix vgc_level_reg handling
Currently vgc_level_reg and vgc_level are equal to eachother, while the purpose of vgc_level_reg is the value last written to the register and is remembered through link tuning resets. The vgc_level is the currently active level, which is reset during link tuning resets. The usage of these variables depends on the drivers, some drivers need both, while others need only one of the two. Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/rt2x00/rt2400pci.c8
-rw-r--r--drivers/net/wireless/rt2x00/rt2500pci.c8
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00link.c8
3 files changed, 16 insertions, 8 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2400pci.c b/drivers/net/wireless/rt2x00/rt2400pci.c
index d5f1fabe9faf..25e9dcf65c4e 100644
--- a/drivers/net/wireless/rt2x00/rt2400pci.c
+++ b/drivers/net/wireless/rt2x00/rt2400pci.c
@@ -586,9 +586,11 @@ static void rt2400pci_link_stats(struct rt2x00_dev *rt2x00dev,
586static inline void rt2400pci_set_vgc(struct rt2x00_dev *rt2x00dev, 586static inline void rt2400pci_set_vgc(struct rt2x00_dev *rt2x00dev,
587 struct link_qual *qual, u8 vgc_level) 587 struct link_qual *qual, u8 vgc_level)
588{ 588{
589 rt2400pci_bbp_write(rt2x00dev, 13, vgc_level); 589 if (qual->vgc_level_reg != vgc_level) {
590 qual->vgc_level = vgc_level; 590 rt2400pci_bbp_write(rt2x00dev, 13, vgc_level);
591 qual->vgc_level_reg = vgc_level; 591 qual->vgc_level = vgc_level;
592 qual->vgc_level_reg = vgc_level;
593 }
592} 594}
593 595
594static void rt2400pci_reset_tuner(struct rt2x00_dev *rt2x00dev, 596static void rt2400pci_reset_tuner(struct rt2x00_dev *rt2x00dev,
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c b/drivers/net/wireless/rt2x00/rt2500pci.c
index 096d6dbc8305..faa804cf181a 100644
--- a/drivers/net/wireless/rt2x00/rt2500pci.c
+++ b/drivers/net/wireless/rt2x00/rt2500pci.c
@@ -626,6 +626,7 @@ static inline void rt2500pci_set_vgc(struct rt2x00_dev *rt2x00dev,
626{ 626{
627 if (qual->vgc_level_reg != vgc_level) { 627 if (qual->vgc_level_reg != vgc_level) {
628 rt2500pci_bbp_write(rt2x00dev, 17, vgc_level); 628 rt2500pci_bbp_write(rt2x00dev, 17, vgc_level);
629 qual->vgc_level = vgc_level;
629 qual->vgc_level_reg = vgc_level; 630 qual->vgc_level_reg = vgc_level;
630 } 631 }
631} 632}
@@ -700,13 +701,10 @@ dynamic_cca_tune:
700 * R17 is inside the dynamic tuning range, 701 * R17 is inside the dynamic tuning range,
701 * start tuning the link based on the false cca counter. 702 * start tuning the link based on the false cca counter.
702 */ 703 */
703 if (qual->false_cca > 512 && qual->vgc_level_reg < 0x40) { 704 if (qual->false_cca > 512 && qual->vgc_level_reg < 0x40)
704 rt2500pci_set_vgc(rt2x00dev, qual, ++qual->vgc_level_reg); 705 rt2500pci_set_vgc(rt2x00dev, qual, ++qual->vgc_level_reg);
705 qual->vgc_level = qual->vgc_level_reg; 706 else if (qual->false_cca < 100 && qual->vgc_level_reg > 0x32)
706 } else if (qual->false_cca < 100 && qual->vgc_level_reg > 0x32) {
707 rt2500pci_set_vgc(rt2x00dev, qual, --qual->vgc_level_reg); 707 rt2500pci_set_vgc(rt2x00dev, qual, --qual->vgc_level_reg);
708 qual->vgc_level = qual->vgc_level_reg;
709 }
710} 708}
711 709
712/* 710/*
diff --git a/drivers/net/wireless/rt2x00/rt2x00link.c b/drivers/net/wireless/rt2x00/rt2x00link.c
index 14f1d5126289..9acfc5c70389 100644
--- a/drivers/net/wireless/rt2x00/rt2x00link.c
+++ b/drivers/net/wireless/rt2x00/rt2x00link.c
@@ -302,6 +302,7 @@ void rt2x00link_stop_tuner(struct rt2x00_dev *rt2x00dev)
302void rt2x00link_reset_tuner(struct rt2x00_dev *rt2x00dev, bool antenna) 302void rt2x00link_reset_tuner(struct rt2x00_dev *rt2x00dev, bool antenna)
303{ 303{
304 struct link_qual *qual = &rt2x00dev->link.qual; 304 struct link_qual *qual = &rt2x00dev->link.qual;
305 u8 vgc_level = qual->vgc_level_reg;
305 306
306 if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags)) 307 if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
307 return; 308 return;
@@ -318,6 +319,13 @@ void rt2x00link_reset_tuner(struct rt2x00_dev *rt2x00dev, bool antenna)
318 memset(qual, 0, sizeof(*qual)); 319 memset(qual, 0, sizeof(*qual));
319 320
320 /* 321 /*
322 * Restore the VGC level as stored in the registers,
323 * the driver can use this to determine if the register
324 * must be updated during reset or not.
325 */
326 qual->vgc_level_reg = vgc_level;
327
328 /*
321 * Reset the link tuner. 329 * Reset the link tuner.
322 */ 330 */
323 rt2x00dev->ops->lib->reset_tuner(rt2x00dev, qual); 331 rt2x00dev->ops->lib->reset_tuner(rt2x00dev, qual);