diff mbox series

[v1,04/11] ena_netdev: use generic power management

Message ID 20200701125938.639447-5-vaibhavgupta40@gmail.com
State Superseded
Delegated to: David Miller
Headers show
Series net: ethernet: use generic power management | expand

Commit Message

Vaibhav Gupta July 1, 2020, 12:59 p.m. UTC
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.

Compile-tested only.

Signed-off-by: Vaibhav Gupta <vaibhavgupta40@gmail.com>
---
 drivers/net/ethernet/amazon/ena/ena_netdev.c | 21 ++++++++------------
 1 file changed, 8 insertions(+), 13 deletions(-)

Comments

Jakub Kicinski July 1, 2020, 3:58 p.m. UTC | #1
On Wed,  1 Jul 2020 18:29:31 +0530 Vaibhav Gupta wrote:
> 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.
> 
> Compile-tested only.
> 
> Signed-off-by: Vaibhav Gupta <vaibhavgupta40@gmail.com>

This one produces a warning on a W=1 build:

drivers/net/ethernet/amazon/ena/ena_netdev.c:4464:26: warning: ‘ena_pm_ops’ defined but not used [-Wunused-const-variable=]
  4464 | static SIMPLE_DEV_PM_OPS(ena_pm_ops, ena_suspend, ena_resume);
Vaibhav Gupta July 1, 2020, 4:45 p.m. UTC | #2
On Wed, 1 Jul 2020 at 21:28, Jakub Kicinski <kuba@kernel.org> wrote:
>
> On Wed,  1 Jul 2020 18:29:31 +0530 Vaibhav Gupta wrote:
> > 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.
> >
> > Compile-tested only.
> >
> > Signed-off-by: Vaibhav Gupta <vaibhavgupta40@gmail.com>
>
> This one produces a warning on a W=1 build:
>
> drivers/net/ethernet/amazon/ena/ena_netdev.c:4464:26: warning: ‘ena_pm_ops’ defined but not used [-Wunused-const-variable=]
>   4464 | static SIMPLE_DEV_PM_OPS(ena_pm_ops, ena_suspend, ena_resume);
I forgot to bind it inside "static struct pci_driver ena_pci_driver" :
      .driver.pm = &ena_pm_ops,

I am sending v2 of this particular patch.

--Vaibhav Gupta
diff mbox series

Patch

diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c
index dda4b8fc9525..92e6d244550c 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.c
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c
@@ -4420,13 +4420,12 @@  static void ena_shutdown(struct pci_dev *pdev)
 	__ena_shutoff(pdev, true);
 }
 
-#ifdef CONFIG_PM
 /* ena_suspend - PM suspend callback
- * @pdev: PCI device information struct
- * @state:power state
+ * @dev_d: Device information struct
  */
-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);
 
 	u64_stats_update_begin(&adapter->syncp);
@@ -4445,12 +4444,11 @@  static int ena_suspend(struct pci_dev *pdev,  pm_message_t state)
 }
 
 /* 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;
 
 	u64_stats_update_begin(&adapter->syncp);
@@ -4462,7 +4460,8 @@  static int ena_resume(struct pci_dev *pdev)
 	rtnl_unlock();
 	return rc;
 }
-#endif
+
+static SIMPLE_DEV_PM_OPS(ena_pm_ops, ena_suspend, ena_resume);
 
 static struct pci_driver ena_pci_driver = {
 	.name		= DRV_MODULE_NAME,
@@ -4470,10 +4469,6 @@  static struct pci_driver ena_pci_driver = {
 	.probe		= ena_probe,
 	.remove		= ena_remove,
 	.shutdown	= ena_shutdown,
-#ifdef CONFIG_PM
-	.suspend    = ena_suspend,
-	.resume     = ena_resume,
-#endif
 	.sriov_configure = pci_sriov_configure_simple,
 };