Skip to content

Commit c3ab180

Browse files
VARoDeKKalle Valo
authored andcommitted
airo: use generic power management
Drivers using legacy power management .suspen()/.resume() callbacks have to manage PCI states and device's PM states themselves. They also need to take care of standard configuration registers. Switch to generic power management framework using a single "struct dev_pm_ops" variable to take the unnecessary load from the driver. This also avoids the need for the driver to directly call most of the PCI helper functions and device power state control functions, as through the generic framework PCI Core takes care of the necessary operations, and drivers are required to do only device-specific jobs. Signed-off-by: Vaibhav Gupta <[email protected]> Signed-off-by: Kalle Valo <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 4dd9e7e commit c3ab180

File tree

1 file changed

+19
-20
lines changed
  • drivers/net/wireless/cisco

1 file changed

+19
-20
lines changed

drivers/net/wireless/cisco/airo.c

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,19 @@ MODULE_DEVICE_TABLE(pci, card_ids);
7474

7575
static int airo_pci_probe(struct pci_dev *, const struct pci_device_id *);
7676
static void airo_pci_remove(struct pci_dev *);
77-
static int airo_pci_suspend(struct pci_dev *pdev, pm_message_t state);
78-
static int airo_pci_resume(struct pci_dev *pdev);
77+
static int __maybe_unused airo_pci_suspend(struct device *dev);
78+
static int __maybe_unused airo_pci_resume(struct device *dev);
79+
80+
static SIMPLE_DEV_PM_OPS(airo_pci_pm_ops,
81+
airo_pci_suspend,
82+
airo_pci_resume);
7983

8084
static struct pci_driver airo_driver = {
81-
.name = DRV_NAME,
82-
.id_table = card_ids,
83-
.probe = airo_pci_probe,
84-
.remove = airo_pci_remove,
85-
.suspend = airo_pci_suspend,
86-
.resume = airo_pci_resume,
85+
.name = DRV_NAME,
86+
.id_table = card_ids,
87+
.probe = airo_pci_probe,
88+
.remove = airo_pci_remove,
89+
.driver.pm = &airo_pci_pm_ops,
8790
};
8891
#endif /* CONFIG_PCI */
8992

@@ -5573,9 +5576,9 @@ static void airo_pci_remove(struct pci_dev *pdev)
55735576
pci_disable_device(pdev);
55745577
}
55755578

5576-
static int airo_pci_suspend(struct pci_dev *pdev, pm_message_t state)
5579+
static int __maybe_unused airo_pci_suspend(struct device *dev_d)
55775580
{
5578-
struct net_device *dev = pci_get_drvdata(pdev);
5581+
struct net_device *dev = dev_get_drvdata(dev_d);
55795582
struct airo_info *ai = dev->ml_priv;
55805583
Cmd cmd;
55815584
Resp rsp;
@@ -5591,25 +5594,21 @@ static int airo_pci_suspend(struct pci_dev *pdev, pm_message_t state)
55915594
return -EAGAIN;
55925595
disable_MAC(ai, 0);
55935596
netif_device_detach(dev);
5594-
ai->power = state;
5597+
ai->power = PMSG_SUSPEND;
55955598
cmd.cmd = HOSTSLEEP;
55965599
issuecommand(ai, &cmd, &rsp);
55975600

5598-
pci_enable_wake(pdev, pci_choose_state(pdev, state), 1);
5599-
pci_save_state(pdev);
5600-
pci_set_power_state(pdev, pci_choose_state(pdev, state));
5601+
device_wakeup_enable(dev_d);
56015602
return 0;
56025603
}
56035604

5604-
static int airo_pci_resume(struct pci_dev *pdev)
5605+
static int __maybe_unused airo_pci_resume(struct device *dev_d)
56055606
{
5606-
struct net_device *dev = pci_get_drvdata(pdev);
5607+
struct net_device *dev = dev_get_drvdata(dev_d);
56075608
struct airo_info *ai = dev->ml_priv;
5608-
pci_power_t prev_state = pdev->current_state;
5609+
pci_power_t prev_state = to_pci_dev(dev_d)->current_state;
56095610

5610-
pci_set_power_state(pdev, PCI_D0);
5611-
pci_restore_state(pdev);
5612-
pci_enable_wake(pdev, PCI_D0, 0);
5611+
device_wakeup_disable(dev_d);
56135612

56145613
if (prev_state != PCI_D1) {
56155614
reset_card(dev, 0);

0 commit comments

Comments
 (0)