Commit 9914175f authored by David S. Miller's avatar David S. Miller

Merge branch 'smsc-use-generic-power-management'

Vaibhav Gupta says:

====================
smsc: use generic power management

Linux Kernel Mentee: Remove Legacy Power Management.

The purpose of this patch series is to remove legacy power management callbacks
from smsc ethernet drivers.

The callbacks performing suspend() and resume() operations are still calling
pci_save_state(), pci_set_power_state(), etc. and handling the power management
themselves, which is not recommended.

The conversion requires the removal of the those function calls and change the
callback definition accordingly and make use of dev_pm_ops structure.

All patches are compile-tested only.

V2: Kbuild in V1, warning: variable 'err' is used uninitialized whenever 'if'
conditio is false in funcution .resume() .
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 4e48978c 53fff2bf
...@@ -1512,12 +1512,9 @@ static void epic_remove_one(struct pci_dev *pdev) ...@@ -1512,12 +1512,9 @@ static void epic_remove_one(struct pci_dev *pdev)
/* pci_power_off(pdev, -1); */ /* pci_power_off(pdev, -1); */
} }
static int __maybe_unused epic_suspend(struct device *dev_d)
#ifdef CONFIG_PM
static int epic_suspend (struct pci_dev *pdev, pm_message_t state)
{ {
struct net_device *dev = pci_get_drvdata(pdev); struct net_device *dev = dev_get_drvdata(dev_d);
struct epic_private *ep = netdev_priv(dev); struct epic_private *ep = netdev_priv(dev);
void __iomem *ioaddr = ep->ioaddr; void __iomem *ioaddr = ep->ioaddr;
...@@ -1531,9 +1528,9 @@ static int epic_suspend (struct pci_dev *pdev, pm_message_t state) ...@@ -1531,9 +1528,9 @@ static int epic_suspend (struct pci_dev *pdev, pm_message_t state)
} }
static int epic_resume (struct pci_dev *pdev) static int __maybe_unused epic_resume(struct device *dev_d)
{ {
struct net_device *dev = pci_get_drvdata(pdev); struct net_device *dev = dev_get_drvdata(dev_d);
if (!netif_running(dev)) if (!netif_running(dev))
return 0; return 0;
...@@ -1542,18 +1539,14 @@ static int epic_resume (struct pci_dev *pdev) ...@@ -1542,18 +1539,14 @@ static int epic_resume (struct pci_dev *pdev)
return 0; return 0;
} }
#endif /* CONFIG_PM */ static SIMPLE_DEV_PM_OPS(epic_pm_ops, epic_suspend, epic_resume);
static struct pci_driver epic_driver = { static struct pci_driver epic_driver = {
.name = DRV_NAME, .name = DRV_NAME,
.id_table = epic_pci_tbl, .id_table = epic_pci_tbl,
.probe = epic_init_one, .probe = epic_init_one,
.remove = epic_remove_one, .remove = epic_remove_one,
#ifdef CONFIG_PM .driver.pm = &epic_pm_ops,
.suspend = epic_suspend,
.resume = epic_resume,
#endif /* CONFIG_PM */
}; };
......
...@@ -1422,11 +1422,9 @@ static int smsc9420_open(struct net_device *dev) ...@@ -1422,11 +1422,9 @@ static int smsc9420_open(struct net_device *dev)
return result; return result;
} }
#ifdef CONFIG_PM static int __maybe_unused smsc9420_suspend(struct device *dev_d)
static int smsc9420_suspend(struct pci_dev *pdev, pm_message_t state)
{ {
struct net_device *dev = pci_get_drvdata(pdev); struct net_device *dev = dev_get_drvdata(dev_d);
struct smsc9420_pdata *pd = netdev_priv(dev); struct smsc9420_pdata *pd = netdev_priv(dev);
u32 int_cfg; u32 int_cfg;
ulong flags; ulong flags;
...@@ -1451,34 +1449,21 @@ static int smsc9420_suspend(struct pci_dev *pdev, pm_message_t state) ...@@ -1451,34 +1449,21 @@ static int smsc9420_suspend(struct pci_dev *pdev, pm_message_t state)
netif_device_detach(dev); netif_device_detach(dev);
} }
pci_save_state(pdev); device_wakeup_disable(dev_d);
pci_enable_wake(pdev, pci_choose_state(pdev, state), 0);
pci_disable_device(pdev);
pci_set_power_state(pdev, pci_choose_state(pdev, state));
return 0; 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 net_device *dev = dev_get_drvdata(dev_d);
struct smsc9420_pdata *pd = netdev_priv(dev);
int err; int err;
pci_set_power_state(pdev, PCI_D0); pci_set_master(to_pci_dev(dev_d));
pci_restore_state(pdev);
err = pci_enable_device(pdev);
if (err)
return err;
pci_set_master(pdev); device_wakeup_disable(dev_d);
err = pci_enable_wake(pdev, PCI_D0, 0);
if (err)
netif_warn(pd, ifup, pd->dev, "pci_enable_wake failed: %d\n",
err);
err = 0;
if (netif_running(dev)) { if (netif_running(dev)) {
/* FIXME: gross. It looks like ancient PM relic.*/ /* FIXME: gross. It looks like ancient PM relic.*/
err = smsc9420_open(dev); err = smsc9420_open(dev);
...@@ -1487,8 +1472,6 @@ static int smsc9420_resume(struct pci_dev *pdev) ...@@ -1487,8 +1472,6 @@ static int smsc9420_resume(struct pci_dev *pdev)
return err; return err;
} }
#endif /* CONFIG_PM */
static const struct net_device_ops smsc9420_netdev_ops = { static const struct net_device_ops smsc9420_netdev_ops = {
.ndo_open = smsc9420_open, .ndo_open = smsc9420_open,
.ndo_stop = smsc9420_stop, .ndo_stop = smsc9420_stop,
...@@ -1658,15 +1641,14 @@ static void smsc9420_remove(struct pci_dev *pdev) ...@@ -1658,15 +1641,14 @@ static void smsc9420_remove(struct pci_dev *pdev)
pci_disable_device(pdev); pci_disable_device(pdev);
} }
static SIMPLE_DEV_PM_OPS(smsc9420_pm_ops, smsc9420_suspend, smsc9420_resume);
static struct pci_driver smsc9420_driver = { static struct pci_driver smsc9420_driver = {
.name = DRV_NAME, .name = DRV_NAME,
.id_table = smsc9420_id_table, .id_table = smsc9420_id_table,
.probe = smsc9420_probe, .probe = smsc9420_probe,
.remove = smsc9420_remove, .remove = smsc9420_remove,
#ifdef CONFIG_PM .driver.pm = &smsc9420_pm_ops,
.suspend = smsc9420_suspend,
.resume = smsc9420_resume,
#endif /* CONFIG_PM */
}; };
static int __init smsc9420_init_module(void) static int __init smsc9420_init_module(void)
......
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