rt2x00: rt2800lib: introduce rt2800_get_txwi_rxwi_size helper
authorGabor Juhos <juhosg@openwrt.org>
Fri, 16 Aug 2013 08:23:29 +0000 (10:23 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Fri, 16 Aug 2013 18:17:50 +0000 (14:17 -0400)
The rt2800pci driver uses the same [RT]XWI size
for all chipsets, however some chips requires
different values.

The size of the [RT]XWI structures is a constant
value for a given chipset and it does not depend
on the underlying interface. Add a helper function
which returns the correct values for the actual
chipset and use the new helper both in the rt2800usb
and in the rt2800pci drivers. This ensures that both
drivers are using the correct values.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/rt2x00/rt2800lib.c
drivers/net/wireless/rt2x00/rt2800lib.h
drivers/net/wireless/rt2x00/rt2800pci.c
drivers/net/wireless/rt2x00/rt2800usb.c

index dedc3d4ae3659e7e525c71b710b0e22af98e9f10..313da6ac2ee4bc36fc32d1da4b1c84f208b3a626 100644 (file)
@@ -521,6 +521,29 @@ void rt2800_disable_wpdma(struct rt2x00_dev *rt2x00dev)
 }
 EXPORT_SYMBOL_GPL(rt2800_disable_wpdma);
 
+void rt2800_get_txwi_rxwi_size(struct rt2x00_dev *rt2x00dev,
+                              unsigned short *txwi_size,
+                              unsigned short *rxwi_size)
+{
+       switch (rt2x00dev->chip.rt) {
+       case RT3593:
+               *txwi_size = TXWI_DESC_SIZE_4WORDS;
+               *rxwi_size = RXWI_DESC_SIZE_5WORDS;
+               break;
+
+       case RT5592:
+               *txwi_size = TXWI_DESC_SIZE_5WORDS;
+               *rxwi_size = RXWI_DESC_SIZE_6WORDS;
+               break;
+
+       default:
+               *txwi_size = TXWI_DESC_SIZE_4WORDS;
+               *rxwi_size = RXWI_DESC_SIZE_4WORDS;
+               break;
+       }
+}
+EXPORT_SYMBOL_GPL(rt2800_get_txwi_rxwi_size);
+
 static bool rt2800_check_firmware_crc(const u8 *data, const size_t len)
 {
        u16 fw_crc;
index 6ec739466db46e681f86fc4f59a282949082cf38..a94ba447e63c93eb10744ba2adf8ff2aa00f1886 100644 (file)
@@ -226,4 +226,8 @@ int rt2800_get_survey(struct ieee80211_hw *hw, int idx,
                      struct survey_info *survey);
 void rt2800_disable_wpdma(struct rt2x00_dev *rt2x00dev);
 
+void rt2800_get_txwi_rxwi_size(struct rt2x00_dev *rt2x00dev,
+                              unsigned short *txwi_size,
+                              unsigned short *rxwi_size);
+
 #endif /* RT2800LIB_H */
index 00055627eb8de41282a8248f0ad855a87fe00c86..dcad90c805421ce36996c8e35dec386c87616b6d 100644 (file)
@@ -1189,12 +1189,17 @@ static const struct rt2x00lib_ops rt2800pci_rt2x00_ops = {
 
 static void rt2800pci_queue_init(struct data_queue *queue)
 {
+       struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
+       unsigned short txwi_size, rxwi_size;
+
+       rt2800_get_txwi_rxwi_size(rt2x00dev, &txwi_size, &rxwi_size);
+
        switch (queue->qid) {
        case QID_RX:
                queue->limit = 128;
                queue->data_size = AGGREGATION_SIZE;
                queue->desc_size = RXD_DESC_SIZE;
-               queue->winfo_size = RXWI_DESC_SIZE_4WORDS;
+               queue->winfo_size = rxwi_size;
                queue->priv_size = sizeof(struct queue_entry_priv_mmio);
                break;
 
@@ -1205,7 +1210,7 @@ static void rt2800pci_queue_init(struct data_queue *queue)
                queue->limit = 64;
                queue->data_size = AGGREGATION_SIZE;
                queue->desc_size = TXD_DESC_SIZE;
-               queue->winfo_size = TXWI_DESC_SIZE_4WORDS;
+               queue->winfo_size = txwi_size;
                queue->priv_size = sizeof(struct queue_entry_priv_mmio);
                break;
 
@@ -1213,7 +1218,7 @@ static void rt2800pci_queue_init(struct data_queue *queue)
                queue->limit = 8;
                queue->data_size = 0; /* No DMA required for beacons */
                queue->desc_size = TXD_DESC_SIZE;
-               queue->winfo_size = TXWI_DESC_SIZE_4WORDS;
+               queue->winfo_size = txwi_size;
                queue->priv_size = sizeof(struct queue_entry_priv_mmio);
                break;
 
index fc9efdfca8f2eda014e4e4391d0bc295a61afb12..338034e18243af16f810eb4b7a1e9a3c8fc92e6a 100644 (file)
@@ -854,16 +854,7 @@ static void rt2800usb_queue_init(struct data_queue *queue)
        struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
        unsigned short txwi_size, rxwi_size;
 
-       if (rt2x00_rt(rt2x00dev, RT3593)) {
-               txwi_size = TXWI_DESC_SIZE_4WORDS;
-               rxwi_size = RXWI_DESC_SIZE_5WORDS;
-       } else if (rt2x00_rt(rt2x00dev, RT5592)) {
-               txwi_size = TXWI_DESC_SIZE_5WORDS;
-               rxwi_size = RXWI_DESC_SIZE_6WORDS;
-       } else {
-               txwi_size = TXWI_DESC_SIZE_4WORDS;
-               rxwi_size = RXWI_DESC_SIZE_4WORDS;
-       }
+       rt2800_get_txwi_rxwi_size(rt2x00dev, &txwi_size, &rxwi_size);
 
        switch (queue->qid) {
        case QID_RX: