Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

orinoco: use generic power management

With the support of generic PM callbacks, drivers no longer need to use
legacy .suspend() and .resume() in which they had to maintain PCI states
changes and device's power state themselves. The required operations are
done by PCI core.

PCI drivers are not expected to invoke PCI helper functions like
pci_save/restore_state(), pci_enable/disable_device(),
pci_set_power_state(), etc. Their tasks are completed by PCI core itself.

Compile-tested only.

Signed-off-by: Vaibhav Gupta <vaibhavgupta40@gmail.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20200624174048.64754-1-vaibhavgupta40@gmail.com

authored by

Vaibhav Gupta and committed by
Kalle Valo
c689a62b ef642510

+13 -31
+1 -2
drivers/net/wireless/intersil/orinoco/orinoco_nortel.c
··· 290 290 .id_table = orinoco_nortel_id_table, 291 291 .probe = orinoco_nortel_init_one, 292 292 .remove = orinoco_nortel_remove_one, 293 - .suspend = orinoco_pci_suspend, 294 - .resume = orinoco_pci_resume, 293 + .driver.pm = &orinoco_pci_pm_ops, 295 294 }; 296 295 297 296 static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION
+1 -2
drivers/net/wireless/intersil/orinoco/orinoco_pci.c
··· 230 230 .id_table = orinoco_pci_id_table, 231 231 .probe = orinoco_pci_init_one, 232 232 .remove = orinoco_pci_remove_one, 233 - .suspend = orinoco_pci_suspend, 234 - .resume = orinoco_pci_resume, 233 + .driver.pm = &orinoco_pci_pm_ops, 235 234 }; 236 235 237 236 static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION
+9 -23
drivers/net/wireless/intersil/orinoco/orinoco_pci.h
··· 18 18 void __iomem *attr_io; 19 19 }; 20 20 21 - #ifdef CONFIG_PM 22 - static int orinoco_pci_suspend(struct pci_dev *pdev, pm_message_t state) 21 + static int __maybe_unused orinoco_pci_suspend(struct device *dev_d) 23 22 { 23 + struct pci_dev *pdev = to_pci_dev(dev_d); 24 24 struct orinoco_private *priv = pci_get_drvdata(pdev); 25 25 26 26 orinoco_down(priv); 27 27 free_irq(pdev->irq, priv); 28 - pci_save_state(pdev); 29 - pci_disable_device(pdev); 30 - pci_set_power_state(pdev, PCI_D3hot); 31 28 32 29 return 0; 33 30 } 34 31 35 - static int orinoco_pci_resume(struct pci_dev *pdev) 32 + static int __maybe_unused orinoco_pci_resume(struct device *dev_d) 36 33 { 34 + struct pci_dev *pdev = to_pci_dev(dev_d); 37 35 struct orinoco_private *priv = pci_get_drvdata(pdev); 38 36 struct net_device *dev = priv->ndev; 39 37 int err; 40 - 41 - pci_set_power_state(pdev, PCI_D0); 42 - err = pci_enable_device(pdev); 43 - if (err) { 44 - printk(KERN_ERR "%s: pci_enable_device failed on resume\n", 45 - dev->name); 46 - return err; 47 - } 48 - pci_restore_state(pdev); 49 38 50 39 err = request_irq(pdev->irq, orinoco_interrupt, IRQF_SHARED, 51 40 dev->name, priv); 52 41 if (err) { 53 42 printk(KERN_ERR "%s: cannot re-allocate IRQ on resume\n", 54 43 dev->name); 55 - pci_disable_device(pdev); 56 44 return -EBUSY; 57 45 } 58 46 59 - err = orinoco_up(priv); 60 - 61 - return err; 47 + return orinoco_up(priv); 62 48 } 63 - #else 64 - #define orinoco_pci_suspend NULL 65 - #define orinoco_pci_resume NULL 66 - #endif 49 + 50 + static SIMPLE_DEV_PM_OPS(orinoco_pci_pm_ops, 51 + orinoco_pci_suspend, 52 + orinoco_pci_resume); 67 53 68 54 #endif /* _ORINOCO_PCI_H */
+1 -2
drivers/net/wireless/intersil/orinoco/orinoco_plx.c
··· 336 336 .id_table = orinoco_plx_id_table, 337 337 .probe = orinoco_plx_init_one, 338 338 .remove = orinoco_plx_remove_one, 339 - .suspend = orinoco_pci_suspend, 340 - .resume = orinoco_pci_resume, 339 + .driver.pm = &orinoco_pci_pm_ops, 341 340 }; 342 341 343 342 static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION
+1 -2
drivers/net/wireless/intersil/orinoco/orinoco_tmd.c
··· 213 213 .id_table = orinoco_tmd_id_table, 214 214 .probe = orinoco_tmd_init_one, 215 215 .remove = orinoco_tmd_remove_one, 216 - .suspend = orinoco_pci_suspend, 217 - .resume = orinoco_pci_resume, 216 + .driver.pm = &orinoco_pci_pm_ops, 218 217 }; 219 218 220 219 static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION