- patches.fixes/0001-rt2x00-Remove-incorrect-led-blink.patch:
[opensuse:kernel-source.git] / patches.fixes / 0014-rt2800-introduce-wpdma_disable-function.patch
1 Subject: [PATCH 15/18] rt2800: introduce wpdma_disable function
2
3 From: Jakub Kicinski <kubakici@wp.pl>
4 Git-commit: f7b395e9f898313c2add740af04361e59b06e68b
5 Patch-mainline: v3.5-rc1
6 References: bnc#774902
7
8 Introduce wpdma_disable function to simplify the code.
9
10 Signed-off-by: Jakub Kicinski <kubakici@wp.pl>
11 Reviewed-by: Stanislaw Gruszka <sgruszka@redhat.com>
12 Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
13 Signed-off-by: John W. Linville <linville@tuxdriver.com>
14 Acked-by: Chen, Chien-Chia <machen@suse.com>
15 ---
16  drivers/net/wireless/rt2x00/rt2800lib.c |   32 ++++++++++++++++--------------
17  drivers/net/wireless/rt2x00/rt2800lib.h |    1 +
18  drivers/net/wireless/rt2x00/rt2800pci.c |   10 +--------
19  3 files changed, 19 insertions(+), 24 deletions(-)
20
21 diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
22 index 0f17cdd..19de379 100644
23 --- a/drivers/net/wireless/rt2x00/rt2800lib.c
24 +++ b/drivers/net/wireless/rt2x00/rt2800lib.c
25 @@ -296,6 +296,20 @@ int rt2800_wait_wpdma_ready(struct rt2x00_dev *rt2x00dev)
26  }
27  EXPORT_SYMBOL_GPL(rt2800_wait_wpdma_ready);
28  
29 +void rt2800_disable_wpdma(struct rt2x00_dev *rt2x00dev)
30 +{
31 +       u32 reg;
32 +
33 +       rt2800_register_read(rt2x00dev, WPDMA_GLO_CFG, &reg);
34 +       rt2x00_set_field32(&reg, WPDMA_GLO_CFG_ENABLE_TX_DMA, 0);
35 +       rt2x00_set_field32(&reg, WPDMA_GLO_CFG_TX_DMA_BUSY, 0);
36 +       rt2x00_set_field32(&reg, WPDMA_GLO_CFG_ENABLE_RX_DMA, 0);
37 +       rt2x00_set_field32(&reg, WPDMA_GLO_CFG_RX_DMA_BUSY, 0);
38 +       rt2x00_set_field32(&reg, WPDMA_GLO_CFG_TX_WRITEBACK_DONE, 1);
39 +       rt2800_register_write(rt2x00dev, WPDMA_GLO_CFG, reg);
40 +}
41 +EXPORT_SYMBOL_GPL(rt2800_disable_wpdma);
42 +
43  static bool rt2800_check_firmware_crc(const u8 *data, const size_t len)
44  {
45         u16 fw_crc;
46 @@ -444,10 +458,7 @@ int rt2800_load_firmware(struct rt2x00_dev *rt2x00dev,
47          * Disable DMA, will be reenabled later when enabling
48          * the radio.
49          */
50 -       rt2800_register_read(rt2x00dev, WPDMA_GLO_CFG, &reg);
51 -       rt2x00_set_field32(&reg, WPDMA_GLO_CFG_ENABLE_TX_DMA, 0);
52 -       rt2x00_set_field32(&reg, WPDMA_GLO_CFG_ENABLE_RX_DMA, 0);
53 -       rt2800_register_write(rt2x00dev, WPDMA_GLO_CFG, reg);
54 +       rt2800_disable_wpdma(rt2x00dev);
55  
56         /*
57          * Initialize firmware.
58 @@ -2861,13 +2872,7 @@ static int rt2800_init_registers(struct rt2x00_dev *rt2x00dev)
59         unsigned int i;
60         int ret;
61  
62 -       rt2800_register_read(rt2x00dev, WPDMA_GLO_CFG, &reg);
63 -       rt2x00_set_field32(&reg, WPDMA_GLO_CFG_ENABLE_TX_DMA, 0);
64 -       rt2x00_set_field32(&reg, WPDMA_GLO_CFG_TX_DMA_BUSY, 0);
65 -       rt2x00_set_field32(&reg, WPDMA_GLO_CFG_ENABLE_RX_DMA, 0);
66 -       rt2x00_set_field32(&reg, WPDMA_GLO_CFG_RX_DMA_BUSY, 0);
67 -       rt2x00_set_field32(&reg, WPDMA_GLO_CFG_TX_WRITEBACK_DONE, 1);
68 -       rt2800_register_write(rt2x00dev, WPDMA_GLO_CFG, reg);
69 +       rt2800_disable_wpdma(rt2x00dev);
70  
71         ret = rt2800_drv_init_registers(rt2x00dev);
72         if (ret)
73 @@ -4294,10 +4299,7 @@ void rt2800_disable_radio(struct rt2x00_dev *rt2x00dev)
74  {
75         u32 reg;
76  
77 -       rt2800_register_read(rt2x00dev, WPDMA_GLO_CFG, &reg);
78 -       rt2x00_set_field32(&reg, WPDMA_GLO_CFG_ENABLE_TX_DMA, 0);
79 -       rt2x00_set_field32(&reg, WPDMA_GLO_CFG_ENABLE_RX_DMA, 0);
80 -       rt2800_register_write(rt2x00dev, WPDMA_GLO_CFG, reg);
81 +       rt2800_disable_wpdma(rt2x00dev);
82  
83         /* Wait for DMA, ignore error */
84         rt2800_wait_wpdma_ready(rt2x00dev);
85 diff --git a/drivers/net/wireless/rt2x00/rt2800lib.h b/drivers/net/wireless/rt2x00/rt2800lib.h
86 index f89b71b..74fbf8a 100644
87 --- a/drivers/net/wireless/rt2x00/rt2800lib.h
88 +++ b/drivers/net/wireless/rt2x00/rt2800lib.h
89 @@ -209,5 +209,6 @@ int rt2800_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
90  int rt2800_get_survey(struct ieee80211_hw *hw, int idx,
91                       struct survey_info *survey);
92  int rt2800_enable_wlan_rt3290(struct rt2x00_dev *rt2x00dev);
93 +void rt2800_disable_wpdma(struct rt2x00_dev *rt2x00dev);
94  
95  #endif /* RT2800LIB_H */
96 diff --git a/drivers/net/wireless/rt2x00/rt2800pci.c b/drivers/net/wireless/rt2x00/rt2800pci.c
97 index 946e898..c4eb122 100644
98 --- a/drivers/net/wireless/rt2x00/rt2800pci.c
99 +++ b/drivers/net/wireless/rt2x00/rt2800pci.c
100 @@ -367,7 +367,6 @@ static void rt2800pci_clear_entry(struct queue_entry *entry)
101  static int rt2800pci_init_queues(struct rt2x00_dev *rt2x00dev)
102  {
103         struct queue_entry_priv_pci *entry_priv;
104 -       u32 reg;
105  
106         /*
107          * Initialize registers.
108 @@ -408,14 +407,7 @@ static int rt2800pci_init_queues(struct rt2x00_dev *rt2x00dev)
109                                  rt2x00dev->rx[0].limit - 1);
110         rt2x00pci_register_write(rt2x00dev, RX_DRX_IDX, 0);
111  
112 -       /*
113 -        * Enable global DMA configuration
114 -        */
115 -       rt2x00pci_register_read(rt2x00dev, WPDMA_GLO_CFG, &reg);
116 -       rt2x00_set_field32(&reg, WPDMA_GLO_CFG_ENABLE_TX_DMA, 0);
117 -       rt2x00_set_field32(&reg, WPDMA_GLO_CFG_ENABLE_RX_DMA, 0);
118 -       rt2x00_set_field32(&reg, WPDMA_GLO_CFG_TX_WRITEBACK_DONE, 1);
119 -       rt2x00pci_register_write(rt2x00dev, WPDMA_GLO_CFG, reg);
120 +       rt2800_disable_wpdma(rt2x00dev);
121  
122         rt2x00pci_register_write(rt2x00dev, DELAY_INT_CFG, 0);
123  
124 -- 
125 1.6.0.2
126