rt2x00: Simplify Queue function arguments
authorIvo van Doorn <ivdoorn@gmail.com>
Mon, 11 Oct 2010 13:37:25 +0000 (15:37 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 11 Oct 2010 19:04:25 +0000 (15:04 -0400)
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>
drivers/net/wireless/rt2x00/rt2400pci.c
drivers/net/wireless/rt2x00/rt2500pci.c
drivers/net/wireless/rt2x00/rt2x00.h
drivers/net/wireless/rt2x00/rt2x00dev.c
drivers/net/wireless/rt2x00/rt2x00lib.h
drivers/net/wireless/rt2x00/rt2x00pci.c
drivers/net/wireless/rt2x00/rt2x00queue.c
drivers/net/wireless/rt2x00/rt2x00usb.c

index 4b88909275a103f3f4c7fb00061c2cf733fda3f4..095cb6982d7a3757d40cf9d037829aada6357bc7 100644 (file)
@@ -1104,7 +1104,7 @@ static void rt2400pci_write_beacon(struct queue_entry *entry,
        rt2x00_set_field32(&reg, CSR14_BEACON_GEN, 0);
        rt2x00pci_register_write(rt2x00dev, CSR14, reg);
 
-       rt2x00queue_map_txskb(rt2x00dev, entry->skb);
+       rt2x00queue_map_txskb(entry);
 
        /*
         * Write the TX descriptor for the beacon.
index 46ef692e404df4ea67211b3b7501ec7a60712379..7d85bf9bd2534353ea8bbe4a3f6916424a523288 100644 (file)
@@ -1258,7 +1258,7 @@ static void rt2500pci_write_beacon(struct queue_entry *entry,
        rt2x00_set_field32(&reg, CSR14_BEACON_GEN, 0);
        rt2x00pci_register_write(rt2x00dev, CSR14, reg);
 
-       rt2x00queue_map_txskb(rt2x00dev, entry->skb);
+       rt2x00queue_map_txskb(entry);
 
        /*
         * Write the TX descriptor for the beacon.
index 75ac6624bf9e3914d9e571d03526cf5ea19cd4eb..2322c84adc1c81d8ccc0a251b36fadc6769ffeb8 100644 (file)
@@ -1036,17 +1036,15 @@ static inline bool rt2x00_is_soc(struct rt2x00_dev *rt2x00dev)
 
 /**
  * rt2x00queue_map_txskb - Map a skb into DMA for TX purposes.
- * @rt2x00dev: Pointer to &struct rt2x00_dev.
- * @skb: The skb to map.
+ * @entry: Pointer to &struct queue_entry
  */
-void rt2x00queue_map_txskb(struct rt2x00_dev *rt2x00dev, struct sk_buff *skb);
+void rt2x00queue_map_txskb(struct queue_entry *entry);
 
 /**
  * rt2x00queue_unmap_skb - Unmap a skb from DMA.
- * @rt2x00dev: Pointer to &struct rt2x00_dev.
- * @skb: The skb to unmap.
+ * @entry: Pointer to &struct queue_entry
  */
-void rt2x00queue_unmap_skb(struct rt2x00_dev *rt2x00dev, struct sk_buff *skb);
+void rt2x00queue_unmap_skb(struct queue_entry *entry);
 
 /**
  * rt2x00queue_get_queue - Convert queue index to queue pointer
@@ -1093,8 +1091,7 @@ void rt2x00lib_dmadone(struct queue_entry *entry);
 void rt2x00lib_txdone(struct queue_entry *entry,
                      struct txdone_entry_desc *txdesc);
 void rt2x00lib_txdone_noinfo(struct queue_entry *entry, u32 status);
-void rt2x00lib_rxdone(struct rt2x00_dev *rt2x00dev,
-                     struct queue_entry *entry);
+void rt2x00lib_rxdone(struct queue_entry *entry);
 
 /*
  * mac80211 handlers.
index 6f442b02b83ed0282c41b1ee2710d52f967ad43d..9b745faef0ed161dfe38de9b4d6c829837bed7d1 100644 (file)
@@ -273,7 +273,7 @@ void rt2x00lib_txdone(struct queue_entry *entry,
        /*
         * Unmap the skb.
         */
-       rt2x00queue_unmap_skb(rt2x00dev, entry->skb);
+       rt2x00queue_unmap_skb(entry);
 
        /*
         * Remove the extra tx headroom from the skb.
@@ -465,9 +465,9 @@ static int rt2x00lib_rxdone_read_signal(struct rt2x00_dev *rt2x00dev,
        return 0;
 }
 
-void rt2x00lib_rxdone(struct rt2x00_dev *rt2x00dev,
-                     struct queue_entry *entry)
+void rt2x00lib_rxdone(struct queue_entry *entry)
 {
+       struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
        struct rxdone_entry_desc rxdesc;
        struct sk_buff *skb;
        struct ieee80211_rx_status *rx_status;
@@ -481,14 +481,14 @@ void rt2x00lib_rxdone(struct rt2x00_dev *rt2x00dev,
         * Allocate a new sk_buffer. If no new buffer available, drop the
         * received frame and reuse the existing buffer.
         */
-       skb = rt2x00queue_alloc_rxskb(rt2x00dev, entry);
+       skb = rt2x00queue_alloc_rxskb(entry);
        if (!skb)
                return;
 
        /*
         * Unmap the skb.
         */
-       rt2x00queue_unmap_skb(rt2x00dev, entry->skb);
+       rt2x00queue_unmap_skb(entry);
 
        /*
         * Extract the RXD details.
index 70c85ac2e53ec15e2ec200581ea210db306a6159..619da23b7b56004cec3e3d327100449e9269b500 100644 (file)
@@ -100,18 +100,15 @@ void rt2x00lib_config(struct rt2x00_dev *rt2x00dev,
 
 /**
  * rt2x00queue_alloc_rxskb - allocate a skb for RX purposes.
- * @rt2x00dev: Pointer to &struct rt2x00_dev.
- * @queue: The queue for which the skb will be applicable.
+ * @entry: The entry for which the skb will be applicable.
  */
-struct sk_buff *rt2x00queue_alloc_rxskb(struct rt2x00_dev *rt2x00dev,
-                                       struct queue_entry *entry);
+struct sk_buff *rt2x00queue_alloc_rxskb(struct queue_entry *entry);
 
 /**
  * rt2x00queue_free_skb - free a skb
- * @rt2x00dev: Pointer to &struct rt2x00_dev.
- * @skb: The skb to free.
+ * @entry: The entry for which the skb will be applicable.
  */
-void rt2x00queue_free_skb(struct rt2x00_dev *rt2x00dev, struct sk_buff *skb);
+void rt2x00queue_free_skb(struct queue_entry *entry);
 
 /**
  * rt2x00queue_align_frame - Align 802.11 frame to 4-byte boundary
index 63c2cc408e154705967677b287e0b4da85a5e727..2449d785cf8d5b4d9b5260a0a2e4f79d0506fdd9 100644 (file)
@@ -84,7 +84,7 @@ void rt2x00pci_rxdone(struct rt2x00_dev *rt2x00dev)
                /*
                 * Send the frame to rt2x00lib for further processing.
                 */
-               rt2x00lib_rxdone(rt2x00dev, entry);
+               rt2x00lib_rxdone(entry);
        }
 }
 EXPORT_SYMBOL_GPL(rt2x00pci_rxdone);
