diff options
author | Ivo van Doorn <ivdoorn@gmail.com> | 2010-10-11 09:37:25 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2010-10-11 15:04:25 -0400 |
commit | fa69560f317d961c56e29dea788b346d2b34fb87 (patch) | |
tree | f3102311d1a38906ebaf4a7df988b91a2f38cab3 /drivers/net/wireless/rt2x00/rt2x00queue.c | |
parent | a9325199edb093a5c7311a25d15da20ee984e80b (diff) |
rt2x00: Simplify Queue function arguments
A lot of functions accept a struct rt2x00_dev combined with
either a struct queue_entry or struct data_queue argument.
This can be simplified by only passing on the queue/entry
argument.
In cases where rt2x00_dev and a sk_buff are send together,
we can send the queue_entry instead.
rt2x00usb_alloc_urb and rt2x00usb_free_urb have a bit
of vague naming. Instead they allocate all the data which
belongs to a rt2x00 data queue entry.
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Acked-by: Helmut Schaa <helmut.schaa@googlemail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2x00queue.c')
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2x00queue.c | 49 |
1 files changed, 24 insertions, 25 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c index 83630f16dc6..7e30144c5cf 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,39 +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 | } else if (skbdesc->flags & SKBDESC_DMA_MAPPED_TX) { | 120 | } else if (skbdesc->flags & SKBDESC_DMA_MAPPED_TX) { |
119 | dma_unmap_single(rt2x00dev->dev, skbdesc->skb_dma, skb->len, | 121 | dma_unmap_single(dev, skbdesc->skb_dma, entry->skb->len, |
120 | DMA_TO_DEVICE); | 122 | DMA_TO_DEVICE); |
121 | skbdesc->flags &= ~SKBDESC_DMA_MAPPED_TX; | 123 | skbdesc->flags &= ~SKBDESC_DMA_MAPPED_TX; |
122 | } | 124 | } |
123 | } | 125 | } |
124 | EXPORT_SYMBOL_GPL(rt2x00queue_unmap_skb); | 126 | EXPORT_SYMBOL_GPL(rt2x00queue_unmap_skb); |
125 | 127 | ||
126 | void rt2x00queue_free_skb(struct rt2x00_dev *rt2x00dev, struct sk_buff *skb) | 128 | void rt2x00queue_free_skb(struct queue_entry *entry) |
127 | { | 129 | { |
128 | if (!skb) | 130 | if (!entry->skb) |
129 | return; | 131 | return; |
130 | 132 | ||
131 | rt2x00queue_unmap_skb(rt2x00dev, skb); | 133 | rt2x00queue_unmap_skb(entry); |
132 | dev_kfree_skb_any(skb); | 134 | dev_kfree_skb_any(entry->skb); |
135 | entry->skb = NULL; | ||
133 | } | 136 | } |
134 | 137 | ||
135 | void rt2x00queue_align_frame(struct sk_buff *skb) | 138 | void rt2x00queue_align_frame(struct sk_buff *skb) |
@@ -438,7 +441,7 @@ static int rt2x00queue_write_tx_data(struct queue_entry *entry, | |||
438 | * Map the skb to DMA. | 441 | * Map the skb to DMA. |
439 | */ | 442 | */ |
440 | if (test_bit(DRIVER_REQUIRE_DMA, &rt2x00dev->flags)) | 443 | if (test_bit(DRIVER_REQUIRE_DMA, &rt2x00dev->flags)) |
441 | rt2x00queue_map_txskb(rt2x00dev, entry->skb); | 444 | rt2x00queue_map_txskb(entry); |
442 | 445 | ||
443 | return 0; | 446 | return 0; |
444 | } | 447 | } |
@@ -585,8 +588,7 @@ int rt2x00queue_update_beacon(struct rt2x00_dev *rt2x00dev, | |||
585 | /* | 588 | /* |
586 | * Clean up the beacon skb. | 589 | * Clean up the beacon skb. |
587 | */ | 590 | */ |
588 | rt2x00queue_free_skb(rt2x00dev, intf->beacon->skb); | 591 | rt2x00queue_free_skb(intf->beacon); |
589 | intf->beacon->skb = NULL; | ||
590 | 592 | ||
591 | if (!enable_beacon) { | 593 | if (!enable_beacon) { |
592 | rt2x00dev->ops->lib->kill_tx_queue(intf->beacon->queue); | 594 | rt2x00dev->ops->lib->kill_tx_queue(intf->beacon->queue); |
@@ -827,8 +829,7 @@ static int rt2x00queue_alloc_entries(struct data_queue *queue, | |||
827 | return 0; | 829 | return 0; |
828 | } | 830 | } |
829 | 831 | ||
830 | static void rt2x00queue_free_skbs(struct rt2x00_dev *rt2x00dev, | 832 | static void rt2x00queue_free_skbs(struct data_queue *queue) |
831 | struct data_queue *queue) | ||
832 | { | 833 | { |
833 | unsigned int i; | 834 | unsigned int i; |
834 | 835 | ||
@@ -836,19 +837,17 @@ static void rt2x00queue_free_skbs(struct rt2x00_dev *rt2x00dev, | |||
836 | return; | 837 | return; |
837 | 838 | ||
838 | for (i = 0; i < queue->limit; i++) { | 839 | for (i = 0; i < queue->limit; i++) { |
839 | if (queue->entries[i].skb) | 840 | rt2x00queue_free_skb(&queue->entries[i]); |
840 | rt2x00queue_free_skb(rt2x00dev, queue->entries[i].skb); | ||
841 | } | 841 | } |
842 | } | 842 | } |
843 | 843 | ||
844 | static int rt2x00queue_alloc_rxskbs(struct rt2x00_dev *rt2x00dev, | 844 | static int rt2x00queue_alloc_rxskbs(struct data_queue *queue) |
845 | struct data_queue *queue) | ||
846 | { | 845 | { |
847 | unsigned int i; | 846 | unsigned int i; |
848 | struct sk_buff *skb; | 847 | struct sk_buff *skb; |
849 | 848 | ||
850 | for (i = 0; i < queue->limit; i++) { | 849 | for (i = 0; i < queue->limit; i++) { |
851 | skb = rt2x00queue_alloc_rxskb(rt2x00dev, &queue->entries[i]); | 850 | skb = rt2x00queue_alloc_rxskb(&queue->entries[i]); |
852 | if (!skb) | 851 | if (!skb) |
853 | return -ENOMEM; | 852 | return -ENOMEM; |
854 | queue->entries[i].skb = skb; | 853 | queue->entries[i].skb = skb; |
@@ -883,7 +882,7 @@ int rt2x00queue_initialize(struct rt2x00_dev *rt2x00dev) | |||
883 | goto exit; | 882 | goto exit; |
884 | } | 883 | } |
885 | 884 | ||
886 | status = rt2x00queue_alloc_rxskbs(rt2x00dev, rt2x00dev->rx); | 885 | status = rt2x00queue_alloc_rxskbs(rt2x00dev->rx); |
887 | if (status) | 886 | if (status) |
888 | goto exit; | 887 | goto exit; |
889 | 888 | ||
@@ -901,7 +900,7 @@ void rt2x00queue_uninitialize(struct rt2x00_dev *rt2x00dev) | |||
901 | { | 900 | { |
902 | struct data_queue *queue; | 901 | struct data_queue *queue; |
903 | 902 | ||
904 | rt2x00queue_free_skbs(rt2x00dev, rt2x00dev->rx); | 903 | rt2x00queue_free_skbs(rt2x00dev->rx); |
905 | 904 | ||
906 | queue_for_each(rt2x00dev, queue) { | 905 | queue_for_each(rt2x00dev, queue) { |
907 | kfree(queue->entries); | 906 | kfree(queue->entries); |