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

hostap: 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 <vaibhavgupta40@gmail.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20200721150547.371763-1-vaibhavgupta40@gmail.com

authored by

Vaibhav Gupta and committed by
Kalle Valo
99aaa1aa 140c6026

+12 -26
+3 -3
drivers/net/wireless/intersil/hostap/hostap_hw.c
··· 3366 3366 } 3367 3367 3368 3368 3369 - #if (defined(PRISM2_PCI) && defined(CONFIG_PM)) || defined(PRISM2_PCCARD) 3370 - static void prism2_suspend(struct net_device *dev) 3369 + #if defined(PRISM2_PCI) || defined(PRISM2_PCCARD) 3370 + static void __maybe_unused prism2_suspend(struct net_device *dev) 3371 3371 { 3372 3372 struct hostap_interface *iface; 3373 3373 struct local_info *local; ··· 3385 3385 /* Disable hardware and firmware */ 3386 3386 prism2_hw_shutdown(dev, 0); 3387 3387 } 3388 - #endif /* (PRISM2_PCI && CONFIG_PM) || PRISM2_PCCARD */ 3388 + #endif /* PRISM2_PCI || PRISM2_PCCARD */ 3389 3389 3390 3390 3391 3391 /* These might at some point be compiled separately and used as separate
+9 -23
drivers/net/wireless/intersil/hostap/hostap_pci.c
··· 403 403 pci_disable_device(pdev); 404 404 } 405 405 406 - 407 - #ifdef CONFIG_PM 408 - static int prism2_pci_suspend(struct pci_dev *pdev, pm_message_t state) 406 + static int __maybe_unused prism2_pci_suspend(struct device *dev_d) 409 407 { 410 - struct net_device *dev = pci_get_drvdata(pdev); 408 + struct net_device *dev = dev_get_drvdata(dev_d); 411 409 412 410 if (netif_running(dev)) { 413 411 netif_stop_queue(dev); 414 412 netif_device_detach(dev); 415 413 } 416 414 prism2_suspend(dev); 417 - pci_save_state(pdev); 418 - pci_disable_device(pdev); 419 - pci_set_power_state(pdev, PCI_D3hot); 420 415 421 416 return 0; 422 417 } 423 418 424 - static int prism2_pci_resume(struct pci_dev *pdev) 419 + static int __maybe_unused prism2_pci_resume(struct device *dev_d) 425 420 { 426 - struct net_device *dev = pci_get_drvdata(pdev); 427 - int err; 421 + struct net_device *dev = dev_get_drvdata(dev_d); 428 422 429 - err = pci_enable_device(pdev); 430 - if (err) { 431 - printk(KERN_ERR "%s: pci_enable_device failed on resume\n", 432 - dev->name); 433 - return err; 434 - } 435 - pci_restore_state(pdev); 436 423 prism2_hw_config(dev, 0); 437 424 if (netif_running(dev)) { 438 425 netif_device_attach(dev); ··· 428 441 429 442 return 0; 430 443 } 431 - #endif /* CONFIG_PM */ 432 - 433 444 434 445 MODULE_DEVICE_TABLE(pci, prism2_pci_id_table); 446 + 447 + static SIMPLE_DEV_PM_OPS(prism2_pci_pm_ops, 448 + prism2_pci_suspend, 449 + prism2_pci_resume); 435 450 436 451 static struct pci_driver prism2_pci_driver = { 437 452 .name = "hostap_pci", 438 453 .id_table = prism2_pci_id_table, 439 454 .probe = prism2_pci_probe, 440 455 .remove = prism2_pci_remove, 441 - #ifdef CONFIG_PM 442 - .suspend = prism2_pci_suspend, 443 - .resume = prism2_pci_resume, 444 - #endif /* CONFIG_PM */ 456 + .driver.pm = &prism2_pci_pm_ops, 445 457 }; 446 458 447 459 module_pci_driver(prism2_pci_driver);