Commit 454b768f authored by Kai-Heng Feng's avatar Kai-Heng Feng Committed by Felix Fietkau

mt76: mt7921: Let PCI core handle power state and use pm_sleep_ptr()

PCI power state and wakeup are already handled by PCI core, so it's not
necessary to handle them in the driver.

Also switch to use pm_sleep_ptr() to remove #ifdef guard.
Signed-off-by: default avatarKai-Heng Feng <kai.heng.feng@canonical.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 3bd53ea0
...@@ -358,9 +358,9 @@ static void mt7921_pci_remove(struct pci_dev *pdev) ...@@ -358,9 +358,9 @@ static void mt7921_pci_remove(struct pci_dev *pdev)
pci_free_irq_vectors(pdev); pci_free_irq_vectors(pdev);
} }
#ifdef CONFIG_PM static int mt7921_pci_suspend(struct device *device)
static int mt7921_pci_suspend(struct pci_dev *pdev, pm_message_t state)
{ {
struct pci_dev *pdev = to_pci_dev(device);
struct mt76_dev *mdev = pci_get_drvdata(pdev); struct mt76_dev *mdev = pci_get_drvdata(pdev);
struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76); struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76);
struct mt76_connac_pm *pm = &dev->pm; struct mt76_connac_pm *pm = &dev->pm;
...@@ -390,8 +390,6 @@ static int mt7921_pci_suspend(struct pci_dev *pdev, pm_message_t state) ...@@ -390,8 +390,6 @@ static int mt7921_pci_suspend(struct pci_dev *pdev, pm_message_t state)
napi_disable(&mdev->napi[i]); napi_disable(&mdev->napi[i]);
} }
pci_enable_wake(pdev, pci_choose_state(pdev, state), true);
/* wait until dma is idle */ /* wait until dma is idle */
mt76_poll(dev, MT_WFDMA0_GLO_CFG, mt76_poll(dev, MT_WFDMA0_GLO_CFG,
MT_WFDMA0_GLO_CFG_TX_DMA_BUSY | MT_WFDMA0_GLO_CFG_TX_DMA_BUSY |
...@@ -411,8 +409,6 @@ static int mt7921_pci_suspend(struct pci_dev *pdev, pm_message_t state) ...@@ -411,8 +409,6 @@ static int mt7921_pci_suspend(struct pci_dev *pdev, pm_message_t state)
if (err) if (err)
goto restore_napi; goto restore_napi;
pci_save_state(pdev);
err = pci_set_power_state(pdev, pci_choose_state(pdev, state));
if (err) if (err)
goto restore_napi; goto restore_napi;
...@@ -435,19 +431,14 @@ static int mt7921_pci_suspend(struct pci_dev *pdev, pm_message_t state) ...@@ -435,19 +431,14 @@ static int mt7921_pci_suspend(struct pci_dev *pdev, pm_message_t state)
return err; return err;
} }
static int mt7921_pci_resume(struct pci_dev *pdev) static int mt7921_pci_resume(struct device *device)
{ {
struct pci_dev *pdev = to_pci_dev(device);
struct mt76_dev *mdev = pci_get_drvdata(pdev); struct mt76_dev *mdev = pci_get_drvdata(pdev);
struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76); struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76);
struct mt76_connac_pm *pm = &dev->pm; struct mt76_connac_pm *pm = &dev->pm;
int i, err; int i, err;
err = pci_set_power_state(pdev, PCI_D0);
if (err)
return err;
pci_restore_state(pdev);
err = mt7921_mcu_drv_pmctrl(dev); err = mt7921_mcu_drv_pmctrl(dev);
if (err < 0) if (err < 0)
return err; return err;
...@@ -487,17 +478,15 @@ static int mt7921_pci_resume(struct pci_dev *pdev) ...@@ -487,17 +478,15 @@ static int mt7921_pci_resume(struct pci_dev *pdev)
return err; return err;
} }
#endif /* CONFIG_PM */
static DEFINE_SIMPLE_DEV_PM_OPS(mt7921_pm_ops, mt7921_pci_suspend, mt7921_pci_resume);
static struct pci_driver mt7921_pci_driver = { static struct pci_driver mt7921_pci_driver = {
.name = KBUILD_MODNAME, .name = KBUILD_MODNAME,
.id_table = mt7921_pci_device_table, .id_table = mt7921_pci_device_table,
.probe = mt7921_pci_probe, .probe = mt7921_pci_probe,
.remove = mt7921_pci_remove, .remove = mt7921_pci_remove,
#ifdef CONFIG_PM .driver.pm = pm_sleep_ptr(&mt7921_pm_ops),
.suspend = mt7921_pci_suspend,
.resume = mt7921_pci_resume,
#endif /* CONFIG_PM */
}; };
module_pci_driver(mt7921_pci_driver); module_pci_driver(mt7921_pci_driver);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment