Skip to content

Commit

Permalink
mlx4: use generic power management
Browse files Browse the repository at this point in the history
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.

Use "struct dev_pm_ops" variable to bind the callbacks.

Compile-tested only.

Signed-off-by: Vaibhav Gupta <vaibhavgupta40@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Vaibhav Gupta authored and David S. Miller committed Jul 1, 2020
1 parent e9a7f8c commit 0e3e206
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions drivers/net/ethernet/mellanox/mlx4/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4370,8 +4370,9 @@ static const struct pci_error_handlers mlx4_err_handler = {
.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 *dev = persist->dev;

Expand All @@ -4384,8 +4385,9 @@ static int mlx4_suspend(struct pci_dev *pdev, pm_message_t state)
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 *dev = persist->dev;
struct mlx4_priv *priv = mlx4_priv(dev);
Expand Down Expand Up @@ -4414,14 +4416,15 @@ static int mlx4_resume(struct pci_dev *pdev)
return ret;
}

static SIMPLE_DEV_PM_OPS(mlx4_pm_ops, mlx4_suspend, mlx4_resume);

static struct pci_driver mlx4_driver = {
.name = DRV_NAME,
.id_table = mlx4_pci_table,
.probe = mlx4_init_one,
.shutdown = mlx4_shutdown,
.remove = mlx4_remove_one,
.suspend = mlx4_suspend,
.resume = mlx4_resume,
.driver.pm = &mlx4_pm_ops,
.err_handler = &mlx4_err_handler,
};

Expand Down

0 comments on commit 0e3e206

Please sign in to comment.