index 83630f16dc64ecd473b4515431de75af2b65c935..7e30144c5cfa04189fe94886bc7ded69572aa5a8 100644 (file)
@@ -33,9 +33,9 @@
 #include "rt2x00.h"
 #include "rt2x00lib.h"
 
-struct sk_buff *rt2x00queue_alloc_rxskb(struct rt2x00_dev *rt2x00dev,
-                                       struct queue_entry *entry)
+struct sk_buff *rt2x00queue_alloc_rxskb(struct queue_entry *entry)
 {
+       struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
        struct sk_buff *skb;
        struct skb_frame_desc *skbdesc;
        unsigned int frame_size;
@@ -97,39 +97,42 @@ struct sk_buff *rt2x00queue_alloc_rxskb(struct rt2x00_dev *rt2x00dev,
        return skb;
 }
 
-void rt2x00queue_map_txskb(struct rt2x00_dev *rt2x00dev, struct sk_buff *skb)
+void rt2x00queue_map_txskb(struct queue_entry *entry)
 {
-       struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb);
+       struct device *dev = entry->queue->rt2x00dev->dev;
+       struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
 
        skbdesc->skb_dma =
-           dma_map_single(rt2x00dev->dev, skb->data, skb->len, DMA_TO_DEVICE);
+           dma_map_single(dev, entry->skb->data, entry->skb->len, DMA_TO_DEVICE);
        skbdesc->flags |= SKBDESC_DMA_MAPPED_TX;
 }
 EXPORT_SYMBOL_GPL(rt2x00queue_map_txskb);
 
