diff mbox series

[v2] mt76x0: pci: add mt76x0e_cleanup routine

Message ID de07f6bb2754c23f00ad4979783f106a510ef6cf.1538383762.git.lorenzo.bianconi@redhat.com (mailing list archive)
State Accepted
Delegated to: Kalle Valo
Headers show
Series [v2] mt76x0: pci: add mt76x0e_cleanup routine | expand

Commit Message

Lorenzo Bianconi Oct. 1, 2018, 8:55 a.m. UTC
Add mt76x0e_cleanup routine to tidy up the device
during device removal

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
---
Changes since v1:
- remove H2M_MAILBOX_* configurations
---
 .../net/wireless/mediatek/mt76/mt76x0/pci.c   | 26 ++++++++++++++-----
 1 file changed, 20 insertions(+), 6 deletions(-)

Comments

Felix Fietkau Oct. 1, 2018, 11:42 a.m. UTC | #1
On 2018-10-01 10:55, Lorenzo Bianconi wrote:
> Add mt76x0e_cleanup routine to tidy up the device
> during device removal
> 
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Merged, thanks.

- Felix
diff mbox series

Patch

diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c b/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c
index 876291dd3c1e..97bf8634b06d 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/pci.c
@@ -41,13 +41,8 @@  static int mt76x0e_start(struct ieee80211_hw *hw)
 	return 0;
 }
 
-static void mt76x0e_stop(struct ieee80211_hw *hw)
+static void mt76x0e_stop_hw(struct mt76x0_dev *dev)
 {
-	struct mt76x0_dev *dev = hw->priv;
-
-	mutex_lock(&dev->mt76.mutex);
-
-	clear_bit(MT76_STATE_RUNNING, &dev->mt76.state);
 	cancel_delayed_work_sync(&dev->cal_work);
 	cancel_delayed_work_sync(&dev->mac_work);
 
@@ -62,7 +57,15 @@  static void mt76x0e_stop(struct ieee80211_hw *hw)
 		       0, 1000))
 		dev_warn(dev->mt76.dev, "TX DMA did not stop\n");
 	mt76_clear(dev, MT_WPDMA_GLO_CFG, MT_WPDMA_GLO_CFG_RX_DMA_EN);
+}
+
+static void mt76x0e_stop(struct ieee80211_hw *hw)
+{
+	struct mt76x0_dev *dev = hw->priv;
 
+	mutex_lock(&dev->mt76.mutex);
+	clear_bit(MT76_STATE_RUNNING, &dev->mt76.state);
+	mt76x0e_stop_hw(dev);
 	mutex_unlock(&dev->mt76.mutex);
 }
 
@@ -160,12 +163,23 @@  mt76x0e_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	return ret;
 }
 
+static void mt76x0e_cleanup(struct mt76x0_dev *dev)
+{
+	clear_bit(MT76_STATE_INITIALIZED, &dev->mt76.state);
+	mt76x0_chip_onoff(dev, false, false);
+	mt76x0e_stop_hw(dev);
+	mt76_dma_cleanup(&dev->mt76);
+	mt76x02_mcu_cleanup(&dev->mt76);
+}
+
 static void
 mt76x0e_remove(struct pci_dev *pdev)
 {
 	struct mt76_dev *mdev = pci_get_drvdata(pdev);
+	struct mt76x0_dev *dev = container_of(mdev, struct mt76x0_dev, mt76);
 
 	mt76_unregister_device(mdev);
+	mt76x0e_cleanup(dev);
 	ieee80211_free_hw(mdev->hw);
 }