tulip: windbond-840: use generic power management

With stable support of generic PM callbacks, drivers no longer need to use
legacy .suspend() and .resume() in which they had to maintain PCI states
changes and device's power state themselves.

Earlier, .resume() was invoking pci_enable_device(). Drivers should not
call PCI legacy helper functions, hence, it was removed. This should not
change the behavior of the device as this function is called by PCI core
if somehow pm_ops is not able to bind with the driver, else, required tasks
are managed by the core itself.

Compile-tested only.

Signed-off-by: Vaibhav Gupta <vaibhavgupta40@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Vaibhav Gupta 2020-06-22 17:12:25 +05:30 committed by David S. Miller
parent f906d0f9cd
commit fc9aebfbdb
1 changed files with 8 additions and 18 deletions

View File

@ -1530,8 +1530,6 @@ static void w840_remove1(struct pci_dev *pdev)
} }
} }
#ifdef CONFIG_PM
/* /*
* suspend/resume synchronization: * suspend/resume synchronization:
* - open, close, do_ioctl: * - open, close, do_ioctl:
@ -1555,9 +1553,9 @@ static void w840_remove1(struct pci_dev *pdev)
* Detach must occur under spin_unlock_irq(), interrupts from a detached * Detach must occur under spin_unlock_irq(), interrupts from a detached
* device would cause an irq storm. * device would cause an irq storm.
*/ */
static int w840_suspend (struct pci_dev *pdev, pm_message_t state) static int __maybe_unused w840_suspend(struct device *dev_d)
{ {
struct net_device *dev = pci_get_drvdata (pdev); struct net_device *dev = dev_get_drvdata(dev_d);
struct netdev_private *np = netdev_priv(dev); struct netdev_private *np = netdev_priv(dev);
void __iomem *ioaddr = np->base_addr; void __iomem *ioaddr = np->base_addr;
@ -1590,21 +1588,15 @@ static int w840_suspend (struct pci_dev *pdev, pm_message_t state)
return 0; return 0;
} }
static int w840_resume (struct pci_dev *pdev) static int __maybe_unused w840_resume(struct device *dev_d)
{ {
struct net_device *dev = pci_get_drvdata (pdev); struct net_device *dev = dev_get_drvdata(dev_d);
struct netdev_private *np = netdev_priv(dev); struct netdev_private *np = netdev_priv(dev);
int retval = 0;
rtnl_lock(); rtnl_lock();
if (netif_device_present(dev)) if (netif_device_present(dev))
goto out; /* device not suspended */ goto out; /* device not suspended */
if (netif_running(dev)) { if (netif_running(dev)) {
if ((retval = pci_enable_device(pdev))) {
dev_err(&dev->dev,
"pci_enable_device failed in resume\n");
goto out;
}
spin_lock_irq(&np->lock); spin_lock_irq(&np->lock);
iowrite32(1, np->base_addr+PCIBusCfg); iowrite32(1, np->base_addr+PCIBusCfg);
ioread32(np->base_addr+PCIBusCfg); ioread32(np->base_addr+PCIBusCfg);
@ -1622,19 +1614,17 @@ static int w840_resume (struct pci_dev *pdev)
} }
out: out:
rtnl_unlock(); rtnl_unlock();
return retval; return 0;
} }
#endif
static SIMPLE_DEV_PM_OPS(w840_pm_ops, w840_suspend, w840_resume);
static struct pci_driver w840_driver = { static struct pci_driver w840_driver = {
.name = DRV_NAME, .name = DRV_NAME,
.id_table = w840_pci_tbl, .id_table = w840_pci_tbl,
.probe = w840_probe1, .probe = w840_probe1,
.remove = w840_remove1, .remove = w840_remove1,
#ifdef CONFIG_PM .driver.pm = &w840_pm_ops,
.suspend = w840_suspend,
.resume = w840_resume,
#endif
}; };
static int __init w840_init(void) static int __init w840_init(void)