diff options
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2400pci.c | 47 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2500pci.c | 47 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2500usb.c | 20 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2x00.h | 19 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2x00dev.c | 2 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2x00usb.c | 11 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt61pci.c | 66 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt73usb.c | 21 |
8 files changed, 152 insertions, 81 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2400pci.c b/drivers/net/wireless/rt2x00/rt2400pci.c index 9bda3889539c..78fca1bcc544 100644 --- a/drivers/net/wireless/rt2x00/rt2400pci.c +++ b/drivers/net/wireless/rt2x00/rt2400pci.c | |||
@@ -69,14 +69,14 @@ static void rt2400pci_bbp_write(struct rt2x00_dev *rt2x00dev, | |||
69 | { | 69 | { |
70 | u32 reg; | 70 | u32 reg; |
71 | 71 | ||
72 | mutex_lock(&rt2x00dev->csr_mutex); | ||
73 | |||
72 | /* | 74 | /* |
73 | * Wait until the BBP becomes ready. | 75 | * Wait until the BBP becomes ready. |
74 | */ | 76 | */ |
75 | reg = rt2400pci_bbp_check(rt2x00dev); | 77 | reg = rt2400pci_bbp_check(rt2x00dev); |
76 | if (rt2x00_get_field32(reg, BBPCSR_BUSY)) { | 78 | if (rt2x00_get_field32(reg, BBPCSR_BUSY)) |
77 | ERROR(rt2x00dev, "BBPCSR register busy. Write failed.\n"); | 79 | goto exit_fail; |
78 | return; | ||
79 | } | ||
80 | 80 | ||
81 | /* | 81 | /* |
82 | * Write the data into the BBP. | 82 | * Write the data into the BBP. |
@@ -88,6 +88,15 @@ static void rt2400pci_bbp_write(struct rt2x00_dev *rt2x00dev, | |||
88 | rt2x00_set_field32(®, BBPCSR_WRITE_CONTROL, 1); | 88 | rt2x00_set_field32(®, BBPCSR_WRITE_CONTROL, 1); |
89 | 89 | ||
90 | rt2x00pci_register_write(rt2x00dev, BBPCSR, reg); | 90 | rt2x00pci_register_write(rt2x00dev, BBPCSR, reg); |
91 | |||
92 | mutex_unlock(&rt2x00dev->csr_mutex); | ||
93 | |||
94 | return; | ||
95 | |||
96 | exit_fail: | ||
97 | mutex_unlock(&rt2x00dev->csr_mutex); | ||
98 | |||
99 | ERROR(rt2x00dev, "BBPCSR register busy. Write failed.\n"); | ||
91 | } | 100 | } |
92 | 101 | ||
93 | static void rt2400pci_bbp_read(struct rt2x00_dev *rt2x00dev, | 102 | static void rt2400pci_bbp_read(struct rt2x00_dev *rt2x00dev, |
@@ -95,14 +104,14 @@ static void rt2400pci_bbp_read(struct rt2x00_dev *rt2x00dev, | |||
95 | { | 104 | { |
96 | u32 reg; | 105 | u32 reg; |
97 | 106 | ||
107 | mutex_lock(&rt2x00dev->csr_mutex); | ||
108 | |||
98 | /* | 109 | /* |
99 | * Wait until the BBP becomes ready. | 110 | * Wait until the BBP becomes ready. |
100 | */ | 111 | */ |
101 | reg = rt2400pci_bbp_check(rt2x00dev); | 112 | reg = rt2400pci_bbp_check(rt2x00dev); |
102 | if (rt2x00_get_field32(reg, BBPCSR_BUSY)) { | 113 | if (rt2x00_get_field32(reg, BBPCSR_BUSY)) |
103 | ERROR(rt2x00dev, "BBPCSR register busy. Read failed.\n"); | 114 | goto exit_fail; |
104 | return; | ||
105 | } | ||
106 | 115 | ||
107 | /* | 116 | /* |
108 | * Write the request into the BBP. | 117 | * Write the request into the BBP. |
@@ -118,13 +127,20 @@ static void rt2400pci_bbp_read(struct rt2x00_dev *rt2x00dev, | |||
118 | * Wait until the BBP becomes ready. | 127 | * Wait until the BBP becomes ready. |
119 | */ | 128 | */ |
120 | reg = rt2400pci_bbp_check(rt2x00dev); | 129 | reg = rt2400pci_bbp_check(rt2x00dev); |
121 | if (rt2x00_get_field32(reg, BBPCSR_BUSY)) { | 130 | if (rt2x00_get_field32(reg, BBPCSR_BUSY)) |
122 | ERROR(rt2x00dev, "BBPCSR register busy. Read failed.\n"); | 131 | goto exit_fail; |
123 | *value = 0xff; | ||
124 | return; | ||
125 | } | ||
126 | 132 | ||
127 | *value = rt2x00_get_field32(reg, BBPCSR_VALUE); | 133 | *value = rt2x00_get_field32(reg, BBPCSR_VALUE); |
134 | |||
135 | mutex_unlock(&rt2x00dev->csr_mutex); | ||
136 | |||
137 | return; | ||
138 | |||
139 | exit_fail: | ||
140 | mutex_unlock(&rt2x00dev->csr_mutex); | ||
141 | |||
142 | ERROR(rt2x00dev, "BBPCSR register busy. Read failed.\n"); | ||
143 | *value = 0xff; | ||
128 | } | 144 | } |
129 | 145 | ||
130 | static void rt2400pci_rf_write(struct rt2x00_dev *rt2x00dev, | 146 | static void rt2400pci_rf_write(struct rt2x00_dev *rt2x00dev, |
@@ -136,6 +152,8 @@ static void rt2400pci_rf_write(struct rt2x00_dev *rt2x00dev, | |||
136 | if (!word) | 152 | if (!word) |
137 | return; | 153 | return; |
138 | 154 | ||
155 | mutex_lock(&rt2x00dev->csr_mutex); | ||
156 | |||
139 | for (i = 0; i < REGISTER_BUSY_COUNT; i++) { | 157 | for (i = 0; i < REGISTER_BUSY_COUNT; i++) { |
140 | rt2x00pci_register_read(rt2x00dev, RFCSR, ®); | 158 | rt2x00pci_register_read(rt2x00dev, RFCSR, ®); |
141 | if (!rt2x00_get_field32(reg, RFCSR_BUSY)) | 159 | if (!rt2x00_get_field32(reg, RFCSR_BUSY)) |
@@ -143,6 +161,7 @@ static void rt2400pci_rf_write(struct rt2x00_dev *rt2x00dev, | |||
143 | udelay(REGISTER_BUSY_DELAY); | 161 | udelay(REGISTER_BUSY_DELAY); |
144 | } | 162 | } |
145 | 163 | ||
164 | mutex_unlock(&rt2x00dev->csr_mutex); | ||
146 | ERROR(rt2x00dev, "RFCSR register busy. Write failed.\n"); | 165 | ERROR(rt2x00dev, "RFCSR register busy. Write failed.\n"); |
147 | return; | 166 | return; |
148 | 167 | ||
@@ -155,6 +174,8 @@ rf_write: | |||
155 | 174 | ||
156 | rt2x00pci_register_write(rt2x00dev, RFCSR, reg); | 175 | rt2x00pci_register_write(rt2x00dev, RFCSR, reg); |
157 | rt2x00_rf_write(rt2x00dev, word, value); | 176 | rt2x00_rf_write(rt2x00dev, word, value); |
177 | |||
178 | mutex_unlock(&rt2x00dev->csr_mutex); | ||
158 | } | 179 | } |
159 | 180 | ||
160 | static void rt2400pci_eepromregister_read(struct eeprom_93cx6 *eeprom) | 181 | static void rt2400pci_eepromregister_read(struct eeprom_93cx6 *eeprom) |
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c b/drivers/net/wireless/rt2x00/rt2500pci.c index 885844c1a3c3..972b5a5c3864 100644 --- a/drivers/net/wireless/rt2x00/rt2500pci.c +++ b/drivers/net/wireless/rt2x00/rt2500pci.c | |||
@@ -69,14 +69,14 @@ static void rt2500pci_bbp_write(struct rt2x00_dev *rt2x00dev, | |||
69 | { | 69 | { |
70 | u32 reg; | 70 | u32 reg; |
71 | 71 | ||
72 | mutex_lock(&rt2x00dev->csr_mutex); | ||
73 | |||
72 | /* | 74 | /* |
73 | * Wait until the BBP becomes ready. | 75 | * Wait until the BBP becomes ready. |
74 | */ | 76 | */ |
75 | reg = rt2500pci_bbp_check(rt2x00dev); | 77 | reg = rt2500pci_bbp_check(rt2x00dev); |
76 | if (rt2x00_get_field32(reg, BBPCSR_BUSY)) { | 78 | if (rt2x00_get_field32(reg, BBPCSR_BUSY)) |
77 | ERROR(rt2x00dev, "BBPCSR register busy. Write failed.\n"); | 79 | goto exit_fail; |
78 | return; | ||
79 | } | ||
80 | 80 | ||
81 | /* | 81 | /* |
82 | * Write the data into the BBP. | 82 | * Write the data into the BBP. |
@@ -88,6 +88,15 @@ static void rt2500pci_bbp_write(struct rt2x00_dev *rt2x00dev, | |||
88 | rt2x00_set_field32(®, BBPCSR_WRITE_CONTROL, 1); | 88 | rt2x00_set_field32(®, BBPCSR_WRITE_CONTROL, 1); |
89 | 89 | ||
90 | rt2x00pci_register_write(rt2x00dev, BBPCSR, reg); | 90 | rt2x00pci_register_write(rt2x00dev, BBPCSR, reg); |
91 | |||
92 | mutex_unlock(&rt2x00dev->csr_mutex); | ||
93 | |||
94 | return; | ||
95 | |||
96 | exit_fail: | ||
97 | mutex_unlock(&rt2x00dev->csr_mutex); | ||
98 | |||
99 | ERROR(rt2x00dev, "BBPCSR register busy. Write failed.\n"); | ||
91 | } | 100 | } |
92 | 101 | ||
93 | static void rt2500pci_bbp_read(struct rt2x00_dev *rt2x00dev, | 102 | static void rt2500pci_bbp_read(struct rt2x00_dev *rt2x00dev, |
@@ -95,14 +104,14 @@ static void rt2500pci_bbp_read(struct rt2x00_dev *rt2x00dev, | |||
95 | { | 104 | { |
96 | u32 reg; | 105 | u32 reg; |
97 | 106 | ||
107 | mutex_lock(&rt2x00dev->csr_mutex); | ||
108 | |||
98 | /* | 109 | /* |
99 | * Wait until the BBP becomes ready. | 110 | * Wait until the BBP becomes ready. |
100 | */ | 111 | */ |
101 | reg = rt2500pci_bbp_check(rt2x00dev); | 112 | reg = rt2500pci_bbp_check(rt2x00dev); |
102 | if (rt2x00_get_field32(reg, BBPCSR_BUSY)) { | 113 | if (rt2x00_get_field32(reg, BBPCSR_BUSY)) |
103 | ERROR(rt2x00dev, "BBPCSR register busy. Read failed.\n"); | 114 | goto exit_fail; |
104 | return; | ||
105 | } | ||
106 | 115 | ||
107 | /* | 116 | /* |
108 | * Write the request into the BBP. | 117 | * Write the request into the BBP. |
@@ -118,13 +127,20 @@ static void rt2500pci_bbp_read(struct rt2x00_dev *rt2x00dev, | |||
118 | * Wait until the BBP becomes ready. | 127 | * Wait until the BBP becomes ready. |
119 | */ | 128 | */ |
120 | reg = rt2500pci_bbp_check(rt2x00dev); | 129 | reg = rt2500pci_bbp_check(rt2x00dev); |
121 | if (rt2x00_get_field32(reg, BBPCSR_BUSY)) { | 130 | if (rt2x00_get_field32(reg, BBPCSR_BUSY)) |
122 | ERROR(rt2x00dev, "BBPCSR register busy. Read failed.\n"); | 131 | goto exit_fail; |
123 | *value = 0xff; | ||
124 | return; | ||
125 | } | ||
126 | 132 | ||
127 | *value = rt2x00_get_field32(reg, BBPCSR_VALUE); | 133 | *value = rt2x00_get_field32(reg, BBPCSR_VALUE); |
134 | |||
135 | mutex_unlock(&rt2x00dev->csr_mutex); | ||
136 | |||
137 | return; | ||
138 | |||
139 | exit_fail: | ||
140 | mutex_unlock(&rt2x00dev->csr_mutex); | ||
141 | |||
142 | ERROR(rt2x00dev, "BBPCSR register busy. Read failed.\n"); | ||
143 | *value = 0xff; | ||
128 | } | 144 | } |
129 | 145 | ||
130 | static void rt2500pci_rf_write(struct rt2x00_dev *rt2x00dev, | 146 | static void rt2500pci_rf_write(struct rt2x00_dev *rt2x00dev, |
@@ -136,6 +152,8 @@ static void rt2500pci_rf_write(struct rt2x00_dev *rt2x00dev, | |||
136 | if (!word) | 152 | if (!word) |
137 | return; | 153 | return; |
138 | 154 | ||
155 | mutex_lock(&rt2x00dev->csr_mutex); | ||
156 | |||
139 | for (i = 0; i < REGISTER_BUSY_COUNT; i++) { | 157 | for (i = 0; i < REGISTER_BUSY_COUNT; i++) { |
140 | rt2x00pci_register_read(rt2x00dev, RFCSR, ®); | 158 | rt2x00pci_register_read(rt2x00dev, RFCSR, ®); |
141 | if (!rt2x00_get_field32(reg, RFCSR_BUSY)) | 159 | if (!rt2x00_get_field32(reg, RFCSR_BUSY)) |
@@ -143,6 +161,7 @@ static void rt2500pci_rf_write(struct rt2x00_dev *rt2x00dev, | |||
143 | udelay(REGISTER_BUSY_DELAY); | 161 | udelay(REGISTER_BUSY_DELAY); |
144 | } | 162 | } |
145 | 163 | ||
164 | mutex_unlock(&rt2x00dev->csr_mutex); | ||
146 | ERROR(rt2x00dev, "RFCSR register busy. Write failed.\n"); | 165 | ERROR(rt2x00dev, "RFCSR register busy. Write failed.\n"); |
147 | return; | 166 | return; |
148 | 167 | ||
@@ -155,6 +174,8 @@ rf_write: | |||
155 | 174 | ||
156 | rt2x00pci_register_write(rt2x00dev, RFCSR, reg); | 175 | rt2x00pci_register_write(rt2x00dev, RFCSR, reg); |
157 | rt2x00_rf_write(rt2x00dev, word, value); | 176 | rt2x00_rf_write(rt2x00dev, word, value); |
177 | |||
178 | mutex_unlock(&rt2x00dev->csr_mutex); | ||
158 | } | 179 | } |
159 | 180 | ||
160 | static void rt2500pci_eepromregister_read(struct eeprom_93cx6 *eeprom) | 181 | static void rt2500pci_eepromregister_read(struct eeprom_93cx6 *eeprom) |
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c index c40c9e706e98..e6bae4ae4c47 100644 --- a/drivers/net/wireless/rt2x00/rt2500usb.c +++ b/drivers/net/wireless/rt2x00/rt2500usb.c | |||
@@ -47,7 +47,7 @@ | |||
47 | * between each attampt. When the busy bit is still set at that time, | 47 | * between each attampt. When the busy bit is still set at that time, |
48 | * the access attempt is considered to have failed, | 48 | * the access attempt is considered to have failed, |
49 | * and we will print an error. | 49 | * and we will print an error. |
50 | * If the usb_cache_mutex is already held then the _lock variants must | 50 | * If the csr_mutex is already held then the _lock variants must |
51 | * be used instead. | 51 | * be used instead. |
52 | */ | 52 | */ |
53 | static inline void rt2500usb_register_read(struct rt2x00_dev *rt2x00dev, | 53 | static inline void rt2500usb_register_read(struct rt2x00_dev *rt2x00dev, |
@@ -132,7 +132,7 @@ static void rt2500usb_bbp_write(struct rt2x00_dev *rt2x00dev, | |||
132 | { | 132 | { |
133 | u16 reg; | 133 | u16 reg; |
134 | 134 | ||
135 | mutex_lock(&rt2x00dev->usb_cache_mutex); | 135 | mutex_lock(&rt2x00dev->csr_mutex); |
136 | 136 | ||
137 | /* | 137 | /* |
138 | * Wait until the BBP becomes ready. | 138 | * Wait until the BBP becomes ready. |
@@ -151,12 +151,12 @@ static void rt2500usb_bbp_write(struct rt2x00_dev *rt2x00dev, | |||
151 | 151 | ||
152 | rt2500usb_register_write_lock(rt2x00dev, PHY_CSR7, reg); | 152 | rt2500usb_register_write_lock(rt2x00dev, PHY_CSR7, reg); |
153 | 153 | ||
154 | mutex_unlock(&rt2x00dev->usb_cache_mutex); | 154 | mutex_unlock(&rt2x00dev->csr_mutex); |
155 | 155 | ||
156 | return; | 156 | return; |
157 | 157 | ||
158 | exit_fail: | 158 | exit_fail: |
159 | mutex_unlock(&rt2x00dev->usb_cache_mutex); | 159 | mutex_unlock(&rt2x00dev->csr_mutex); |
160 | 160 | ||
161 | ERROR(rt2x00dev, "PHY_CSR8 register busy. Write failed.\n"); | 161 | ERROR(rt2x00dev, "PHY_CSR8 register busy. Write failed.\n"); |
162 | } | 162 | } |
@@ -166,7 +166,7 @@ static void rt2500usb_bbp_read(struct rt2x00_dev *rt2x00dev, | |||
166 | { | 166 | { |
167 | u16 reg; | 167 | u16 reg; |
168 | 168 | ||
169 | mutex_lock(&rt2x00dev->usb_cache_mutex); | 169 | mutex_lock(&rt2x00dev->csr_mutex); |
170 | 170 | ||
171 | /* | 171 | /* |
172 | * Wait until the BBP becomes ready. | 172 | * Wait until the BBP becomes ready. |
@@ -194,12 +194,12 @@ static void rt2500usb_bbp_read(struct rt2x00_dev *rt2x00dev, | |||
194 | rt2500usb_register_read_lock(rt2x00dev, PHY_CSR7, ®); | 194 | rt2500usb_register_read_lock(rt2x00dev, PHY_CSR7, ®); |
195 | *value = rt2x00_get_field16(reg, PHY_CSR7_DATA); | 195 | *value = rt2x00_get_field16(reg, PHY_CSR7_DATA); |
196 | 196 | ||
197 | mutex_unlock(&rt2x00dev->usb_cache_mutex); | 197 | mutex_unlock(&rt2x00dev->csr_mutex); |
198 | 198 | ||
199 | return; | 199 | return; |
200 | 200 | ||
201 | exit_fail: | 201 | exit_fail: |
202 | mutex_unlock(&rt2x00dev->usb_cache_mutex); | 202 | mutex_unlock(&rt2x00dev->csr_mutex); |
203 | 203 | ||
204 | ERROR(rt2x00dev, "PHY_CSR8 register busy. Read failed.\n"); | 204 | ERROR(rt2x00dev, "PHY_CSR8 register busy. Read failed.\n"); |
205 | *value = 0xff; | 205 | *value = 0xff; |
@@ -214,7 +214,7 @@ static void rt2500usb_rf_write(struct rt2x00_dev *rt2x00dev, | |||
214 | if (!word) | 214 | if (!word) |
215 | return; | 215 | return; |
216 | 216 | ||
217 | mutex_lock(&rt2x00dev->usb_cache_mutex); | 217 | mutex_lock(&rt2x00dev->csr_mutex); |
218 | 218 | ||
219 | for (i = 0; i < REGISTER_BUSY_COUNT; i++) { | 219 | for (i = 0; i < REGISTER_BUSY_COUNT; i++) { |
220 | rt2500usb_register_read_lock(rt2x00dev, PHY_CSR10, ®); | 220 | rt2500usb_register_read_lock(rt2x00dev, PHY_CSR10, ®); |
@@ -223,7 +223,7 @@ static void rt2500usb_rf_write(struct rt2x00_dev *rt2x00dev, | |||
223 | udelay(REGISTER_BUSY_DELAY); | 223 | udelay(REGISTER_BUSY_DELAY); |
224 | } | 224 | } |
225 | 225 | ||
226 | mutex_unlock(&rt2x00dev->usb_cache_mutex); | 226 | mutex_unlock(&rt2x00dev->csr_mutex); |
227 | ERROR(rt2x00dev, "PHY_CSR10 register busy. Write failed.\n"); | 227 | ERROR(rt2x00dev, "PHY_CSR10 register busy. Write failed.\n"); |
228 | return; | 228 | return; |
229 | 229 | ||
@@ -241,7 +241,7 @@ rf_write: | |||
241 | rt2500usb_register_write_lock(rt2x00dev, PHY_CSR10, reg); | 241 | rt2500usb_register_write_lock(rt2x00dev, PHY_CSR10, reg); |
242 | rt2x00_rf_write(rt2x00dev, word, value); | 242 | rt2x00_rf_write(rt2x00dev, word, value); |
243 | 243 | ||
244 | mutex_unlock(&rt2x00dev->usb_cache_mutex); | 244 | mutex_unlock(&rt2x00dev->csr_mutex); |
245 | } | 245 | } |
246 | 246 | ||
247 | #ifdef CONFIG_RT2X00_LIB_DEBUGFS | 247 | #ifdef CONFIG_RT2X00_LIB_DEBUGFS |
diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h index baccea7184b5..fee61bee1e7e 100644 --- a/drivers/net/wireless/rt2x00/rt2x00.h +++ b/drivers/net/wireless/rt2x00/rt2x00.h | |||
@@ -746,16 +746,15 @@ struct rt2x00_dev { | |||
746 | } csr; | 746 | } csr; |
747 | 747 | ||
748 | /* | 748 | /* |
749 | * Mutex to protect register accesses on USB devices. | 749 | * Mutex to protect register accesses. |
750 | * There are 2 reasons this is needed, one is to ensure | 750 | * For PCI and USB devices it protects against concurrent indirect |
751 | * use of the csr_cache (for USB devices) by one thread | 751 | * register access (BBP, RF, MCU) since accessing those |
752 | * isn't corrupted by another thread trying to access it. | 752 | * registers require multiple calls to the CSR registers. |
753 | * The other is that access to BBP and RF registers | 753 | * For USB devices it also protects the csr_cache since that |
754 | * require multiple BUS transactions and if another thread | 754 | * field is used for normal CSR access and it cannot support |
755 | * attempted to access one of those registers at the same | 755 | * multiple callers simultaneously. |
756 | * time one of the writes could silently fail. | 756 | */ |
757 | */ | 757 | struct mutex csr_mutex; |
758 | struct mutex usb_cache_mutex; | ||
759 | 758 | ||
760 | /* | 759 | /* |
761 | * Current packet filter configuration for the device. | 760 | * Current packet filter configuration for the device. |
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c index bb510a232d14..7fc1d766062b 100644 --- a/drivers/net/wireless/rt2x00/rt2x00dev.c +++ b/drivers/net/wireless/rt2x00/rt2x00dev.c | |||
@@ -1051,6 +1051,8 @@ int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev) | |||
1051 | { | 1051 | { |
1052 | int retval = -ENOMEM; | 1052 | int retval = -ENOMEM; |
1053 | 1053 | ||
1054 | mutex_init(&rt2x00dev->csr_mutex); | ||
1055 | |||
1054 | /* | 1056 | /* |
1055 | * Make room for rt2x00_intf inside the per-interface | 1057 | * Make room for rt2x00_intf inside the per-interface |
1056 | * structure ieee80211_vif. | 1058 | * structure ieee80211_vif. |
diff --git a/drivers/net/wireless/rt2x00/rt2x00usb.c b/drivers/net/wireless/rt2x00/rt2x00usb.c index 4eb550fab2f6..c507b0d9409f 100644 --- a/drivers/net/wireless/rt2x00/rt2x00usb.c +++ b/drivers/net/wireless/rt2x00/rt2x00usb.c | |||
@@ -79,7 +79,7 @@ int rt2x00usb_vendor_req_buff_lock(struct rt2x00_dev *rt2x00dev, | |||
79 | { | 79 | { |
80 | int status; | 80 | int status; |
81 | 81 | ||
82 | BUG_ON(!mutex_is_locked(&rt2x00dev->usb_cache_mutex)); | 82 | BUG_ON(!mutex_is_locked(&rt2x00dev->csr_mutex)); |
83 | 83 | ||
84 | /* | 84 | /* |
85 | * Check for Cache availability. | 85 | * Check for Cache availability. |
@@ -110,13 +110,13 @@ int rt2x00usb_vendor_request_buff(struct rt2x00_dev *rt2x00dev, | |||
110 | { | 110 | { |
111 | int status; | 111 | int status; |
112 | 112 | ||
113 | mutex_lock(&rt2x00dev->usb_cache_mutex); | 113 | mutex_lock(&rt2x00dev->csr_mutex); |
114 | 114 | ||
115 | status = rt2x00usb_vendor_req_buff_lock(rt2x00dev, request, | 115 | status = rt2x00usb_vendor_req_buff_lock(rt2x00dev, request, |
116 | requesttype, offset, buffer, | 116 | requesttype, offset, buffer, |
117 | buffer_length, timeout); | 117 | buffer_length, timeout); |
118 | 118 | ||
119 | mutex_unlock(&rt2x00dev->usb_cache_mutex); | 119 | mutex_unlock(&rt2x00dev->csr_mutex); |
120 | 120 | ||
121 | return status; | 121 | return status; |
122 | } | 122 | } |
@@ -132,7 +132,7 @@ int rt2x00usb_vendor_request_large_buff(struct rt2x00_dev *rt2x00dev, | |||
132 | unsigned char *tb; | 132 | unsigned char *tb; |
133 | u16 off, len, bsize; | 133 | u16 off, len, bsize; |
134 | 134 | ||
135 | mutex_lock(&rt2x00dev->usb_cache_mutex); | 135 | mutex_lock(&rt2x00dev->csr_mutex); |
136 | 136 | ||
137 | tb = (char *)buffer; | 137 | tb = (char *)buffer; |
138 | off = offset; | 138 | off = offset; |
@@ -148,7 +148,7 @@ int rt2x00usb_vendor_request_large_buff(struct rt2x00_dev *rt2x00dev, | |||
148 | off += bsize; | 148 | off += bsize; |
149 | } | 149 | } |
150 | 150 | ||
151 | mutex_unlock(&rt2x00dev->usb_cache_mutex); | 151 | mutex_unlock(&rt2x00dev->csr_mutex); |
152 | 152 | ||
153 | return status; | 153 | return status; |
154 | } | 154 | } |
@@ -531,7 +531,6 @@ int rt2x00usb_probe(struct usb_interface *usb_intf, | |||
531 | rt2x00dev->dev = &usb_intf->dev; | 531 | rt2x00dev->dev = &usb_intf->dev; |
532 | rt2x00dev->ops = ops; | 532 | rt2x00dev->ops = ops; |
533 | rt2x00dev->hw = hw; | 533 | rt2x00dev->hw = hw; |
534 | mutex_init(&rt2x00dev->usb_cache_mutex); | ||
535 | 534 | ||
536 | rt2x00dev->usb_maxpacket = | 535 | rt2x00dev->usb_maxpacket = |
537 | usb_maxpacket(usb_dev, usb_sndbulkpipe(usb_dev, 1), 1); | 536 | usb_maxpacket(usb_dev, usb_sndbulkpipe(usb_dev, 1), 1); |
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c index abfe33b5712a..89ac34fbadf2 100644 --- a/drivers/net/wireless/rt2x00/rt61pci.c +++ b/drivers/net/wireless/rt2x00/rt61pci.c | |||
@@ -75,14 +75,14 @@ static void rt61pci_bbp_write(struct rt2x00_dev *rt2x00dev, | |||
75 | { | 75 | { |
76 | u32 reg; | 76 | u32 reg; |
77 | 77 | ||
78 | mutex_lock(&rt2x00dev->csr_mutex); | ||
79 | |||
78 | /* | 80 | /* |
79 | * Wait until the BBP becomes ready. | 81 | * Wait until the BBP becomes ready. |
80 | */ | 82 | */ |
81 | reg = rt61pci_bbp_check(rt2x00dev); | 83 | reg = rt61pci_bbp_check(rt2x00dev); |
82 | if (rt2x00_get_field32(reg, PHY_CSR3_BUSY)) { | 84 | if (rt2x00_get_field32(reg, PHY_CSR3_BUSY)) |
83 | ERROR(rt2x00dev, "PHY_CSR3 register busy. Write failed.\n"); | 85 | goto exit_fail; |
84 | return; | ||
85 | } | ||
86 | 86 | ||
87 | /* | 87 | /* |
88 | * Write the data into the BBP. | 88 | * Write the data into the BBP. |
@@ -94,6 +94,14 @@ static void rt61pci_bbp_write(struct rt2x00_dev *rt2x00dev, | |||
94 | rt2x00_set_field32(®, PHY_CSR3_READ_CONTROL, 0); | 94 | rt2x00_set_field32(®, PHY_CSR3_READ_CONTROL, 0); |
95 | 95 | ||
96 | rt2x00pci_register_write(rt2x00dev, PHY_CSR3, reg); | 96 | rt2x00pci_register_write(rt2x00dev, PHY_CSR3, reg); |
97 | mutex_unlock(&rt2x00dev->csr_mutex); | ||
98 | |||
99 | return; | ||
100 | |||
101 | exit_fail: | ||
102 | mutex_unlock(&rt2x00dev->csr_mutex); | ||
103 | |||
104 | ERROR(rt2x00dev, "PHY_CSR3 register busy. Write failed.\n"); | ||
97 | } | 105 | } |
98 | 106 | ||
99 | static void rt61pci_bbp_read(struct rt2x00_dev *rt2x00dev, | 107 | static void rt61pci_bbp_read(struct rt2x00_dev *rt2x00dev, |
@@ -101,14 +109,14 @@ static void rt61pci_bbp_read(struct rt2x00_dev *rt2x00dev, | |||
101 | { | 109 | { |
102 | u32 reg; | 110 | u32 reg; |
103 | 111 | ||
112 | mutex_lock(&rt2x00dev->csr_mutex); | ||
113 | |||
104 | /* | 114 | /* |
105 | * Wait until the BBP becomes ready. | 115 | * Wait until the BBP becomes ready. |
106 | */ | 116 | */ |
107 | reg = rt61pci_bbp_check(rt2x00dev); | 117 | reg = rt61pci_bbp_check(rt2x00dev); |
108 | if (rt2x00_get_field32(reg, PHY_CSR3_BUSY)) { | 118 | if (rt2x00_get_field32(reg, PHY_CSR3_BUSY)) |
109 | ERROR(rt2x00dev, "PHY_CSR3 register busy. Read failed.\n"); | 119 | goto exit_fail; |
110 | return; | ||
111 | } | ||
112 | 120 | ||
113 | /* | 121 | /* |
114 | * Write the request into the BBP. | 122 | * Write the request into the BBP. |
@@ -124,13 +132,19 @@ static void rt61pci_bbp_read(struct rt2x00_dev *rt2x00dev, | |||
124 | * Wait until the BBP becomes ready. | 132 | * Wait until the BBP becomes ready. |
125 | */ | 133 | */ |
126 | reg = rt61pci_bbp_check(rt2x00dev); | 134 | reg = rt61pci_bbp_check(rt2x00dev); |
127 | if (rt2x00_get_field32(reg, PHY_CSR3_BUSY)) { | 135 | if (rt2x00_get_field32(reg, PHY_CSR3_BUSY)) |
128 | ERROR(rt2x00dev, "PHY_CSR3 register busy. Read failed.\n"); | 136 | goto exit_fail; |
129 | *value = 0xff; | ||
130 | return; | ||
131 | } | ||
132 | 137 | ||
133 | *value = rt2x00_get_field32(reg, PHY_CSR3_VALUE); | 138 | *value = rt2x00_get_field32(reg, PHY_CSR3_VALUE); |
139 | mutex_unlock(&rt2x00dev->csr_mutex); | ||
140 | |||
141 | return; | ||
142 | |||
143 | exit_fail: | ||
144 | mutex_unlock(&rt2x00dev->csr_mutex); | ||
145 | |||
146 | ERROR(rt2x00dev, "PHY_CSR3 register busy. Read failed.\n"); | ||
147 | *value = 0xff; | ||
134 | } | 148 | } |
135 | 149 | ||
136 | static void rt61pci_rf_write(struct rt2x00_dev *rt2x00dev, | 150 | static void rt61pci_rf_write(struct rt2x00_dev *rt2x00dev, |
@@ -142,6 +156,8 @@ static void rt61pci_rf_write(struct rt2x00_dev *rt2x00dev, | |||
142 | if (!word) | 156 | if (!word) |
143 | return; | 157 | return; |
144 | 158 | ||
159 | mutex_lock(&rt2x00dev->csr_mutex); | ||
160 | |||
145 | for (i = 0; i < REGISTER_BUSY_COUNT; i++) { | 161 | for (i = 0; i < REGISTER_BUSY_COUNT; i++) { |
146 | rt2x00pci_register_read(rt2x00dev, PHY_CSR4, ®); | 162 | rt2x00pci_register_read(rt2x00dev, PHY_CSR4, ®); |
147 | if (!rt2x00_get_field32(reg, PHY_CSR4_BUSY)) | 163 | if (!rt2x00_get_field32(reg, PHY_CSR4_BUSY)) |
@@ -149,6 +165,7 @@ static void rt61pci_rf_write(struct rt2x00_dev *rt2x00dev, | |||
149 | udelay(REGISTER_BUSY_DELAY); | 165 | udelay(REGISTER_BUSY_DELAY); |
150 | } | 166 | } |
151 | 167 | ||
168 | mutex_unlock(&rt2x00dev->csr_mutex); | ||
152 | ERROR(rt2x00dev, "PHY_CSR4 register busy. Write failed.\n"); | 169 | ERROR(rt2x00dev, "PHY_CSR4 register busy. Write failed.\n"); |
153 | return; | 170 | return; |
154 | 171 | ||
@@ -161,6 +178,8 @@ rf_write: | |||
161 | 178 | ||
162 | rt2x00pci_register_write(rt2x00dev, PHY_CSR4, reg); | 179 | rt2x00pci_register_write(rt2x00dev, PHY_CSR4, reg); |
163 | rt2x00_rf_write(rt2x00dev, word, value); | 180 | rt2x00_rf_write(rt2x00dev, word, value); |
181 | |||
182 | mutex_unlock(&rt2x00dev->csr_mutex); | ||
164 | } | 183 | } |
165 | 184 | ||
166 | #ifdef CONFIG_RT2X00_LIB_LEDS | 185 | #ifdef CONFIG_RT2X00_LIB_LEDS |
@@ -175,14 +194,12 @@ static void rt61pci_mcu_request(struct rt2x00_dev *rt2x00dev, | |||
175 | { | 194 | { |
176 | u32 reg; | 195 | u32 reg; |
177 | 196 | ||
197 | mutex_lock(&rt2x00dev->csr_mutex); | ||
198 | |||
178 | rt2x00pci_register_read(rt2x00dev, H2M_MAILBOX_CSR, ®); | 199 | rt2x00pci_register_read(rt2x00dev, H2M_MAILBOX_CSR, ®); |
179 | 200 | ||
180 | if (rt2x00_get_field32(reg, H2M_MAILBOX_CSR_OWNER)) { | 201 | if (rt2x00_get_field32(reg, H2M_MAILBOX_CSR_OWNER)) |
181 | ERROR(rt2x00dev, "mcu request error. " | 202 | goto exit_fail; |
182 | "Request 0x%02x failed for token 0x%02x.\n", | ||
183 | command, token); | ||
184 | return; | ||
185 | } | ||
186 | 203 | ||
187 | rt2x00_set_field32(®, H2M_MAILBOX_CSR_OWNER, 1); | 204 | rt2x00_set_field32(®, H2M_MAILBOX_CSR_OWNER, 1); |
188 | rt2x00_set_field32(®, H2M_MAILBOX_CSR_CMD_TOKEN, token); | 205 | rt2x00_set_field32(®, H2M_MAILBOX_CSR_CMD_TOKEN, token); |
@@ -194,6 +211,17 @@ static void rt61pci_mcu_request(struct rt2x00_dev *rt2x00dev, | |||
194 | rt2x00_set_field32(®, HOST_CMD_CSR_HOST_COMMAND, command); | 211 | rt2x00_set_field32(®, HOST_CMD_CSR_HOST_COMMAND, command); |
195 | rt2x00_set_field32(®, HOST_CMD_CSR_INTERRUPT_MCU, 1); | 212 | rt2x00_set_field32(®, HOST_CMD_CSR_INTERRUPT_MCU, 1); |
196 | rt2x00pci_register_write(rt2x00dev, HOST_CMD_CSR, reg); | 213 | rt2x00pci_register_write(rt2x00dev, HOST_CMD_CSR, reg); |
214 | |||
215 | mutex_unlock(&rt2x00dev->csr_mutex); | ||
216 | |||
217 | return; | ||
218 | |||
219 | exit_fail: | ||
220 | mutex_unlock(&rt2x00dev->csr_mutex); | ||
221 | |||
222 | ERROR(rt2x00dev, | ||
223 | "mcu request error. Request 0x%02x failed for token 0x%02x.\n", | ||
224 | command, token); | ||
197 | } | 225 | } |
198 | #endif /* CONFIG_RT2X00_LIB_LEDS */ | 226 | #endif /* CONFIG_RT2X00_LIB_LEDS */ |
199 | 227 | ||
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c index f2c8d9733c1d..d1a63e0017da 100644 --- a/drivers/net/wireless/rt2x00/rt73usb.c +++ b/drivers/net/wireless/rt2x00/rt73usb.c | |||
@@ -55,7 +55,7 @@ MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption."); | |||
55 | * between each attampt. When the busy bit is still set at that time, | 55 | * between each attampt. When the busy bit is still set at that time, |
56 | * the access attempt is considered to have failed, | 56 | * the access attempt is considered to have failed, |
57 | * and we will print an error. | 57 | * and we will print an error. |
58 | * The _lock versions must be used if you already hold the usb_cache_mutex | 58 | * The _lock versions must be used if you already hold the csr_mutex |
59 | */ | 59 | */ |
60 | static inline void rt73usb_register_read(struct rt2x00_dev *rt2x00dev, | 60 | static inline void rt73usb_register_read(struct rt2x00_dev *rt2x00dev, |
61 | const unsigned int offset, u32 *value) | 61 | const unsigned int offset, u32 *value) |
@@ -135,7 +135,7 @@ static void rt73usb_bbp_write(struct rt2x00_dev *rt2x00dev, | |||
135 | { | 135 | { |
136 | u32 reg; | 136 | u32 reg; |
137 | 137 | ||
138 | mutex_lock(&rt2x00dev->usb_cache_mutex); | 138 | mutex_lock(&rt2x00dev->csr_mutex); |
139 | 139 | ||
140 | /* | 140 | /* |
141 | * Wait until the BBP becomes ready. | 141 | * Wait until the BBP becomes ready. |
@@ -154,12 +154,12 @@ static void rt73usb_bbp_write(struct rt2x00_dev *rt2x00dev, | |||
154 | rt2x00_set_field32(®, PHY_CSR3_READ_CONTROL, 0); | 154 | rt2x00_set_field32(®, PHY_CSR3_READ_CONTROL, 0); |
155 | 155 | ||
156 | rt73usb_register_write_lock(rt2x00dev, PHY_CSR3, reg); | 156 | rt73usb_register_write_lock(rt2x00dev, PHY_CSR3, reg); |
157 | mutex_unlock(&rt2x00dev->usb_cache_mutex); | 157 | mutex_unlock(&rt2x00dev->csr_mutex); |
158 | 158 | ||
159 | return; | 159 | return; |
160 | 160 | ||
161 | exit_fail: | 161 | exit_fail: |
162 | mutex_unlock(&rt2x00dev->usb_cache_mutex); | 162 | mutex_unlock(&rt2x00dev->csr_mutex); |
163 | 163 | ||
164 | ERROR(rt2x00dev, "PHY_CSR3 register busy. Write failed.\n"); | 164 | ERROR(rt2x00dev, "PHY_CSR3 register busy. Write failed.\n"); |
165 | } | 165 | } |
@@ -169,7 +169,7 @@ static void rt73usb_bbp_read(struct rt2x00_dev *rt2x00dev, | |||
169 | { | 169 | { |
170 | u32 reg; | 170 | u32 reg; |
171 | 171 | ||
172 | mutex_lock(&rt2x00dev->usb_cache_mutex); | 172 | mutex_lock(&rt2x00dev->csr_mutex); |
173 | 173 | ||
174 | /* | 174 | /* |
175 | * Wait until the BBP becomes ready. | 175 | * Wait until the BBP becomes ready. |
@@ -196,12 +196,12 @@ static void rt73usb_bbp_read(struct rt2x00_dev *rt2x00dev, | |||
196 | goto exit_fail; | 196 | goto exit_fail; |
197 | 197 | ||
198 | *value = rt2x00_get_field32(reg, PHY_CSR3_VALUE); | 198 | *value = rt2x00_get_field32(reg, PHY_CSR3_VALUE); |
199 | mutex_unlock(&rt2x00dev->usb_cache_mutex); | 199 | mutex_unlock(&rt2x00dev->csr_mutex); |
200 | 200 | ||
201 | return; | 201 | return; |
202 | 202 | ||
203 | exit_fail: | 203 | exit_fail: |
204 | mutex_unlock(&rt2x00dev->usb_cache_mutex); | 204 | mutex_unlock(&rt2x00dev->csr_mutex); |
205 | 205 | ||
206 | ERROR(rt2x00dev, "PHY_CSR3 register busy. Read failed.\n"); | 206 | ERROR(rt2x00dev, "PHY_CSR3 register busy. Read failed.\n"); |
207 | *value = 0xff; | 207 | *value = 0xff; |
@@ -216,7 +216,7 @@ static void rt73usb_rf_write(struct rt2x00_dev *rt2x00dev, | |||
216 | if (!word) | 216 | if (!word) |
217 | return; | 217 | return; |
218 | 218 | ||
219 | mutex_lock(&rt2x00dev->usb_cache_mutex); | 219 | mutex_lock(&rt2x00dev->csr_mutex); |
220 | 220 | ||
221 | for (i = 0; i < REGISTER_BUSY_COUNT; i++) { | 221 | for (i = 0; i < REGISTER_BUSY_COUNT; i++) { |
222 | rt73usb_register_read_lock(rt2x00dev, PHY_CSR4, ®); | 222 | rt73usb_register_read_lock(rt2x00dev, PHY_CSR4, ®); |
@@ -225,7 +225,7 @@ static void rt73usb_rf_write(struct rt2x00_dev *rt2x00dev, | |||
225 | udelay(REGISTER_BUSY_DELAY); | 225 | udelay(REGISTER_BUSY_DELAY); |
226 | } | 226 | } |
227 | 227 | ||
228 | mutex_unlock(&rt2x00dev->usb_cache_mutex); | 228 | mutex_unlock(&rt2x00dev->csr_mutex); |
229 | ERROR(rt2x00dev, "PHY_CSR4 register busy. Write failed.\n"); | 229 | ERROR(rt2x00dev, "PHY_CSR4 register busy. Write failed.\n"); |
230 | return; | 230 | return; |
231 | 231 | ||
@@ -245,7 +245,8 @@ rf_write: | |||
245 | 245 | ||
246 | rt73usb_register_write_lock(rt2x00dev, PHY_CSR4, reg); | 246 | rt73usb_register_write_lock(rt2x00dev, PHY_CSR4, reg); |
247 | rt2x00_rf_write(rt2x00dev, word, value); | 247 | rt2x00_rf_write(rt2x00dev, word, value); |
248 | mutex_unlock(&rt2x00dev->usb_cache_mutex); | 248 | |
249 | mutex_unlock(&rt2x00dev->csr_mutex); | ||
249 | } | 250 | } |
250 | 251 | ||
251 | #ifdef CONFIG_RT2X00_LIB_DEBUGFS | 252 | #ifdef CONFIG_RT2X00_LIB_DEBUGFS |