Commit 6d79dc67 authored by David S. Miller's avatar David S. Miller

Merge branch 'net-ethernet-use-generic-power-management'

Vaibhav Gupta says:

====================
net: ethernet: 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 net 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.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 4f195d28 40c1b1ee
...@@ -1801,9 +1801,8 @@ typhoon_free_rx_rings(struct typhoon *tp) ...@@ -1801,9 +1801,8 @@ typhoon_free_rx_rings(struct typhoon *tp)
} }
static int static int
typhoon_sleep(struct typhoon *tp, pci_power_t state, __le16 events) typhoon_sleep_early(struct typhoon *tp, __le16 events)
{ {
struct pci_dev *pdev = tp->pdev;
void __iomem *ioaddr = tp->ioaddr; void __iomem *ioaddr = tp->ioaddr;
struct cmd_desc xp_cmd; struct cmd_desc xp_cmd;
int err; int err;
...@@ -1832,20 +1831,29 @@ typhoon_sleep(struct typhoon *tp, pci_power_t state, __le16 events) ...@@ -1832,20 +1831,29 @@ typhoon_sleep(struct typhoon *tp, pci_power_t state, __le16 events)
*/ */
netif_carrier_off(tp->dev); netif_carrier_off(tp->dev);
return 0;
}
static int
typhoon_sleep(struct typhoon *tp, pci_power_t state, __le16 events)
{
int err;
err = typhoon_sleep_early(tp, events);
if (err)
return err;
pci_enable_wake(tp->pdev, state, 1); pci_enable_wake(tp->pdev, state, 1);
pci_disable_device(pdev); pci_disable_device(tp->pdev);
return pci_set_power_state(pdev, state); return pci_set_power_state(tp->pdev, state);
} }
static int static int
typhoon_wakeup(struct typhoon *tp, int wait_type) typhoon_wakeup(struct typhoon *tp, int wait_type)
{ {
struct pci_dev *pdev = tp->pdev;
void __iomem *ioaddr = tp->ioaddr; void __iomem *ioaddr = tp->ioaddr;
pci_set_power_state(pdev, PCI_D0);
pci_restore_state(pdev);
/* Post 2.x.x versions of the Sleep Image require a reset before /* Post 2.x.x versions of the Sleep Image require a reset before
* we can download the Runtime Image. But let's not make users of * we can download the Runtime Image. But let's not make users of
* the old firmware pay for the reset. * the old firmware pay for the reset.
...@@ -2049,6 +2057,9 @@ typhoon_open(struct net_device *dev) ...@@ -2049,6 +2057,9 @@ typhoon_open(struct net_device *dev)
if (err) if (err)
goto out; goto out;
pci_set_power_state(tp->pdev, PCI_D0);
pci_restore_state(tp->pdev);
err = typhoon_wakeup(tp, WaitSleep); err = typhoon_wakeup(tp, WaitSleep);
if (err < 0) { if (err < 0) {
netdev_err(dev, "unable to wakeup device\n"); netdev_err(dev, "unable to wakeup device\n");
...@@ -2114,11 +2125,10 @@ typhoon_close(struct net_device *dev) ...@@ -2114,11 +2125,10 @@ typhoon_close(struct net_device *dev)
return 0; return 0;
} }
#ifdef CONFIG_PM static int __maybe_unused
static int typhoon_resume(struct device *dev_d)
typhoon_resume(struct pci_dev *pdev)
{ {
struct net_device *dev = pci_get_drvdata(pdev); struct net_device *dev = dev_get_drvdata(dev_d);
struct typhoon *tp = netdev_priv(dev); struct typhoon *tp = netdev_priv(dev);
/* If we're down, resume when we are upped. /* If we're down, resume when we are upped.
...@@ -2144,9 +2154,10 @@ typhoon_resume(struct pci_dev *pdev) ...@@ -2144,9 +2154,10 @@ typhoon_resume(struct pci_dev *pdev)
return -EBUSY; return -EBUSY;
} }
static int static int __maybe_unused
typhoon_suspend(struct pci_dev *pdev, pm_message_t state) typhoon_suspend(struct device *dev_d)
{ {
struct pci_dev *pdev = to_pci_dev(dev_d);
struct net_device *dev = pci_get_drvdata(pdev); struct net_device *dev = pci_get_drvdata(pdev);
struct typhoon *tp = netdev_priv(dev); struct typhoon *tp = netdev_priv(dev);
struct cmd_desc xp_cmd; struct cmd_desc xp_cmd;
...@@ -2190,18 +2201,19 @@ typhoon_suspend(struct pci_dev *pdev, pm_message_t state) ...@@ -2190,18 +2201,19 @@ typhoon_suspend(struct pci_dev *pdev, pm_message_t state)
goto need_resume; goto need_resume;
} }
if (typhoon_sleep(tp, pci_choose_state(pdev, state), tp->wol_events) < 0) { if (typhoon_sleep_early(tp, tp->wol_events) < 0) {
netdev_err(dev, "unable to put card to sleep\n"); netdev_err(dev, "unable to put card to sleep\n");
goto need_resume; goto need_resume;
} }
device_wakeup_enable(dev_d);
return 0; return 0;
need_resume: need_resume:
typhoon_resume(pdev); typhoon_resume(dev_d);
return -EBUSY; return -EBUSY;
} }
#endif
static int static int
typhoon_test_mmio(struct pci_dev *pdev) typhoon_test_mmio(struct pci_dev *pdev)
...@@ -2533,15 +2545,14 @@ typhoon_remove_one(struct pci_dev *pdev) ...@@ -2533,15 +2545,14 @@ typhoon_remove_one(struct pci_dev *pdev)
free_netdev(dev); free_netdev(dev);
} }
static SIMPLE_DEV_PM_OPS(typhoon_pm_ops, typhoon_suspend, typhoon_resume);
static struct pci_driver typhoon_driver = { static struct pci_driver typhoon_driver = {
.name = KBUILD_MODNAME, .name = KBUILD_MODNAME,
.id_table = typhoon_pci_tbl, .id_table = typhoon_pci_tbl,
.probe = typhoon_init_one, .probe = typhoon_init_one,
.remove = typhoon_remove_one, .remove = typhoon_remove_one,
#ifdef CONFIG_PM .driver.pm = &typhoon_pm_ops,
.suspend = typhoon_suspend,
.resume = typhoon_resume,
#endif
}; };
static int __init static int __init
......
...@@ -699,30 +699,18 @@ static void ne2k_pci_remove_one(struct pci_dev *pdev) ...@@ -699,30 +699,18 @@ static void ne2k_pci_remove_one(struct pci_dev *pdev)
pci_disable_device(pdev); pci_disable_device(pdev);
} }
#ifdef CONFIG_PM static int __maybe_unused ne2k_pci_suspend(struct device *dev_d)
static int ne2k_pci_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);
netif_device_detach(dev); netif_device_detach(dev);
pci_save_state(pdev);
pci_disable_device(pdev);
pci_set_power_state(pdev, pci_choose_state(pdev, state));
return 0; return 0;
} }
static int ne2k_pci_resume(struct pci_dev *pdev) static int __maybe_unused ne2k_pci_resume(struct device *dev_d)
{ {
struct net_device *dev = pci_get_drvdata(pdev); struct net_device *dev = dev_get_drvdata(dev_d);
int rc;
pci_set_power_state(pdev, PCI_D0);
pci_restore_state(pdev);
rc = pci_enable_device(pdev);
if (rc)
return rc;
NS8390_init(dev, 1); NS8390_init(dev, 1);
netif_device_attach(dev); netif_device_attach(dev);
...@@ -730,19 +718,14 @@ static int ne2k_pci_resume(struct pci_dev *pdev) ...@@ -730,19 +718,14 @@ static int ne2k_pci_resume(struct pci_dev *pdev)
return 0; return 0;
} }
#endif /* CONFIG_PM */ static SIMPLE_DEV_PM_OPS(ne2k_pci_pm_ops, ne2k_pci_suspend, ne2k_pci_resume);
static struct pci_driver ne2k_driver = { static struct pci_driver ne2k_driver = {
.name = DRV_NAME, .name = DRV_NAME,
.probe = ne2k_pci_init_one, .probe = ne2k_pci_init_one,
.remove = ne2k_pci_remove_one, .remove = ne2k_pci_remove_one,
.id_table = ne2k_pci_tbl, .id_table = ne2k_pci_tbl,
#ifdef CONFIG_PM .driver.pm = &ne2k_pci_pm_ops,
.suspend = ne2k_pci_suspend,
.resume = ne2k_pci_resume,
#endif
}; };
......
...@@ -1984,28 +1984,21 @@ static int netdev_close(struct net_device *dev) ...@@ -1984,28 +1984,21 @@ static int netdev_close(struct net_device *dev)
return 0; return 0;
} }
#ifdef CONFIG_PM static int __maybe_unused starfire_suspend(struct device *dev_d)
static int starfire_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);
if (netif_running(dev)) { if (netif_running(dev)) {
netif_device_detach(dev); netif_device_detach(dev);
netdev_close(dev); netdev_close(dev);
} }
pci_save_state(pdev);
pci_set_power_state(pdev, pci_choose_state(pdev,state));
return 0; return 0;
} }
static int starfire_resume(struct pci_dev *pdev) static int __maybe_unused starfire_resume(struct device *dev_d)
{ {
struct net_device *dev = pci_get_drvdata(pdev); struct net_device *dev = dev_get_drvdata(dev_d);
pci_set_power_state(pdev, PCI_D0);
pci_restore_state(pdev);
if (netif_running(dev)) { if (netif_running(dev)) {
netdev_open(dev); netdev_open(dev);
...@@ -2014,8 +2007,6 @@ static int starfire_resume(struct pci_dev *pdev) ...@@ -2014,8 +2007,6 @@ static int starfire_resume(struct pci_dev *pdev)
return 0; return 0;
} }
#endif /* CONFIG_PM */
static void starfire_remove_one(struct pci_dev *pdev) static void starfire_remove_one(struct pci_dev *pdev)
{ {
...@@ -2040,15 +2031,13 @@ static void starfire_remove_one(struct pci_dev *pdev) ...@@ -2040,15 +2031,13 @@ static void starfire_remove_one(struct pci_dev *pdev)
free_netdev(dev); /* Will also free np!! */ free_netdev(dev); /* Will also free np!! */
} }
static SIMPLE_DEV_PM_OPS(starfire_pm_ops, starfire_suspend, starfire_resume);
static struct pci_driver starfire_driver = { static struct pci_driver starfire_driver = {
.name = DRV_NAME, .name = DRV_NAME,
.probe = starfire_init_one, .probe = starfire_init_one,
.remove = starfire_remove_one, .remove = starfire_remove_one,
#ifdef CONFIG_PM .driver.pm = &starfire_pm_ops,
.suspend = starfire_suspend,
.resume = starfire_resume,
#endif /* CONFIG_PM */
.id_table = starfire_pci_tbl, .id_table = starfire_pci_tbl,
}; };
......
...@@ -4420,13 +4420,12 @@ static void ena_shutdown(struct pci_dev *pdev) ...@@ -4420,13 +4420,12 @@ static void ena_shutdown(struct pci_dev *pdev)
__ena_shutoff(pdev, true); __ena_shutoff(pdev, true);
} }
#ifdef CONFIG_PM
/* ena_suspend - PM suspend callback /* ena_suspend - PM suspend callback
* @pdev: PCI device information struct * @dev_d: Device information struct
* @state:power state
*/ */
static int ena_suspend(struct pci_dev *pdev, pm_message_t state) static int __maybe_unused ena_suspend(struct device *dev_d)
{ {
struct pci_dev *pdev = to_pci_dev(dev_d);
struct ena_adapter *adapter = pci_get_drvdata(pdev); struct ena_adapter *adapter = pci_get_drvdata(pdev);
u64_stats_update_begin(&adapter->syncp); u64_stats_update_begin(&adapter->syncp);
...@@ -4445,12 +4444,11 @@ static int ena_suspend(struct pci_dev *pdev, pm_message_t state) ...@@ -4445,12 +4444,11 @@ static int ena_suspend(struct pci_dev *pdev, pm_message_t state)
} }
/* ena_resume - PM resume callback /* ena_resume - PM resume callback
* @pdev: PCI device information struct * @dev_d: Device information struct
*
*/ */
static int ena_resume(struct pci_dev *pdev) static int __maybe_unused ena_resume(struct device *dev_d)
{ {
struct ena_adapter *adapter = pci_get_drvdata(pdev); struct ena_adapter *adapter = dev_get_drvdata(dev_d);
int rc; int rc;
u64_stats_update_begin(&adapter->syncp); u64_stats_update_begin(&adapter->syncp);
...@@ -4462,7 +4460,8 @@ static int ena_resume(struct pci_dev *pdev) ...@@ -4462,7 +4460,8 @@ static int ena_resume(struct pci_dev *pdev)
rtnl_unlock(); rtnl_unlock();
return rc; return rc;
} }
#endif
static SIMPLE_DEV_PM_OPS(ena_pm_ops, ena_suspend, ena_resume);
static struct pci_driver ena_pci_driver = { static struct pci_driver ena_pci_driver = {
.name = DRV_MODULE_NAME, .name = DRV_MODULE_NAME,
...@@ -4470,10 +4469,7 @@ static struct pci_driver ena_pci_driver = { ...@@ -4470,10 +4469,7 @@ static struct pci_driver ena_pci_driver = {
.probe = ena_probe, .probe = ena_probe,
.remove = ena_remove, .remove = ena_remove,
.shutdown = ena_shutdown, .shutdown = ena_shutdown,
#ifdef CONFIG_PM .driver.pm = &ena_pm_ops,
.suspend = ena_suspend,
.resume = ena_resume,
#endif
.sriov_configure = pci_sriov_configure_simple, .sriov_configure = pci_sriov_configure_simple,
}; };
......
...@@ -405,27 +405,8 @@ static void liquidio_pcie_resume(struct pci_dev *pdev __attribute__((unused))) ...@@ -405,27 +405,8 @@ static void liquidio_pcie_resume(struct pci_dev *pdev __attribute__((unused)))
/* Nothing to be done here. */ /* Nothing to be done here. */
} }
#ifdef CONFIG_PM #define liquidio_suspend NULL
/** #define liquidio_resume NULL
* \brief called when suspending
* @param pdev Pointer to PCI device
* @param state state to suspend to
*/
static int liquidio_suspend(struct pci_dev *pdev __attribute__((unused)),
pm_message_t state __attribute__((unused)))
{
return 0;
}
/**
* \brief called when resuming
* @param pdev Pointer to PCI device
*/
static int liquidio_resume(struct pci_dev *pdev __attribute__((unused)))
{
return 0;
}
#endif
/* For PCI-E Advanced Error Recovery (AER) Interface */ /* For PCI-E Advanced Error Recovery (AER) Interface */
static const struct pci_error_handlers liquidio_err_handler = { static const struct pci_error_handlers liquidio_err_handler = {
...@@ -451,17 +432,15 @@ static const struct pci_device_id liquidio_pci_tbl[] = { ...@@ -451,17 +432,15 @@ static const struct pci_device_id liquidio_pci_tbl[] = {
}; };
MODULE_DEVICE_TABLE(pci, liquidio_pci_tbl); MODULE_DEVICE_TABLE(pci, liquidio_pci_tbl);
static SIMPLE_DEV_PM_OPS(liquidio_pm_ops, liquidio_suspend, liquidio_resume);
static struct pci_driver liquidio_pci_driver = { static struct pci_driver liquidio_pci_driver = {
.name = "LiquidIO", .name = "LiquidIO",
.id_table = liquidio_pci_tbl, .id_table = liquidio_pci_tbl,
.probe = liquidio_probe, .probe = liquidio_probe,
.remove = liquidio_remove, .remove = liquidio_remove,
.err_handler = &liquidio_err_handler, /* For AER */ .err_handler = &liquidio_err_handler, /* For AER */
.driver.pm = &liquidio_pm_ops,
#ifdef CONFIG_PM
.suspend = liquidio_suspend,
.resume = liquidio_resume,
#endif
#ifdef CONFIG_PCI_IOV #ifdef CONFIG_PCI_IOV
.sriov_configure = liquidio_enable_sriov, .sriov_configure = liquidio_enable_sriov,
#endif #endif
......
...@@ -1928,11 +1928,9 @@ static void sundance_remove1(struct pci_dev *pdev) ...@@ -1928,11 +1928,9 @@ static void sundance_remove1(struct pci_dev *pdev)
} }
} }
#ifdef CONFIG_PM static int __maybe_unused sundance_suspend(struct device *dev_d)
static int sundance_suspend(struct pci_dev *pci_dev, pm_message_t state)
{ {
struct net_device *dev = pci_get_drvdata(pci_dev); 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; void __iomem *ioaddr = np->base;
...@@ -1942,30 +1940,24 @@ static int sundance_suspend(struct pci_dev *pci_dev, pm_message_t state) ...@@ -1942,30 +1940,24 @@ static int sundance_suspend(struct pci_dev *pci_dev, pm_message_t state)
netdev_close(dev); netdev_close(dev);
netif_device_detach(dev); netif_device_detach(dev);
pci_save_state(pci_dev);
if (np->wol_enabled) { if (np->wol_enabled) {
iowrite8(AcceptBroadcast | AcceptMyPhys, ioaddr + RxMode); iowrite8(AcceptBroadcast | AcceptMyPhys, ioaddr + RxMode);
iowrite16(RxEnable, ioaddr + MACCtrl1); iowrite16(RxEnable, ioaddr + MACCtrl1);
} }
pci_enable_wake(pci_dev, pci_choose_state(pci_dev, state),
np->wol_enabled); device_set_wakeup_enable(dev_d, np->wol_enabled);
pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state));
return 0; return 0;
} }
static int sundance_resume(struct pci_dev *pci_dev) static int __maybe_unused sundance_resume(struct device *dev_d)
{ {
struct net_device *dev = pci_get_drvdata(pci_dev); struct net_device *dev = dev_get_drvdata(dev_d);
int err = 0; int err = 0;
if (!netif_running(dev)) if (!netif_running(dev))
return 0; return 0;
pci_set_power_state(pci_dev, PCI_D0);
pci_restore_state(pci_dev);
pci_enable_wake(pci_dev, PCI_D0, 0);
err = netdev_open(dev); err = netdev_open(dev);
if (err) { if (err) {
printk(KERN_ERR "%s: Can't resume interface!\n", printk(KERN_ERR "%s: Can't resume interface!\n",
...@@ -1979,17 +1971,14 @@ static int sundance_resume(struct pci_dev *pci_dev) ...@@ -1979,17 +1971,14 @@ static int sundance_resume(struct pci_dev *pci_dev)
return err; return err;
} }
#endif /* CONFIG_PM */ static SIMPLE_DEV_PM_OPS(sundance_pm_ops, sundance_suspend, sundance_resume);
static struct pci_driver sundance_driver = { static struct pci_driver sundance_driver = {
.name = DRV_NAME, .name = DRV_NAME,
.id_table = sundance_pci_tbl, .id_table = sundance_pci_tbl,
.probe = sundance_probe1, .probe = sundance_probe1,
.remove = sundance_remove1, .remove = sundance_remove1,
#ifdef CONFIG_PM .driver.pm = &sundance_pm_ops,
.suspend = sundance_suspend,
.resume = sundance_resume,
#endif /* CONFIG_PM */
}; };
static int __init sundance_init(void) static int __init sundance_init(void)
......
...@@ -6037,32 +6037,23 @@ static int be_probe(struct pci_dev *pdev, const struct pci_device_id *pdev_id) ...@@ -6037,32 +6037,23 @@ static int be_probe(struct pci_dev *pdev, const struct pci_device_id *pdev_id)
return status; return status;
} }
static int be_suspend(struct pci_dev *pdev, pm_message_t state) static int __maybe_unused be_suspend(struct device *dev_d)
{ {
struct be_adapter *adapter = pci_get_drvdata(pdev); struct be_adapter *adapter = dev_get_drvdata(dev_d);
be_intr_set(adapter, false); be_intr_set(adapter, false);
be_cancel_err_detection(adapter); be_cancel_err_detection(adapter);
be_cleanup(adapter); be_cleanup(adapter);
pci_save_state(pdev);
pci_disable_device(pdev);
pci_set_power_state(pdev, pci_choose_state(pdev, state));
return 0; return 0;
} }
static int be_pci_resume(struct pci_dev *pdev) static int __maybe_unused be_pci_resume(struct device *dev_d)
{ {
struct be_adapter *adapter = pci_get_drvdata(pdev); struct be_adapter *adapter = dev_get_drvdata(dev_d);
int status = 0; int status = 0;
status = pci_enable_device(pdev);
if (status)
return status;
pci_restore_state(pdev);
status = be_resume(adapter); status = be_resume(adapter);
if (status) if (status)
return status; return status;
...@@ -6234,13 +6225,14 @@ static const struct pci_error_handlers be_eeh_handlers = { ...@@ -6234,13 +6225,14 @@ static const struct pci_error_handlers be_eeh_handlers = {
.resume = be_eeh_resume, .resume = be_eeh_resume,
}; };
static SIMPLE_DEV_PM_OPS(be_pci_pm_ops, be_suspend, be_pci_resume);
static struct pci_driver be_driver = { static struct pci_driver be_driver = {
.name = DRV_NAME, .name = DRV_NAME,
.id_table = be_dev_ids, .id_table = be_dev_ids,
.probe = be_probe, .probe = be_probe,
.remove = be_remove, .remove = be_remove,
.suspend = be_suspend, .driver.pm = &be_pci_pm_ops,
.resume = be_pci_resume,
.shutdown = be_shutdown, .shutdown = be_shutdown,
.sriov_configure = be_pci_sriov_configure, .sriov_configure = be_pci_sriov_configure,
.err_handler = &be_eeh_handlers .err_handler = &be_eeh_handlers
......
...@@ -4370,8 +4370,9 @@ static const struct pci_error_handlers mlx4_err_handler = { ...@@ -4370,8 +4370,9 @@ static const struct pci_error_handlers mlx4_err_handler = {
.resume = mlx4_pci_resume, .resume = mlx4_pci_resume,
}; };
static int mlx4_suspend(struct pci_dev *pdev, pm_message_t state) static int mlx4_suspend(struct device *dev_d)
{ {
struct pci_dev *pdev = to_pci_dev(dev_d);
struct mlx4_dev_persistent *persist = pci_get_drvdata(pdev); struct mlx4_dev_persistent *persist = pci_get_drvdata(pdev);
struct mlx4_dev *dev = persist->dev; struct mlx4_dev *dev = persist->dev;
...@@ -4384,8 +4385,9 @@ static int mlx4_suspend(struct pci_dev *pdev, pm_message_t state) ...@@ -4384,8 +4385,9 @@ static int mlx4_suspend(struct pci_dev *pdev, pm_message_t state)
return 0; return 0;
} }
static int mlx4_resume(struct pci_dev *pdev) static int mlx4_resume(struct device *dev_d)
{ {
struct pci_dev *pdev = to_pci_dev(dev_d);
struct mlx4_dev_persistent *persist = pci_get_drvdata(pdev); struct mlx4_dev_persistent *persist = pci_get_drvdata(pdev);
struct mlx4_dev *dev = persist->dev; struct mlx4_dev *dev = persist->dev;
struct mlx4_priv *priv = mlx4_priv(dev); struct mlx4_priv *priv = mlx4_priv(dev);
...@@ -4414,14 +4416,15 @@ static int mlx4_resume(struct pci_dev *pdev) ...@@ -4414,14 +4416,15 @@ static int mlx4_resume(struct pci_dev *pdev)
return ret; return ret;
} }
static SIMPLE_DEV_PM_OPS(mlx4_pm_ops, mlx4_suspend, mlx4_resume);
static struct pci_driver mlx4_driver = { static struct pci_driver mlx4_driver = {
.name = DRV_NAME, .name = DRV_NAME,
.id_table = mlx4_pci_table, .id_table = mlx4_pci_table,
.probe = mlx4_init_one, .probe = mlx4_init_one,
.shutdown = mlx4_shutdown, .shutdown = mlx4_shutdown,
.remove = mlx4_remove_one, .remove = mlx4_remove_one,
.suspend = mlx4_suspend, .driver.pm = &mlx4_pm_ops,
.resume = mlx4_resume,
.err_handler = &mlx4_err_handler, .err_handler = &mlx4_err_handler,
}; };
......
...@@ -7155,17 +7155,14 @@ static void pcidev_exit(struct pci_dev *pdev) ...@@ -7155,17 +7155,14 @@ static void pcidev_exit(struct pci_dev *pdev)
kfree(info); kfree(info);
} }
#ifdef CONFIG_PM static int __maybe_unused pcidev_resume(struct device *dev_d)
static int pcidev_resume(struct pci_dev *pdev)
{ {
int i; int i;
struct platform_info *info = pci_get_drvdata(pdev); struct platform_info *info = dev_get_drvdata(dev_d);
struct dev_info *hw_priv = &info->dev_info; struct dev_info *hw_priv = &info->dev_info;
struct ksz_hw *hw = &hw_priv->hw; struct ksz_hw *hw = &hw_priv->hw;
pci_set_power_state(pdev, PCI_D0); device_wakeup_disable(dev_d);
pci_restore_state(pdev);
pci_enable_wake(pdev, PCI_D0, 0);
if (hw_priv->wol_enable) if (hw_priv->wol_enable)
hw_cfg_wol_pme(hw, 0); hw_cfg_wol_pme(hw, 0);
...@@ -7182,10 +7179,10 @@ static int pcidev_resume(struct pci_dev *pdev) ...@@ -7182,10 +7179,10 @@ static int pcidev_resume(struct pci_dev *pdev)
return 0; return 0;
} }
static int pcidev_suspend(struct pci_dev *pdev, pm_message_t state) static int pcidev_suspend(struct device *dev_d)
{ {
int i; int i;
struct platform_info *info = pci_get_drvdata(pdev); struct platform_info *info = dev_get_drvdata(dev_d);
struct dev_info *hw_priv = &info->dev_info; struct dev_info *hw_priv = &info->dev_info;
struct ksz_hw *hw = &hw_priv->hw; struct ksz_hw *hw = &hw_priv->hw;
...@@ -7207,12 +7204,9 @@ static int pcidev_suspend(struct pci_dev *pdev, pm_message_t state) ...@@ -7207,12 +7204,9 @@ static int pcidev_suspend(struct pci_dev *pdev, pm_message_t state)
hw_cfg_wol_pme(hw, 1); hw_cfg_wol_pme(hw, 1);
} }
pci_save_state(pdev); device_wakeup_enable(dev_d);
pci_enable_wake(pdev, pci_choose_state(pdev, state), 1);
pci_set_power_state(pdev, pci_choose_state(pdev, state));
return 0; return 0;
} }
#endif
static char pcidev_name[] = "ksz884xp"; static char pcidev_name[] = "ksz884xp";
...@@ -7226,11 +7220,10 @@ static const struct pci_device_id pcidev_table[] = { ...@@ -7226,11 +7220,10 @@ static const struct pci_device_id pcidev_table[] = {
MODULE_DEVICE_TABLE(pci, pcidev_table); MODULE_DEVICE_TABLE(pci, pcidev_table);
static SIMPLE_DEV_PM_OPS(pcidev_pm_ops, pcidev_suspend, pcidev_resume);
static struct pci_driver pci_device_driver = { static struct pci_driver pci_device_driver = {
#ifdef CONFIG_PM .driver.pm = &pcidev_pm_ops,
.suspend = pcidev_suspend,
.resume = pcidev_resume,
#endif
.name = pcidev_name, .name = pcidev_name,
.id_table = pcidev_table, .id_table = pcidev_table,
.probe = pcidev_init, .probe = pcidev_init,
......
...@@ -3247,8 +3247,6 @@ static void natsemi_remove1(struct pci_dev *pdev) ...@@ -3247,8 +3247,6 @@ static void natsemi_remove1(struct pci_dev *pdev)
free_netdev (dev); free_netdev (dev);
} }
#ifdef CONFIG_PM
/* /*
* The ns83815 chip doesn't have explicit RxStop bits. * The ns83815 chip doesn't have explicit RxStop bits.
* Kicking the Rx or Tx process for a new packet reenables the Rx process * Kicking the Rx or Tx process for a new packet reenables the Rx process
...@@ -3275,9 +3273,9 @@ static void natsemi_remove1(struct pci_dev *pdev) ...@@ -3275,9 +3273,9 @@ static void natsemi_remove1(struct pci_dev *pdev)
* Interrupts must be disabled, otherwise hands_off can cause irq storms. * Interrupts must be disabled, otherwise hands_off can cause irq storms.
*/ */
static int natsemi_suspend (struct pci_dev *pdev, pm_message_t state) static int __maybe_unused natsemi_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 = ns_ioaddr(dev); void __iomem * ioaddr = ns_ioaddr(dev);
...@@ -3326,11 +3324,10 @@ static int natsemi_suspend (struct pci_dev *pdev, pm_message_t state) ...@@ -3326,11 +3324,10 @@ static int natsemi_suspend (struct pci_dev *pdev, pm_message_t state)
} }
static int natsemi_resume (struct pci_dev *pdev) static int __maybe_unused natsemi_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 ret = 0;
rtnl_lock(); rtnl_lock();
if (netif_device_present(dev)) if (netif_device_present(dev))
...@@ -3339,12 +3336,6 @@ static int natsemi_resume (struct pci_dev *pdev) ...@@ -3339,12 +3336,6 @@ static int natsemi_resume (struct pci_dev *pdev)
const int irq = np->pci_dev->irq; const int irq = np->pci_dev->irq;
BUG_ON(!np->hands_off); BUG_ON(!np->hands_off);
ret = pci_enable_device(pdev);
if (ret < 0) {
dev_err(&pdev->dev,
"pci_enable_device() failed: %d\n", ret);
goto out;
}
/* pci_power_on(pdev); */ /* pci_power_on(pdev); */
napi_enable(&np->napi); napi_enable(&np->napi);
...@@ -3364,20 +3355,17 @@ static int natsemi_resume (struct pci_dev *pdev) ...@@ -3364,20 +3355,17 @@ static int natsemi_resume (struct pci_dev *pdev)
netif_device_attach(dev); netif_device_attach(dev);
out: out:
rtnl_unlock(); rtnl_unlock();
return ret; return 0;
} }
#endif /* CONFIG_PM */ static SIMPLE_DEV_PM_OPS(natsemi_pm_ops, natsemi_suspend, natsemi_resume);
static struct pci_driver natsemi_driver = { static struct pci_driver natsemi_driver = {
.name = DRV_NAME, .name = DRV_NAME,
.id_table = natsemi_pci_tbl, .id_table = natsemi_pci_tbl,
.probe = natsemi_probe1, .probe = natsemi_probe1,
.remove = natsemi_remove1, .remove = natsemi_remove1,
#ifdef CONFIG_PM .driver.pm = &natsemi_pm_ops,
.suspend = natsemi_suspend,
.resume = natsemi_resume,
#endif
}; };
static int __init natsemi_init_mod (void) static int __init natsemi_init_mod (void)
......
...@@ -3999,12 +3999,11 @@ static void vxge_print_parm(struct vxgedev *vdev, u64 vpath_mask) ...@@ -3999,12 +3999,11 @@ static void vxge_print_parm(struct vxgedev *vdev, u64 vpath_mask)
} }
} }
#ifdef CONFIG_PM
/** /**
* vxge_pm_suspend - vxge power management suspend entry point * vxge_pm_suspend - vxge power management suspend entry point
* *
*/ */
static int vxge_pm_suspend(struct pci_dev *pdev, pm_message_t state) static int __maybe_unused vxge_pm_suspend(struct device *dev_d)
{ {
return -ENOSYS; return -ENOSYS;
} }
...@@ -4012,13 +4011,11 @@ static int vxge_pm_suspend(struct pci_dev *pdev, pm_message_t state) ...@@ -4012,13 +4011,11 @@ static int vxge_pm_suspend(struct pci_dev *pdev, pm_message_t state)
* vxge_pm_resume - vxge power management resume entry point * vxge_pm_resume - vxge power management resume entry point
* *
*/ */
static int vxge_pm_resume(struct pci_dev *pdev) static int __maybe_unused vxge_pm_resume(struct device *dev_d)
{ {
return -ENOSYS; return -ENOSYS;
} }
#endif
/** /**
* vxge_io_error_detected - called when PCI error is detected * vxge_io_error_detected - called when PCI error is detected
* @pdev: Pointer to PCI device * @pdev: Pointer to PCI device
...@@ -4796,15 +4793,14 @@ static const struct pci_error_handlers vxge_err_handler = { ...@@ -4796,15 +4793,14 @@ static const struct pci_error_handlers vxge_err_handler = {
.resume = vxge_io_resume, .resume = vxge_io_resume,
}; };
static SIMPLE_DEV_PM_OPS(vxge_pm_ops, vxge_pm_suspend, vxge_pm_resume);
static struct pci_driver vxge_driver = { static struct pci_driver vxge_driver = {
.name = VXGE_DRIVER_NAME, .name = VXGE_DRIVER_NAME,
.id_table = vxge_id_table, .id_table = vxge_id_table,
.probe = vxge_probe, .probe = vxge_probe,
.remove = vxge_remove, .remove = vxge_remove,
#ifdef CONFIG_PM .driver.pm = &vxge_pm_ops,
.suspend = vxge_pm_suspend,
.resume = vxge_pm_resume,
#endif
.err_handler = &vxge_err_handler, .err_handler = &vxge_err_handler,
}; };
......
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