-void rt2x00queue_unmap_skb(struct rt2x00_dev *rt2x00dev, struct sk_buff *skb)
+void rt2x00queue_unmap_skb(struct queue_entry *entry)
 {
-       struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb);
+       struct device *dev = entry->queue->rt2x00dev->dev;
+       struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
 
        if (skbdesc->flags & SKBDESC_DMA_MAPPED_RX) {
-               dma_unmap_single(rt2x00dev->dev, skbdesc->skb_dma, skb->len,
+               dma_unmap_single(dev, skbdesc->skb_dma, entry->skb->len,
                                 DMA_FROM_DEVICE);
                skbdesc->flags &= ~SKBDESC_DMA_MAPPED_RX;
        } else if (skbdesc->flags & SKBDESC_DMA_MAPPED_TX) {
-               dma_unmap_single(rt2x00dev->dev, skbdesc->skb_dma, skb->len,
+               dma_unmap_single(dev, skbdesc->skb_dma, entry->skb->len,
                                 DMA_TO_DEVICE);
                skbdesc->flags &= ~SKBDESC_DMA_MAPPED_TX;
        }
 }
 EXPORT_SYMBOL_GPL(rt2x00queue_unmap_skb);
 
-void rt2x00queue_free_skb(struct rt2x00_dev *rt2x00dev, struct sk_buff *skb)
+void rt2x00queue_free_skb(struct queue_entry *entry)
 {
-       if (!skb)
+       if (!entry->skb)
                return;
 
-       rt2x00queue_unmap_skb(rt2x00dev, skb);
-       dev_kfree_skb_any(skb);
+       rt2x00queue_unmap_skb(entry);
+       dev_kfree_skb_any(entry->skb);
+       entry->skb = NULL;
 }
 
 void rt2x00queue_align_frame(struct sk_buff *skb)
@@ -438,7 +441,7 @@ static int rt2x00queue_write_tx_data(struct queue_entry *entry,
         * Map the skb to DMA.
         */
        if (test_bit(DRIVER_REQUIRE_DMA, &rt2x00dev->flags))
-               rt2x00queue_map_txskb(rt2x00dev, entry->skb);
+               rt2x00queue_map_txskb(entry);
 
        return 0;
 }
@@ -585,8 +588,7 @@ int rt2x00queue_update_beacon(struct rt2x00_dev *rt2x00dev,
        /*
         * Clean up the beacon skb.
         */
-       rt2x00queue_free_skb(rt2x00dev, intf->beacon->skb);
-       intf->beacon->skb = NULL;
+       rt2x00queue_free_skb(intf->beacon);
 
        if (!enable_beacon) {
                rt2x00dev->ops->lib->kill_tx_queue(intf->beacon->queue);
@@ -827,8 +829,7 @@ static int rt2x00queue_alloc_entries(struct data_queue *queue,
        return 0;
 }
 
-static void rt2x00queue_free_skbs(struct rt2x00_dev *rt2x00dev,
-                                 struct data_queue *queue)
+static void rt2x00queue_free_skbs(struct data_queue *queue)
 {
        unsigned int i;
 
@@ -836,19 +837,17 @@ static void rt2x00queue_free_skbs(struct rt2x00_dev *rt2x00dev,
                return;
 
        for (i = 0; i < queue->limit; i++) {
-               if (queue->entries[i].skb)
-                       rt2x00queue_free_skb(rt2x00dev, queue->entries[i].skb);
+               rt2x00queue_free_skb(&queue->entries[i]);
        }
 }
 
-static int rt2x00queue_alloc_rxskbs(struct rt2x00_dev *rt2x00dev,
-                                   struct data_queue *queue)
+static int rt2x00queue_alloc_rxskbs(struct data_queue *queue)
 {
        unsigned int i;
        struct sk_buff *skb;
 
        for (i = 0; i < queue->limit; i++) {
-               skb = rt2x00queue_alloc_rxskb(rt2x00dev, &queue->entries[i]);
+               skb = rt2x00queue_alloc_rxskb(&queue->entries[i]);
                if (!skb)
                        return -ENOMEM;
                queue->entries[i].skb = skb;
@@ -883,7 +882,7 @@ int rt2x00queue_initialize(struct rt2x00_dev *rt2x00dev)
                        goto exit;
        }
 
-       status = rt2x00queue_alloc_rxskbs(rt2x00dev, rt2x00dev->rx);
+       status = rt2x00queue_alloc_rxskbs(rt2x00dev->rx);
        if (status)
                goto exit;
 
@@ -901,7 +900,7 @@ void rt2x00queue_uninitialize(struct rt2x00_dev *rt2x00dev)
 {
        struct data_queue *queue;
 
-       rt2x00queue_free_skbs(rt2x00dev, rt2x00dev->rx);
+       rt2x00queue_free_skbs(rt2x00dev->rx);
 
        queue_for_each(rt2x00dev, queue) {
                kfree(queue->entries);
index 4c5ae3d456253ac0a1525fbe592ff9869c06bbc1..451d637377a20bd530cce002266572e165e133e2 100644 (file)
@@ -398,7 +398,7 @@ static void rt2x00usb_work_rxdone(struct work_struct *work)
                /*
                 * Send the frame to rt2x00lib for further processing.
                 */
-               rt2x00lib_rxdone(rt2x00dev, entry);
+               rt2x00lib_rxdone(entry);
        }
 }
 
@@ -542,9 +542,9 @@ static int rt2x00usb_find_endpoints(struct rt2x00_dev *rt2x00dev)
        return 0;
 }
 
-static int rt2x00usb_alloc_urb(struct rt2x00_dev *rt2x00dev,
-                              struct data_queue *queue)
+static int rt2x00usb_alloc_entries(struct data_queue *queue)
 {
+       struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
        struct queue_entry_priv_usb *entry_priv;
        struct queue_entry_priv_usb_bcn *bcn_priv;
        unsigned int i;
@@ -561,7 +561,7 @@ static int rt2x00usb_alloc_urb(struct rt2x00_dev *rt2x00dev,
         * no guardian byte was required for the beacon,
         * then we are done.
         */
-       if (rt2x00dev->bcn != queue ||
+       if (queue->qid != QID_BEACON ||
            !test_bit(DRIVER_REQUIRE_BEACON_GUARD, &rt2x00dev->flags))
                return 0;
 
@@ -575,9 +575,9 @@ static int rt2x00usb_alloc_urb(struct rt2x00_dev *rt2x00dev,
        return 0;
 }
 
-static void rt2x00usb_free_urb(struct rt2x00_dev *rt2x00dev,
-                              struct data_queue *queue)
+static void rt2x00usb_free_entries(struct data_queue *queue)
 {
+       struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
        struct queue_entry_priv_usb *entry_priv;
        struct queue_entry_priv_usb_bcn *bcn_priv;
        unsigned int i;
@@ -596,7 +596,7 @@ static void rt2x00usb_free_urb(struct rt2x00_dev *rt2x00dev,
         * no guardian byte was required for the beacon,
         * then we are done.
         */
-       if (rt2x00dev->bcn != queue ||
+       if (queue->qid != QID_BEACON ||
            !test_bit(DRIVER_REQUIRE_BEACON_GUARD, &rt2x00dev->flags))
                return;
 
@@ -623,7 +623,7 @@ int rt2x00usb_initialize(struct rt2x00_dev *rt2x00dev)
         * Allocate DMA
         */
        queue_for_each(rt2x00dev, queue) {
-               status = rt2x00usb_alloc_urb(rt2x00dev, queue);
+               status = rt2x00usb_alloc_entries(queue);
                if (status)
                        goto exit;
        }
@@ -642,7 +642,7 @@ void rt2x00usb_uninitialize(struct rt2x00_dev *rt2x00dev)
        struct data_queue *queue;
 
        queue_for_each(rt2x00dev, queue)
-               rt2x00usb_free_urb(rt2x00dev, queue);
+               rt2x00usb_free_entries(queue);
 }
 EXPORT_SYMBOL_GPL(rt2x00usb_uninitialize);