diff options
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2x00queue.c')
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2x00queue.c | 56 |
1 files changed, 27 insertions, 29 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c index eede99939db9..e360d287defb 100644 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c | |||
@@ -33,9 +33,9 @@ | |||
33 | #include "rt2x00.h" | 33 | #include "rt2x00.h" |
34 | #include "rt2x00lib.h" | 34 | #include "rt2x00lib.h" |
35 | 35 | ||
36 | struct sk_buff *rt2x00queue_alloc_rxskb(struct rt2x00_dev *rt2x00dev, | 36 | struct sk_buff *rt2x00queue_alloc_rxskb(struct queue_entry *entry) |
37 | struct queue_entry *entry) | ||
38 | { | 37 | { |
38 | struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; | ||
39 | struct sk_buff *skb; | 39 | struct sk_buff *skb; |
40 | struct skb_frame_desc *skbdesc; | 40 | struct skb_frame_desc *skbdesc; |
41 | unsigned int frame_size; | 41 | unsigned int frame_size; |
@@ -97,41 +97,42 @@ struct sk_buff *rt2x00queue_alloc_rxskb(struct rt2x00_dev *rt2x00dev, | |||
97 | return skb; | 97 | return skb; |
98 | } | 98 | } |
99 | 99 | ||
100 | void rt2x00queue_map_txskb(struct rt2x00_dev *rt2x00dev, struct sk_buff *skb) | 100 | void rt2x00queue_map_txskb(struct queue_entry *entry) |
101 | { | 101 | { |
102 | struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb); | 102 | struct device *dev = entry->queue->rt2x00dev->dev; |
103 | struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb); | ||
103 | 104 | ||
104 | skbdesc->skb_dma = | 105 | skbdesc->skb_dma = |
105 | dma_map_single(rt2x00dev->dev, skb->data, skb->len, DMA_TO_DEVICE); | 106 | dma_map_single(dev, entry->skb->data, entry->skb->len, DMA_TO_DEVICE); |
106 | skbdesc->flags |= SKBDESC_DMA_MAPPED_TX; | 107 | skbdesc->flags |= SKBDESC_DMA_MAPPED_TX; |
107 | } | 108 | } |
108 | EXPORT_SYMBOL_GPL(rt2x00queue_map_txskb); | 109 | EXPORT_SYMBOL_GPL(rt2x00queue_map_txskb); |
109 | 110 | ||
110 | void rt2x00queue_unmap_skb(struct rt2x00_dev *rt2x00dev, struct sk_buff *skb) | 111 | void rt2x00queue_unmap_skb(struct queue_entry *entry) |
111 | { | 112 | { |
112 | struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb); | 113 | struct device *dev = entry->queue->rt2x00dev->dev; |
114 | struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb); | ||
113 | 115 | ||
114 | if (skbdesc->flags & SKBDESC_DMA_MAPPED_RX) { | 116 | if (skbdesc->flags & SKBDESC_DMA_MAPPED_RX) { |
115 | dma_unmap_single(rt2x00dev->dev, skbdesc->skb_dma, skb->len, | 117 | dma_unmap_single(dev, skbdesc->skb_dma, entry->skb->len, |
116 | DMA_FROM_DEVICE); | 118 | DMA_FROM_DEVICE); |
117 | skbdesc->flags &= ~SKBDESC_DMA_MAPPED_RX; | 119 | skbdesc->flags &= ~SKBDESC_DMA_MAPPED_RX; |
118 | } | 120 | } else if (skbdesc->flags & SKBDESC_DMA_MAPPED_TX) { |
119 | 121 | dma_unmap_single(dev, skbdesc->skb_dma, entry->skb->len, | |
120 | if (skbdesc->flags & SKBDESC_DMA_MAPPED_TX) { | ||
121 | dma_unmap_single(rt2x00dev->dev, skbdesc->skb_dma, skb->len, | ||
122 | DMA_TO_DEVICE); | 122 | DMA_TO_DEVICE); |
123 | skbdesc->flags &= ~SKBDESC_DMA_MAPPED_TX; | 123 | skbdesc->flags &= ~SKBDESC_DMA_MAPPED_TX; |
124 | } | 124 | } |
125 | } | 125 | } |
126 | EXPORT_SYMBOL_GPL(rt2x00queue_unmap_skb); | 126 | EXPORT_SYMBOL_GPL(rt2x00queue_unmap_skb); |
127 | 127 | ||
128 | void rt2x00queue_free_skb(struct rt2x00_dev *rt2x00dev, struct sk_buff *skb) | 128 | void rt2x00queue_free_skb(struct queue_entry *entry) |
129 | { | 129 | { |
130 | if (!skb) | 130 | if (!entry->skb) |
131 | return; | 131 | return; |
132 | 132 | ||
133 | rt2x00queue_unmap_skb(rt2x00dev, skb); | 133 | rt2x00queue_unmap_skb(entry); |
134 | dev_kfree_skb_any(skb); | 134 | dev_kfree_skb_any(entry->skb); |
135 | entry->skb = NULL; | ||
135 | } | 136 | } |
136 | 137 | ||
137 | void rt2x00queue_align_frame(struct sk_buff *skb) | 138 | void rt2x00queue_align_frame(struct sk_buff *skb) |
@@ -440,7 +441,7 @@ static int rt2x00queue_write_tx_data(struct queue_entry *entry, | |||
440 | * Map the skb to DMA. | 441 | * Map the skb to DMA. |
441 | */ | 442 | */ |
442 | if (test_bit(DRIVER_REQUIRE_DMA, &rt2x00dev->flags)) | 443 | if (test_bit(DRIVER_REQUIRE_DMA, &rt2x00dev->flags)) |
443 | rt2x00queue_map_txskb(rt2x00dev, entry->skb); | 444 | rt2x00queue_map_txskb(entry); |
444 | 445 | ||
445 | return 0; | 446 | return 0; |
446 | } | 447 | } |
@@ -491,7 +492,8 @@ int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb, | |||
491 | if (unlikely(rt2x00queue_full(queue))) | 492 | if (unlikely(rt2x00queue_full(queue))) |
492 | return -ENOBUFS; | 493 | return -ENOBUFS; |
493 | 494 | ||
494 | if (test_and_set_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags)) { | 495 | if (unlikely(test_and_set_bit(ENTRY_OWNER_DEVICE_DATA, |
496 | &entry->flags))) { | ||
495 | ERROR(queue->rt2x00dev, | 497 | ERROR(queue->rt2x00dev, |
496 | "Arrived at non-free entry in the non-full queue %d.\n" | 498 | "Arrived at non-free entry in the non-full queue %d.\n" |
497 | "Please file bug report to %s.\n", | 499 | "Please file bug report to %s.\n", |
@@ -586,8 +588,7 @@ int rt2x00queue_update_beacon(struct rt2x00_dev *rt2x00dev, | |||
586 | /* | 588 | /* |
587 | * Clean up the beacon skb. | 589 | * Clean up the beacon skb. |
588 | */ | 590 | */ |
589 | rt2x00queue_free_skb(rt2x00dev, intf->beacon->skb); | 591 | rt2x00queue_free_skb(intf->beacon); |
590 | intf->beacon->skb = NULL; | ||
591 | 592 | ||
592 | if (!enable_beacon) { | 593 | if (!enable_beacon) { |
593 | rt2x00dev->ops->lib->kill_tx_queue(intf->beacon->queue); | 594 | rt2x00dev->ops->lib->kill_tx_queue(intf->beacon->queue); |
@@ -828,8 +829,7 @@ static int rt2x00queue_alloc_entries(struct data_queue *queue, | |||
828 | return 0; | 829 | return 0; |
829 | } | 830 | } |
830 | 831 | ||
831 | static void rt2x00queue_free_skbs(struct rt2x00_dev *rt2x00dev, | 832 | static void rt2x00queue_free_skbs(struct data_queue *queue) |
832 | struct data_queue *queue) | ||
833 | { | 833 | { |
834 | unsigned int i; | 834 | unsigned int i; |
835 | 835 | ||
@@ -837,19 +837,17 @@ static void rt2x00queue_free_skbs(struct rt2x00_dev *rt2x00dev, | |||
837 | return; | 837 | return; |
838 | 838 | ||
839 | for (i = 0; i < queue->limit; i++) { | 839 | for (i = 0; i < queue->limit; i++) { |
840 | if (queue->entries[i].skb) | 840 | rt2x00queue_free_skb(&queue->entries[i]); |
841 | rt2x00queue_free_skb(rt2x00dev, queue->entries[i].skb); | ||
842 | } | 841 | } |
843 | } | 842 | } |
844 | 843 | ||
845 | static int rt2x00queue_alloc_rxskbs(struct rt2x00_dev *rt2x00dev, | 844 | static int rt2x00queue_alloc_rxskbs(struct data_queue *queue) |
846 | struct data_queue *queue) | ||
847 | { | 845 | { |
848 | unsigned int i; | 846 | unsigned int i; |
849 | struct sk_buff *skb; | 847 | struct sk_buff *skb; |
850 | 848 | ||
851 | for (i = 0; i < queue->limit; i++) { | 849 | for (i = 0; i < queue->limit; i++) { |
852 | skb = rt2x00queue_alloc_rxskb(rt2x00dev, &queue->entries[i]); | 850 | skb = rt2x00queue_alloc_rxskb(&queue->entries[i]); |
853 | if (!skb) | 851 | if (!skb) |
854 | return -ENOMEM; | 852 | return -ENOMEM; |
855 | queue->entries[i].skb = skb; | 853 | queue->entries[i].skb = skb; |
@@ -884,7 +882,7 @@ int rt2x00queue_initialize(struct rt2x00_dev *rt2x00dev) | |||
884 | goto exit; | 882 | goto exit; |
885 | } | 883 | } |
886 | 884 | ||
887 | status = rt2x00queue_alloc_rxskbs(rt2x00dev, rt2x00dev->rx); | 885 | status = rt2x00queue_alloc_rxskbs(rt2x00dev->rx); |
888 | if (status) | 886 | if (status) |
889 | goto exit; | 887 | goto exit; |
890 | 888 | ||
@@ -902,7 +900,7 @@ void rt2x00queue_uninitialize(struct rt2x00_dev *rt2x00dev) | |||
902 | { | 900 | { |
903 | struct data_queue *queue; | 901 | struct data_queue *queue; |
904 | 902 | ||
905 | rt2x00queue_free_skbs(rt2x00dev, rt2x00dev->rx); | 903 | rt2x00queue_free_skbs(rt2x00dev->rx); |
906 | 904 | ||
907 | queue_for_each(rt2x00dev, queue) { | 905 | queue_for_each(rt2x00dev, queue) { |
908 | kfree(queue->entries); | 906 | kfree(queue->entries); |