]> www.infradead.org Git - users/hch/block.git/commitdiff
wifi: mt76: mt792x: move some common usb code in mt792x module
authorLorenzo Bianconi <lorenzo@kernel.org>
Thu, 21 Sep 2023 10:23:48 +0000 (12:23 +0200)
committerFelix Fietkau <nbd@nbd.name>
Sat, 30 Sep 2023 18:17:18 +0000 (20:17 +0200)
Move the following shared usb routines in mt792x module:
- mt792xu_stop
- mt792x_stop

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7921/main.c
drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
drivers/net/wireless/mediatek/mt76/mt7921/usb.c
drivers/net/wireless/mediatek/mt76/mt7925/main.c
drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h
drivers/net/wireless/mediatek/mt76/mt7925/usb.c
drivers/net/wireless/mediatek/mt76/mt792x.h
drivers/net/wireless/mediatek/mt76/mt792x_core.c
drivers/net/wireless/mediatek/mt76/mt792x_usb.c

index aa20fdce27293f8ceee482a5527fc5e40687e9c8..ee14af4f337337193624674225421eb8ffc93423 100644 (file)
@@ -259,25 +259,6 @@ static int mt7921_start(struct ieee80211_hw *hw)
        return err;
 }
 
-void mt7921_stop(struct ieee80211_hw *hw)
-{
-       struct mt792x_dev *dev = mt792x_hw_dev(hw);
-       struct mt792x_phy *phy = mt792x_hw_phy(hw);
-
-       cancel_delayed_work_sync(&phy->mt76->mac_work);
-
-       cancel_delayed_work_sync(&dev->pm.ps_work);
-       cancel_work_sync(&dev->pm.wake_work);
-       cancel_work_sync(&dev->reset_work);
-       mt76_connac_free_pending_tx_skbs(&dev->pm, NULL);
-
-       mt792x_mutex_acquire(dev);
-       clear_bit(MT76_STATE_RUNNING, &phy->mt76->state);
-       mt76_connac_mcu_set_mac_enable(&dev->mt76, 0, false, false);
-       mt792x_mutex_release(dev);
-}
-EXPORT_SYMBOL_GPL(mt7921_stop);
-
 static int
 mt7921_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
 {
@@ -1312,7 +1293,7 @@ static void mt7921_mgd_complete_tx(struct ieee80211_hw *hw,
 const struct ieee80211_ops mt7921_ops = {
        .tx = mt792x_tx,
        .start = mt7921_start,
-       .stop = mt7921_stop,
+       .stop = mt792x_stop,
        .add_interface = mt7921_add_interface,
        .remove_interface = mt792x_remove_interface,
        .config = mt7921_config,
index d454b5e4363612ce7543d715a479fe6efd0833e6..5e6e5fe85599c0587eab73aee83939b903357fd4 100644 (file)
@@ -232,7 +232,6 @@ mt7921_l1_rmw(struct mt792x_dev *dev, u32 addr, u32 mask, u32 val)
 #define mt7921_l1_set(dev, addr, val)  mt7921_l1_rmw(dev, addr, 0, val)
 #define mt7921_l1_clear(dev, addr, val)        mt7921_l1_rmw(dev, addr, val, 0)
 
-void mt7921_stop(struct ieee80211_hw *hw);
 int mt7921_mac_init(struct mt792x_dev *dev);
 bool mt7921_mac_wtbl_update(struct mt792x_dev *dev, int idx, u32 mask);
 int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
index 33a87f447dca7337fd7edef8094fd2bcb7c11f01..e5258c74fc077ac69b310b5bab0e56c02ebfcef5 100644 (file)
@@ -135,14 +135,6 @@ out:
        return err;
 }
 
-static void mt7921u_stop(struct ieee80211_hw *hw)
-{
-       struct mt792x_dev *dev = mt792x_hw_dev(hw);
-
-       mt76u_stop_tx(&dev->mt76);
-       mt7921_stop(hw);
-}
-
 static int mt7921u_probe(struct usb_interface *usb_intf,
                         const struct usb_device_id *id)
 {
@@ -189,7 +181,7 @@ static int mt7921u_probe(struct usb_interface *usb_intf,
        if (!ops)
                return -ENOMEM;
 
-       ops->stop = mt7921u_stop;
+       ops->stop = mt792xu_stop;
        mdev = mt76_alloc_device(&usb_intf->dev, sizeof(*dev), ops, &drv_ops);
        if (!mdev)
                return -ENOMEM;
index bb913eec3ca86e8e17b58a2493c434a0f54862eb..15c2fb0bcb1b98d1ea436db26c3c6da09441534a 100644 (file)
@@ -318,24 +318,6 @@ static int mt7925_start(struct ieee80211_hw *hw)
        return err;
 }
 
-void mt7925_stop(struct ieee80211_hw *hw)
-{
-       struct mt792x_dev *dev = mt792x_hw_dev(hw);
-       struct mt792x_phy *phy = mt792x_hw_phy(hw);
-
-       cancel_delayed_work_sync(&phy->mt76->mac_work);
-
-       cancel_delayed_work_sync(&dev->pm.ps_work);
-       cancel_work_sync(&dev->pm.wake_work);
-       cancel_work_sync(&dev->reset_work);
-       mt76_connac_free_pending_tx_skbs(&dev->pm, NULL);
-
-       mt792x_mutex_acquire(dev);
-       clear_bit(MT76_STATE_RUNNING, &phy->mt76->state);
-       mt792x_mutex_release(dev);
-}
-EXPORT_SYMBOL_GPL(mt7925_stop);
-
 static int
 mt7925_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
 {
@@ -1411,7 +1393,7 @@ static void mt7925_mgd_complete_tx(struct ieee80211_hw *hw,
 const struct ieee80211_ops mt7925_ops = {
        .tx = mt792x_tx,
        .start = mt7925_start,
-       .stop = mt7925_stop,
+       .stop = mt792x_stop,
        .add_interface = mt7925_add_interface,
        .remove_interface = mt792x_remove_interface,
        .config = mt7925_config,
index 9a2d38a2b2bde79016a86c6e16562b10648892ea..33785f526acff17b6411c10b66b9e462019dcee5 100644 (file)
@@ -208,7 +208,6 @@ int mt7925_mcu_chip_config(struct mt792x_dev *dev, const char *cmd);
 int mt7925_mcu_set_rxfilter(struct mt792x_dev *dev, u32 fif,
                            u8 bit_op, u32 bit_map);
 
-void mt7925_stop(struct ieee80211_hw *hw);
 int mt7925_mac_init(struct mt792x_dev *dev);
 int mt7925_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
                       struct ieee80211_sta *sta);
index ea09b9b9d303db01ad7e610d73933ed71a6f2b7c..9b885c5b3ed594ddc9c5b62f47dfd4522430f469 100644 (file)
@@ -69,14 +69,6 @@ static int mt7925u_mcu_init(struct mt792x_dev *dev)
        return 0;
 }
 
-static void mt7925u_stop(struct ieee80211_hw *hw)
-{
-       struct mt792x_dev *dev = mt792x_hw_dev(hw);
-
-       mt76u_stop_tx(&dev->mt76);
-       mt7925_stop(hw);
-}
-
 static int mt7925u_mac_reset(struct mt792x_dev *dev)
 {
        int err;
@@ -180,7 +172,7 @@ static int mt7925u_probe(struct usb_interface *usb_intf,
        if (!ops)
                return -ENOMEM;
 
-       ops->stop = mt7925u_stop;
+       ops->stop = mt792xu_stop;
 
        mdev = mt76_alloc_device(&usb_intf->dev, sizeof(*dev), ops, &drv_ops);
        if (!mdev)
index fd1614e4926b650adc699fa7ea66dfaf949a5b0a..6c8fee5763f13c204cb9028ed65e3750cae5a992 100644 (file)
@@ -233,6 +233,7 @@ static inline bool mt792x_dma_need_reinit(struct mt792x_dev *dev)
 #define mt792x_mutex_release(dev)      \
        mt76_connac_mutex_release(&(dev)->mt76, &(dev)->pm)
 
+void mt792x_stop(struct ieee80211_hw *hw);
 void mt792x_pm_wake_work(struct work_struct *work);
 void mt792x_pm_power_save_work(struct work_struct *work);
 void mt792x_reset(struct mt76_dev *mdev);
@@ -345,6 +346,7 @@ void mt792xu_wr(struct mt76_dev *dev, u32 addr, u32 val);
 u32 mt792xu_rmw(struct mt76_dev *dev, u32 addr, u32 mask, u32 val);
 void mt792xu_copy(struct mt76_dev *dev, u32 offset, const void *data, int len);
 void mt792xu_disconnect(struct usb_interface *usb_intf);
+void mt792xu_stop(struct ieee80211_hw *hw);
 
 static inline void
 mt792x_skb_add_usb_sdio_hdr(struct mt792x_dev *dev, struct sk_buff *skb,
index 7c4a74fb11804a9d6cee509f8b6d9ac335fef129..502be22dbe3677fb475371b7e4c564be074899d8 100644 (file)
@@ -91,6 +91,28 @@ void mt792x_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control,
 }
 EXPORT_SYMBOL_GPL(mt792x_tx);
 
+void mt792x_stop(struct ieee80211_hw *hw)
+{
+       struct mt792x_dev *dev = mt792x_hw_dev(hw);
+       struct mt792x_phy *phy = mt792x_hw_phy(hw);
+
+       cancel_delayed_work_sync(&phy->mt76->mac_work);
+
+       cancel_delayed_work_sync(&dev->pm.ps_work);
+       cancel_work_sync(&dev->pm.wake_work);
+       cancel_work_sync(&dev->reset_work);
+       mt76_connac_free_pending_tx_skbs(&dev->pm, NULL);
+
+       if (is_mt7921(&dev->mt76)) {
+               mt792x_mutex_acquire(dev);
+               mt76_connac_mcu_set_mac_enable(&dev->mt76, 0, false, false);
+               mt792x_mutex_release(dev);
+       }
+
+       clear_bit(MT76_STATE_RUNNING, &phy->mt76->state);
+}
+EXPORT_SYMBOL_GPL(mt792x_stop);
+
 void mt792x_remove_interface(struct ieee80211_hw *hw,
                             struct ieee80211_vif *vif)
 {
index 20e7f9c7c88c09ec25acba93540fa958c28351ef..2dd283caed36bf056127d17a6cd3e93e9f6664d4 100644 (file)
@@ -287,6 +287,15 @@ int mt792xu_init_reset(struct mt792x_dev *dev)
 }
 EXPORT_SYMBOL_GPL(mt792xu_init_reset);
 
+void mt792xu_stop(struct ieee80211_hw *hw)
+{
+       struct mt792x_dev *dev = mt792x_hw_dev(hw);
+
+       mt76u_stop_tx(&dev->mt76);
+       mt792x_stop(hw);
+}
+EXPORT_SYMBOL_GPL(mt792xu_stop);
+
 void mt792xu_disconnect(struct usb_interface *usb_intf)
 {
        struct mt792x_dev *dev = usb_get_intfdata(usb_intf);