mirror of https://gitee.com/openkylin/linux.git
tulip: dmfe: use generic power management
With legacy PM hooks, it was the responsibility of a driver to manage PCI states and also the device's power state. The generic approach is to let the PCI core handle the work. The legacy suspend() and resume() were making use of pci_read/write_config_dword() to enable/disable wol. Driver editing configuration registers of a device is not recommended. Thus replace them all with device_wakeup_enable/disable(). 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:
parent
39ea5d7014
commit
f906d0f9cd
|
@ -2081,14 +2081,11 @@ static const struct pci_device_id dmfe_pci_tbl[] = {
|
|||
};
|
||||
MODULE_DEVICE_TABLE(pci, dmfe_pci_tbl);
|
||||
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static int dmfe_suspend(struct pci_dev *pci_dev, pm_message_t state)
|
||||
static int __maybe_unused dmfe_suspend(struct device *dev_d)
|
||||
{
|
||||
struct net_device *dev = pci_get_drvdata(pci_dev);
|
||||
struct net_device *dev = dev_get_drvdata(dev_d);
|
||||
struct dmfe_board_info *db = netdev_priv(dev);
|
||||
void __iomem *ioaddr = db->ioaddr;
|
||||
u32 tmp;
|
||||
|
||||
/* Disable upper layer interface */
|
||||
netif_device_detach(dev);
|
||||
|
@ -2105,63 +2102,35 @@ static int dmfe_suspend(struct pci_dev *pci_dev, pm_message_t state)
|
|||
dmfe_free_rxbuffer(db);
|
||||
|
||||
/* Enable WOL */
|
||||
pci_read_config_dword(pci_dev, 0x40, &tmp);
|
||||
tmp &= ~(DMFE_WOL_LINKCHANGE|DMFE_WOL_MAGICPACKET);
|
||||
|
||||
if (db->wol_mode & WAKE_PHY)
|
||||
tmp |= DMFE_WOL_LINKCHANGE;
|
||||
if (db->wol_mode & WAKE_MAGIC)
|
||||
tmp |= DMFE_WOL_MAGICPACKET;
|
||||
|
||||
pci_write_config_dword(pci_dev, 0x40, tmp);
|
||||
|
||||
pci_enable_wake(pci_dev, PCI_D3hot, 1);
|
||||
pci_enable_wake(pci_dev, PCI_D3cold, 1);
|
||||
|
||||
/* Power down device*/
|
||||
pci_save_state(pci_dev);
|
||||
pci_set_power_state(pci_dev, pci_choose_state (pci_dev, state));
|
||||
device_wakeup_enable(dev_d);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dmfe_resume(struct pci_dev *pci_dev)
|
||||
static int __maybe_unused dmfe_resume(struct device *dev_d)
|
||||
{
|
||||
struct net_device *dev = pci_get_drvdata(pci_dev);
|
||||
u32 tmp;
|
||||
|
||||
pci_set_power_state(pci_dev, PCI_D0);
|
||||
pci_restore_state(pci_dev);
|
||||
struct net_device *dev = dev_get_drvdata(dev_d);
|
||||
|
||||
/* Re-initialize DM910X board */
|
||||
dmfe_init_dm910x(dev);
|
||||
|
||||
/* Disable WOL */
|
||||
pci_read_config_dword(pci_dev, 0x40, &tmp);
|
||||
|
||||
tmp &= ~(DMFE_WOL_LINKCHANGE | DMFE_WOL_MAGICPACKET);
|
||||
pci_write_config_dword(pci_dev, 0x40, tmp);
|
||||
|
||||
pci_enable_wake(pci_dev, PCI_D3hot, 0);
|
||||
pci_enable_wake(pci_dev, PCI_D3cold, 0);
|
||||
device_wakeup_disable(dev_d);
|
||||
|
||||
/* Restart upper layer interface */
|
||||
netif_device_attach(dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
#define dmfe_suspend NULL
|
||||
#define dmfe_resume NULL
|
||||
#endif
|
||||
|
||||
static SIMPLE_DEV_PM_OPS(dmfe_pm_ops, dmfe_suspend, dmfe_resume);
|
||||
|
||||
static struct pci_driver dmfe_driver = {
|
||||
.name = "dmfe",
|
||||
.id_table = dmfe_pci_tbl,
|
||||
.probe = dmfe_init_one,
|
||||
.remove = dmfe_remove_one,
|
||||
.suspend = dmfe_suspend,
|
||||
.resume = dmfe_resume
|
||||
.driver.pm = &dmfe_pm_ops,
|
||||
};
|
||||
|
||||
MODULE_AUTHOR("Sten Wang, sten_wang@davicom.com.tw");
|
||||
|
|
Loading…
Reference in New Issue