sun/niu: use generic power management
authorVaibhav Gupta <vaibhavgupta40@gmail.com>
Mon, 6 Jul 2020 08:57:45 +0000 (14:27 +0530)
committerDavid S. Miller <davem@davemloft.net>
Mon, 6 Jul 2020 19:24:15 +0000 (12:24 -0700)
With legacy PM, drivers themselves were responsible for managing the
device's power states and takes care of register states.

After upgrading to the generic structure, PCI core will take care of
required tasks and drivers should do only device-specific operations.

The driver was calling pci_save/restore_state() which is no more needed.

Compile-tested only.

Signed-off-by: Vaibhav Gupta <vaibhavgupta40@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/sun/niu.c

index 9a5004f..68541c8 100644 (file)
@@ -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);
        unsigned long flags;
 
@@ -9897,14 +9897,12 @@ static int niu_suspend(struct pci_dev *pdev, pm_message_t state)
        niu_stop_hw(np);
        spin_unlock_irqrestore(&np->lock, flags);
 
-       pci_save_state(pdev);
-
        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);
        unsigned long flags;
        int err;
@@ -9912,8 +9910,6 @@ static int niu_resume(struct pci_dev *pdev)
        if (!netif_running(dev))
                return 0;
 
-       pci_restore_state(pdev);
-
        netif_device_attach(dev);
 
        spin_lock_irqsave(&np->lock, flags);
@@ -9930,13 +9926,14 @@ static int niu_resume(struct pci_dev *pdev)
        return err;
 }
 
+static SIMPLE_DEV_PM_OPS(niu_pm_ops, niu_suspend, niu_resume);
+
 static struct pci_driver niu_pci_driver = {
        .name           = DRV_MODULE_NAME,
        .id_table       = niu_pci_tbl,
        .probe          = niu_pci_init_one,
        .remove         = niu_pci_remove_one,
-       .suspend        = niu_suspend,
-       .resume         = niu_resume,
+       .driver.pm      = &niu_pm_ops,
 };
 
 #ifdef CONFIG_SPARC64