mt76: move mt76x02_mac_work routine in mt76x02-lib module
authorLorenzo Bianconi <lorenzo.bianconi@redhat.com>
Mon, 15 Oct 2018 09:33:12 +0000 (11:33 +0200)
committerFelix Fietkau <nbd@nbd.name>
Fri, 30 Nov 2018 11:21:39 +0000 (12:21 +0100)
Move mt76x02_mac_work routine in mt76x02_mac.c in order to be reused by
mt76x0 driver to read device statistics

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h
drivers/net/wireless/mediatek/mt76/mt76x02.h
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
drivers/net/wireless/mediatek/mt76/mt76x02_mac.h
drivers/net/wireless/mediatek/mt76/mt76x2/mac.h
drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2.h
drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c
drivers/net/wireless/mediatek/mt76/mt76x2/pci_mac.c

index f27335c..17fc720 100644 (file)
@@ -28,8 +28,6 @@
 #include "../mt76x02.h"
 #include "eeprom.h"
 
-#define MT_CALIBRATE_INTERVAL          (4 * HZ)
-
 #define MT_USB_AGGR_SIZE_LIMIT         21 /* * 1024B */
 #define MT_USB_AGGR_TIMEOUT            0x80 /* * 33ns */
 
index 47c42c6..189c697 100644 (file)
@@ -26,6 +26,8 @@
 #include "mt76x02_dfs.h"
 #include "mt76x02_dma.h"
 
+#define MT_CALIBRATE_INTERVAL  HZ
+
 struct mt76x02_mac_stats {
        u64 rx_stat[6];
        u64 tx_stat[6];
index e6d6dda..c7666f4 100644 (file)
@@ -753,3 +753,22 @@ void mt76x02_update_channel(struct mt76_dev *mdev)
        spin_unlock_bh(&dev->mt76.cc_lock);
 }
 EXPORT_SYMBOL_GPL(mt76x02_update_channel);
+
+void mt76x02_mac_work(struct work_struct *work)
+{
+       struct mt76x02_dev *dev = container_of(work, struct mt76x02_dev,
+                                              mac_work.work);
+       int i, idx;
+
+       mt76x02_update_channel(&dev->mt76);
+       for (i = 0, idx = 0; i < 16; i++) {
+               u32 val = mt76_rr(dev, MT_TX_AGG_CNT(i));
+
+               dev->aggr_stats[idx++] += val & 0xffff;
+               dev->aggr_stats[idx++] += val >> 16;
+       }
+
+       ieee80211_queue_delayed_work(mt76_hw(dev), &dev->mac_work,
+                                    MT_CALIBRATE_INTERVAL);
+}
+EXPORT_SYMBOL_GPL(mt76x02_mac_work);
index 6bce18b..c1936e2 100644 (file)
@@ -227,4 +227,5 @@ void mt76x02_mac_poll_tx_status(struct mt76x02_dev *dev, bool irq);
 void mt76x02_tx_complete_skb(struct mt76_dev *mdev, struct mt76_queue *q,
                             struct mt76_queue_entry *e, bool flush);
 void mt76x02_update_channel(struct mt76_dev *mdev);
+void mt76x02_mac_work(struct work_struct *work);
 #endif
index a31bd49..2dc2b9d 100644 (file)
@@ -32,6 +32,4 @@ int mt76x2_mac_set_beacon(struct mt76x02_dev *dev, u8 vif_idx,
                          struct sk_buff *skb);
 void mt76x2_mac_set_beacon_enable(struct mt76x02_dev *dev, u8 vif_idx, bool val);
 
-void mt76x2_mac_work(struct work_struct *work);
-
 #endif
index 72c3650..eca142a 100644 (file)
@@ -31,8 +31,6 @@
 #define MT7662_ROM_PATCH       "mt7662_rom_patch.bin"
 #define MT7662_EEPROM_SIZE     512
 
-#define MT_CALIBRATE_INTERVAL  HZ
-
 #include "../mt76x02.h"
 #include "mac.h"
 #include "dfs.h"
index 279edc6..0dea7d7 100644 (file)
@@ -467,7 +467,7 @@ int mt76x2_register_device(struct mt76x02_dev *dev)
        int i, ret;
 
        INIT_DELAYED_WORK(&dev->cal_work, mt76x2_phy_calibrate);
-       INIT_DELAYED_WORK(&dev->mac_work, mt76x2_mac_work);
+       INIT_DELAYED_WORK(&dev->mac_work, mt76x02_mac_work);
 
        mt76x2_init_device(dev);
 
index 15620d4..97128ea 100644 (file)
@@ -137,24 +137,6 @@ void mt76x2_mac_set_beacon_enable(struct mt76x02_dev *dev,
                mt76x02_irq_disable(dev, MT_INT_PRE_TBTT | MT_INT_TBTT);
 }
 
-void mt76x2_mac_work(struct work_struct *work)
-{
-       struct mt76x02_dev *dev = container_of(work, struct mt76x02_dev,
-                                              mac_work.work);
-       int i, idx;
-
-       mt76x02_update_channel(&dev->mt76);
-       for (i = 0, idx = 0; i < 16; i++) {
-               u32 val = mt76_rr(dev, MT_TX_AGG_CNT(i));
-
-               dev->aggr_stats[idx++] += val & 0xffff;
-               dev->aggr_stats[idx++] += val >> 16;
-       }
-
-       ieee80211_queue_delayed_work(mt76_hw(dev), &dev->mac_work,
-                                    MT_CALIBRATE_INTERVAL);
-}
-
 void mt76x2_mac_set_tx_protection(struct mt76x02_dev *dev, u32 val)
 {
        u32 data = 0;