summaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/smsc/smsc9420.c
diff options
context:
space:
mode:
authorVaibhav Gupta <vaibhavgupta40@gmail.com>2020-07-03 05:01:38 +0200
committerDavid S. Miller <davem@davemloft.net>2020-07-08 00:20:49 +0200
commit53fff2bfb3fcce7f7e8ac424da73070ac7a550da (patch)
tree47c75a21e27a86789e05551af64e9b20eb94f090 /drivers/net/ethernet/smsc/smsc9420.c
parentepic100: use generic power management (diff)
downloadlinux-53fff2bfb3fcce7f7e8ac424da73070ac7a550da.tar.xz
linux-53fff2bfb3fcce7f7e8ac424da73070ac7a550da.zip
smsc9420: use generic power management
Drivers should not use legacy power management as they have to manage power states and related operations, for the device, themselves. This driver was handling them with the help of PCI helper functions. With generic PM, all essentials will be handled by the PCI core. Driver needs to do only device-specific operations. Compile-tested only. Signed-off-by: Vaibhav Gupta <vaibhavgupta40@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/smsc/smsc9420.c')
-rw-r--r--drivers/net/ethernet/smsc/smsc9420.c40
1 files changed, 11 insertions, 29 deletions
diff --git a/drivers/net/ethernet/smsc/smsc9420.c b/drivers/net/ethernet/smsc/smsc9420.c
index 7312e522c022..42bef04d65ba 100644
--- a/drivers/net/ethernet/smsc/smsc9420.c
+++ b/drivers/net/ethernet/smsc/smsc9420.c
@@ -1422,11 +1422,9 @@ out_0:
return result;
}
-#ifdef CONFIG_PM
-
-static int smsc9420_suspend(struct pci_dev *pdev, pm_message_t state)
+static int __maybe_unused smsc9420_suspend(struct device *dev_d)
{
- struct net_device *dev = pci_get_drvdata(pdev);
+ struct net_device *dev = dev_get_drvdata(dev_d);
struct smsc9420_pdata *pd = netdev_priv(dev);
u32 int_cfg;
ulong flags;
@@ -1451,34 +1449,21 @@ static int smsc9420_suspend(struct pci_dev *pdev, pm_message_t state)
netif_device_detach(dev);
}
- pci_save_state(pdev);
- pci_enable_wake(pdev, pci_choose_state(pdev, state), 0);
- pci_disable_device(pdev);
- pci_set_power_state(pdev, pci_choose_state(pdev, state));
+ device_wakeup_disable(dev_d);
return 0;
}
-static int smsc9420_resume(struct pci_dev *pdev)
+static int __maybe_unused smsc9420_resume(struct device *dev_d)
{
- struct net_device *dev = pci_get_drvdata(pdev);
- struct smsc9420_pdata *pd = netdev_priv(dev);
+ struct net_device *dev = dev_get_drvdata(dev_d);
int err;
- pci_set_power_state(pdev, PCI_D0);
- pci_restore_state(pdev);
-
- err = pci_enable_device(pdev);
- if (err)
- return err;
+ pci_set_master(to_pci_dev(dev_d));
- pci_set_master(pdev);
-
- err = pci_enable_wake(pdev, PCI_D0, 0);
- if (err)
- netif_warn(pd, ifup, pd->dev, "pci_enable_wake failed: %d\n",
- err);
+ device_wakeup_disable(dev_d);
+ err = 0;
if (netif_running(dev)) {
/* FIXME: gross. It looks like ancient PM relic.*/
err = smsc9420_open(dev);
@@ -1487,8 +1472,6 @@ static int smsc9420_resume(struct pci_dev *pdev)
return err;
}
-#endif /* CONFIG_PM */
-
static const struct net_device_ops smsc9420_netdev_ops = {
.ndo_open = smsc9420_open,
.ndo_stop = smsc9420_stop,
@@ -1658,15 +1641,14 @@ static void smsc9420_remove(struct pci_dev *pdev)
pci_disable_device(pdev);
}
+static SIMPLE_DEV_PM_OPS(smsc9420_pm_ops, smsc9420_suspend, smsc9420_resume);
+
static struct pci_driver smsc9420_driver = {
.name = DRV_NAME,
.id_table = smsc9420_id_table,
.probe = smsc9420_probe,
.remove = smsc9420_remove,
-#ifdef CONFIG_PM
- .suspend = smsc9420_suspend,
- .resume = smsc9420_resume,
-#endif /* CONFIG_PM */
+ .driver.pm = &smsc9420_pm_ops,
};
static int __init smsc9420_init_module(void)