Commit 83184b8b authored by David S. Miller's avatar David S. Miller

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

Vaibhav Gupta says:

====================
ethernet: sun: 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 sun 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 5bd6ff0c f193f4eb
...@@ -5172,10 +5172,9 @@ static void cas_remove_one(struct pci_dev *pdev) ...@@ -5172,10 +5172,9 @@ static void cas_remove_one(struct pci_dev *pdev)
pci_disable_device(pdev); pci_disable_device(pdev);
} }
#ifdef CONFIG_PM static int __maybe_unused cas_suspend(struct device *dev_d)
static int cas_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 cas *cp = netdev_priv(dev); struct cas *cp = netdev_priv(dev);
unsigned long flags; unsigned long flags;
...@@ -5204,9 +5203,9 @@ static int cas_suspend(struct pci_dev *pdev, pm_message_t state) ...@@ -5204,9 +5203,9 @@ static int cas_suspend(struct pci_dev *pdev, pm_message_t state)
return 0; return 0;
} }
static int cas_resume(struct pci_dev *pdev) static int cas_resume(struct device *dev_d)
{ {
struct net_device *dev = pci_get_drvdata(pdev); struct net_device *dev = dev_get_drvdata(dev_d);
struct cas *cp = netdev_priv(dev); struct cas *cp = netdev_priv(dev);
netdev_info(dev, "resuming\n"); netdev_info(dev, "resuming\n");
...@@ -5227,17 +5226,15 @@ static int cas_resume(struct pci_dev *pdev) ...@@ -5227,17 +5226,15 @@ static int cas_resume(struct pci_dev *pdev)
mutex_unlock(&cp->pm_mutex); mutex_unlock(&cp->pm_mutex);
return 0; return 0;
} }
#endif /* CONFIG_PM */
static SIMPLE_DEV_PM_OPS(cas_pm_ops, cas_suspend, cas_resume);
static struct pci_driver cas_driver = { static struct pci_driver cas_driver = {
.name = DRV_MODULE_NAME, .name = DRV_MODULE_NAME,
.id_table = cas_pci_tbl, .id_table = cas_pci_tbl,
.probe = cas_init_one, .probe = cas_init_one,
.remove = cas_remove_one, .remove = cas_remove_one,
#ifdef CONFIG_PM .driver.pm = &cas_pm_ops,
.suspend = cas_suspend,
.resume = cas_resume
#endif
}; };
static int __init cas_init(void) static int __init cas_init(void)
......
...@@ -9873,9 +9873,9 @@ static void niu_pci_remove_one(struct pci_dev *pdev) ...@@ -9873,9 +9873,9 @@ static void niu_pci_remove_one(struct pci_dev *pdev)
} }
} }
static int niu_suspend(struct pci_dev *pdev, pm_message_t state) static int niu_suspend(struct device *dev_d)
{ {
struct net_device *dev = pci_get_drvdata(pdev); struct net_device *dev = dev_get_drvdata(dev_d);
struct niu *np = netdev_priv(dev); struct niu *np = netdev_priv(dev);
unsigned long flags; unsigned long flags;
...@@ -9897,14 +9897,12 @@ static int niu_suspend(struct pci_dev *pdev, pm_message_t state) ...@@ -9897,14 +9897,12 @@ static int niu_suspend(struct pci_dev *pdev, pm_message_t state)
niu_stop_hw(np); niu_stop_hw(np);
spin_unlock_irqrestore(&np->lock, flags); spin_unlock_irqrestore(&np->lock, flags);
pci_save_state(pdev);
return 0; return 0;
} }
static int niu_resume(struct pci_dev *pdev) static int niu_resume(struct device *dev_d)
{ {
struct net_device *dev = pci_get_drvdata(pdev); struct net_device *dev = dev_get_drvdata(dev_d);
struct niu *np = netdev_priv(dev); struct niu *np = netdev_priv(dev);
unsigned long flags; unsigned long flags;
int err; int err;
...@@ -9912,8 +9910,6 @@ static int niu_resume(struct pci_dev *pdev) ...@@ -9912,8 +9910,6 @@ static int niu_resume(struct pci_dev *pdev)
if (!netif_running(dev)) if (!netif_running(dev))
return 0; return 0;
pci_restore_state(pdev);
netif_device_attach(dev); netif_device_attach(dev);
spin_lock_irqsave(&np->lock, flags); spin_lock_irqsave(&np->lock, flags);
...@@ -9930,13 +9926,14 @@ static int niu_resume(struct pci_dev *pdev) ...@@ -9930,13 +9926,14 @@ static int niu_resume(struct pci_dev *pdev)
return err; return err;
} }
static SIMPLE_DEV_PM_OPS(niu_pm_ops, niu_suspend, niu_resume);
static struct pci_driver niu_pci_driver = { static struct pci_driver niu_pci_driver = {
.name = DRV_MODULE_NAME, .name = DRV_MODULE_NAME,
.id_table = niu_pci_tbl, .id_table = niu_pci_tbl,
.probe = niu_pci_init_one, .probe = niu_pci_init_one,
.remove = niu_pci_remove_one, .remove = niu_pci_remove_one,
.suspend = niu_suspend, .driver.pm = &niu_pm_ops,
.resume = niu_resume,
}; };
#ifdef CONFIG_SPARC64 #ifdef CONFIG_SPARC64
......
...@@ -2139,20 +2139,6 @@ static int gem_do_start(struct net_device *dev) ...@@ -2139,20 +2139,6 @@ static int gem_do_start(struct net_device *dev)
struct gem *gp = netdev_priv(dev); struct gem *gp = netdev_priv(dev);
int rc; int rc;
/* Enable the cell */
gem_get_cell(gp);
/* Make sure PCI access and bus master are enabled */
rc = pci_enable_device(gp->pdev);
if (rc) {
netdev_err(dev, "Failed to enable chip on PCI bus !\n");
/* Put cell and forget it for now, it will be considered as
* still asleep, a new sleep cycle may bring it back
*/
gem_put_cell(gp);
return -ENXIO;
}
pci_set_master(gp->pdev); pci_set_master(gp->pdev);
/* Init & setup chip hardware */ /* Init & setup chip hardware */
...@@ -2230,13 +2216,6 @@ static void gem_do_stop(struct net_device *dev, int wol) ...@@ -2230,13 +2216,6 @@ static void gem_do_stop(struct net_device *dev, int wol)
/* Shut the PHY down eventually and setup WOL */ /* Shut the PHY down eventually and setup WOL */
gem_stop_phy(gp, wol); gem_stop_phy(gp, wol);
/* Make sure bus master is disabled */
pci_disable_device(gp->pdev);
/* Cell not needed neither if no WOL */
if (!wol)
gem_put_cell(gp);
} }
static void gem_reset_task(struct work_struct *work) static void gem_reset_task(struct work_struct *work)
...@@ -2288,26 +2267,53 @@ static void gem_reset_task(struct work_struct *work) ...@@ -2288,26 +2267,53 @@ static void gem_reset_task(struct work_struct *work)
static int gem_open(struct net_device *dev) static int gem_open(struct net_device *dev)
{ {
struct gem *gp = netdev_priv(dev);
int rc;
/* We allow open while suspended, we just do nothing, /* We allow open while suspended, we just do nothing,
* the chip will be initialized in resume() * the chip will be initialized in resume()
*/ */
if (netif_device_present(dev)) if (netif_device_present(dev)) {
/* Enable the cell */
gem_get_cell(gp);
/* Make sure PCI access and bus master are enabled */
rc = pci_enable_device(gp->pdev);
if (rc) {
netdev_err(dev, "Failed to enable chip on PCI bus !\n");
/* Put cell and forget it for now, it will be considered
*as still asleep, a new sleep cycle may bring it back
*/
gem_put_cell(gp);
return -ENXIO;
}
return gem_do_start(dev); return gem_do_start(dev);
}
return 0; return 0;
} }
static int gem_close(struct net_device *dev) static int gem_close(struct net_device *dev)
{ {
if (netif_device_present(dev)) struct gem *gp = netdev_priv(dev);
if (netif_device_present(dev)) {
gem_do_stop(dev, 0); gem_do_stop(dev, 0);
/* Make sure bus master is disabled */
pci_disable_device(gp->pdev);
/* Cell not needed neither if no WOL */
if (!gp->asleep_wol)
gem_put_cell(gp);
}
return 0; return 0;
} }
#ifdef CONFIG_PM static int __maybe_unused gem_suspend(struct device *dev_d)
static int gem_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 gem *gp = netdev_priv(dev); struct gem *gp = netdev_priv(dev);
/* Lock the network stack first to avoid racing with open/close, /* Lock the network stack first to avoid racing with open/close,
...@@ -2336,15 +2342,19 @@ static int gem_suspend(struct pci_dev *pdev, pm_message_t state) ...@@ -2336,15 +2342,19 @@ static int gem_suspend(struct pci_dev *pdev, pm_message_t state)
gp->asleep_wol = !!gp->wake_on_lan; gp->asleep_wol = !!gp->wake_on_lan;
gem_do_stop(dev, gp->asleep_wol); gem_do_stop(dev, gp->asleep_wol);
/* Cell not needed neither if no WOL */
if (!gp->asleep_wol)
gem_put_cell(gp);
/* Unlock the network stack */ /* Unlock the network stack */
rtnl_unlock(); rtnl_unlock();
return 0; return 0;
} }
static int gem_resume(struct pci_dev *pdev) static int __maybe_unused gem_resume(struct device *dev_d)
{ {
struct net_device *dev = pci_get_drvdata(pdev); struct net_device *dev = dev_get_drvdata(dev_d);
struct gem *gp = netdev_priv(dev); struct gem *gp = netdev_priv(dev);
/* See locking comment in gem_suspend */ /* See locking comment in gem_suspend */
...@@ -2359,6 +2369,9 @@ static int gem_resume(struct pci_dev *pdev) ...@@ -2359,6 +2369,9 @@ static int gem_resume(struct pci_dev *pdev)
return 0; return 0;
} }
/* Enable the cell */
gem_get_cell(gp);
/* Restart chip. If that fails there isn't much we can do, we /* Restart chip. If that fails there isn't much we can do, we
* leave things stopped. * leave things stopped.
*/ */
...@@ -2375,7 +2388,6 @@ static int gem_resume(struct pci_dev *pdev) ...@@ -2375,7 +2388,6 @@ static int gem_resume(struct pci_dev *pdev)
return 0; return 0;
} }
#endif /* CONFIG_PM */
static struct net_device_stats *gem_get_stats(struct net_device *dev) static struct net_device_stats *gem_get_stats(struct net_device *dev)
{ {
...@@ -3019,16 +3031,14 @@ static int gem_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -3019,16 +3031,14 @@ static int gem_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
} }
static SIMPLE_DEV_PM_OPS(gem_pm_ops, gem_suspend, gem_resume);
static struct pci_driver gem_driver = { static struct pci_driver gem_driver = {
.name = GEM_MODULE_NAME, .name = GEM_MODULE_NAME,
.id_table = gem_pci_tbl, .id_table = gem_pci_tbl,
.probe = gem_init_one, .probe = gem_init_one,
.remove = gem_remove_one, .remove = gem_remove_one,
#ifdef CONFIG_PM .driver.pm = &gem_pm_ops,
.suspend = gem_suspend,
.resume = gem_resume,
#endif /* CONFIG_PM */
}; };
module_pci_driver(gem_driver); module_pci_driver(gem_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