diff options
author | Gertjan van Wingerde <gwingerde@gmail.com> | 2009-12-30 05:36:32 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2010-01-12 13:51:23 -0500 |
commit | 67a4c1e24d58e0d88ed88539641631f6fc8a0cfd (patch) | |
tree | 0e1a80327b450fb73bbb73d43566575ccdec98fb /drivers | |
parent | 6c0fe26581406bff3d15fd6051453e80cfe70fd6 (diff) |
rt2x00: Unify rt2800 WPDMA ready waiting functions.
The rt2800pci_wait_wpdma_ready and rt2800usb_wait_wpdma_ready functions are
exactly the same, so unify them into rt200lib.
Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2800lib.c | 19 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2800lib.h | 1 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2800pci.c | 24 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2800usb.c | 22 |
4 files changed, 25 insertions, 41 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c index d300ff84b717..ca700a402e64 100644 --- a/drivers/net/wireless/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/rt2x00/rt2800lib.c | |||
@@ -245,6 +245,25 @@ void rt2800_mcu_request(struct rt2x00_dev *rt2x00dev, | |||
245 | } | 245 | } |
246 | EXPORT_SYMBOL_GPL(rt2800_mcu_request); | 246 | EXPORT_SYMBOL_GPL(rt2800_mcu_request); |
247 | 247 | ||
248 | int rt2800_wait_wpdma_ready(struct rt2x00_dev *rt2x00dev) | ||
249 | { | ||
250 | unsigned int i; | ||
251 | u32 reg; | ||
252 | |||
253 | for (i = 0; i < REGISTER_BUSY_COUNT; i++) { | ||
254 | rt2800_register_read(rt2x00dev, WPDMA_GLO_CFG, ®); | ||
255 | if (!rt2x00_get_field32(reg, WPDMA_GLO_CFG_TX_DMA_BUSY) && | ||
256 | !rt2x00_get_field32(reg, WPDMA_GLO_CFG_RX_DMA_BUSY)) | ||
257 | return 0; | ||
258 | |||
259 | msleep(1); | ||
260 | } | ||
261 | |||
262 | ERROR(rt2x00dev, "WPDMA TX/RX busy, aborting.\n"); | ||
263 | return -EACCES; | ||
264 | } | ||
265 | EXPORT_SYMBOL_GPL(rt2800_wait_wpdma_ready); | ||
266 | |||
248 | #ifdef CONFIG_RT2X00_LIB_DEBUGFS | 267 | #ifdef CONFIG_RT2X00_LIB_DEBUGFS |
249 | const struct rt2x00debug rt2800_rt2x00debug = { | 268 | const struct rt2x00debug rt2800_rt2x00debug = { |
250 | .owner = THIS_MODULE, | 269 | .owner = THIS_MODULE, |
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.h b/drivers/net/wireless/rt2x00/rt2800lib.h index 535ce22f2ac8..9adb3431374d 100644 --- a/drivers/net/wireless/rt2x00/rt2800lib.h +++ b/drivers/net/wireless/rt2x00/rt2800lib.h | |||
@@ -139,6 +139,7 @@ void rt2800_link_tuner(struct rt2x00_dev *rt2x00dev, struct link_qual *qual, | |||
139 | int rt2800_init_registers(struct rt2x00_dev *rt2x00dev); | 139 | int rt2800_init_registers(struct rt2x00_dev *rt2x00dev); |
140 | int rt2800_init_bbp(struct rt2x00_dev *rt2x00dev); | 140 | int rt2800_init_bbp(struct rt2x00_dev *rt2x00dev); |
141 | int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev); | 141 | int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev); |
142 | int rt2800_wait_wpdma_ready(struct rt2x00_dev *rt2x00dev); | ||
142 | 143 | ||
143 | int rt2800_efuse_detect(struct rt2x00_dev *rt2x00dev); | 144 | int rt2800_efuse_detect(struct rt2x00_dev *rt2x00dev); |
144 | void rt2800_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev); | 145 | void rt2800_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev); |
diff --git a/drivers/net/wireless/rt2x00/rt2800pci.c b/drivers/net/wireless/rt2x00/rt2800pci.c index b93eabb4fbe1..daea0b7c416e 100644 --- a/drivers/net/wireless/rt2x00/rt2800pci.c +++ b/drivers/net/wireless/rt2x00/rt2800pci.c | |||
@@ -453,24 +453,6 @@ static void rt2800pci_toggle_irq(struct rt2x00_dev *rt2x00dev, | |||
453 | rt2800_register_write(rt2x00dev, INT_MASK_CSR, reg); | 453 | rt2800_register_write(rt2x00dev, INT_MASK_CSR, reg); |
454 | } | 454 | } |
455 | 455 | ||
456 | static int rt2800pci_wait_wpdma_ready(struct rt2x00_dev *rt2x00dev) | ||
457 | { | ||
458 | unsigned int i; | ||
459 | u32 reg; | ||
460 | |||
461 | for (i = 0; i < REGISTER_BUSY_COUNT; i++) { | ||
462 | rt2800_register_read(rt2x00dev, WPDMA_GLO_CFG, ®); | ||
463 | if (!rt2x00_get_field32(reg, WPDMA_GLO_CFG_TX_DMA_BUSY) && | ||
464 | !rt2x00_get_field32(reg, WPDMA_GLO_CFG_RX_DMA_BUSY)) | ||
465 | return 0; | ||
466 | |||
467 | msleep(1); | ||
468 | } | ||
469 | |||
470 | ERROR(rt2x00dev, "WPDMA TX/RX busy, aborting.\n"); | ||
471 | return -EACCES; | ||
472 | } | ||
473 | |||
474 | static int rt2800pci_enable_radio(struct rt2x00_dev *rt2x00dev) | 456 | static int rt2800pci_enable_radio(struct rt2x00_dev *rt2x00dev) |
475 | { | 457 | { |
476 | u32 reg; | 458 | u32 reg; |
@@ -479,10 +461,10 @@ static int rt2800pci_enable_radio(struct rt2x00_dev *rt2x00dev) | |||
479 | /* | 461 | /* |
480 | * Initialize all registers. | 462 | * Initialize all registers. |
481 | */ | 463 | */ |
482 | if (unlikely(rt2800pci_wait_wpdma_ready(rt2x00dev) || | 464 | if (unlikely(rt2800_wait_wpdma_ready(rt2x00dev) || |
483 | rt2800pci_init_queues(rt2x00dev) || | 465 | rt2800pci_init_queues(rt2x00dev) || |
484 | rt2800_init_registers(rt2x00dev) || | 466 | rt2800_init_registers(rt2x00dev) || |
485 | rt2800pci_wait_wpdma_ready(rt2x00dev) || | 467 | rt2800_wait_wpdma_ready(rt2x00dev) || |
486 | rt2800_init_bbp(rt2x00dev) || | 468 | rt2800_init_bbp(rt2x00dev) || |
487 | rt2800_init_rfcsr(rt2x00dev))) | 469 | rt2800_init_rfcsr(rt2x00dev))) |
488 | return -EIO; | 470 | return -EIO; |
@@ -562,7 +544,7 @@ static void rt2800pci_disable_radio(struct rt2x00_dev *rt2x00dev) | |||
562 | rt2800_register_write(rt2x00dev, PBF_SYS_CTRL, 0x00000e00); | 544 | rt2800_register_write(rt2x00dev, PBF_SYS_CTRL, 0x00000e00); |
563 | 545 | ||
564 | /* Wait for DMA, ignore error */ | 546 | /* Wait for DMA, ignore error */ |
565 | rt2800pci_wait_wpdma_ready(rt2x00dev); | 547 | rt2800_wait_wpdma_ready(rt2x00dev); |
566 | } | 548 | } |
567 | 549 | ||
568 | static int rt2800pci_set_state(struct rt2x00_dev *rt2x00dev, | 550 | static int rt2800pci_set_state(struct rt2x00_dev *rt2x00dev, |
diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c index 0510f020dcf5..82755cf8b73e 100644 --- a/drivers/net/wireless/rt2x00/rt2800usb.c +++ b/drivers/net/wireless/rt2x00/rt2800usb.c | |||
@@ -248,24 +248,6 @@ static void rt2800usb_toggle_rx(struct rt2x00_dev *rt2x00dev, | |||
248 | rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, reg); | 248 | rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, reg); |
249 | } | 249 | } |
250 | 250 | ||
251 | static int rt2800usb_wait_wpdma_ready(struct rt2x00_dev *rt2x00dev) | ||
252 | { | ||
253 | unsigned int i; | ||
254 | u32 reg; | ||
255 | |||
256 | for (i = 0; i < REGISTER_BUSY_COUNT; i++) { | ||
257 | rt2800_register_read(rt2x00dev, WPDMA_GLO_CFG, ®); | ||
258 | if (!rt2x00_get_field32(reg, WPDMA_GLO_CFG_TX_DMA_BUSY) && | ||
259 | !rt2x00_get_field32(reg, WPDMA_GLO_CFG_RX_DMA_BUSY)) | ||
260 | return 0; | ||
261 | |||
262 | msleep(1); | ||
263 | } | ||
264 | |||
265 | ERROR(rt2x00dev, "WPDMA TX/RX busy, aborting.\n"); | ||
266 | return -EACCES; | ||
267 | } | ||
268 | |||
269 | static int rt2800usb_enable_radio(struct rt2x00_dev *rt2x00dev) | 251 | static int rt2800usb_enable_radio(struct rt2x00_dev *rt2x00dev) |
270 | { | 252 | { |
271 | u32 reg; | 253 | u32 reg; |
@@ -274,7 +256,7 @@ static int rt2800usb_enable_radio(struct rt2x00_dev *rt2x00dev) | |||
274 | /* | 256 | /* |
275 | * Initialize all registers. | 257 | * Initialize all registers. |
276 | */ | 258 | */ |
277 | if (unlikely(rt2800usb_wait_wpdma_ready(rt2x00dev) || | 259 | if (unlikely(rt2800_wait_wpdma_ready(rt2x00dev) || |
278 | rt2800_init_registers(rt2x00dev) || | 260 | rt2800_init_registers(rt2x00dev) || |
279 | rt2800_init_bbp(rt2x00dev) || | 261 | rt2800_init_bbp(rt2x00dev) || |
280 | rt2800_init_rfcsr(rt2x00dev))) | 262 | rt2800_init_rfcsr(rt2x00dev))) |
@@ -344,7 +326,7 @@ static void rt2800usb_disable_radio(struct rt2x00_dev *rt2x00dev) | |||
344 | rt2800_register_write(rt2x00dev, TX_PIN_CFG, 0); | 326 | rt2800_register_write(rt2x00dev, TX_PIN_CFG, 0); |
345 | 327 | ||
346 | /* Wait for DMA, ignore error */ | 328 | /* Wait for DMA, ignore error */ |
347 | rt2800usb_wait_wpdma_ready(rt2x00dev); | 329 | rt2800_wait_wpdma_ready(rt2x00dev); |
348 | 330 | ||
349 | rt2x00usb_disable_radio(rt2x00dev); | 331 | rt2x00usb_disable_radio(rt2x00dev); |
350 | } | 332 | } |