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

prism54: islpci_hotplug: 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/20200721125514.145607-1-vaibhavgupta40@gmail.com

authored by

Vaibhav Gupta and committed by
Kalle Valo
81cf72b7 87b589a1

+11 -23
+11 -23
drivers/net/wireless/intersil/prism54/islpci_hotplug.c
··· 63 63 64 64 static int prism54_probe(struct pci_dev *, const struct pci_device_id *); 65 65 static void prism54_remove(struct pci_dev *); 66 - static int prism54_suspend(struct pci_dev *, pm_message_t state); 67 - static int prism54_resume(struct pci_dev *); 66 + static int __maybe_unused prism54_suspend(struct device *); 67 + static int __maybe_unused prism54_resume(struct device *); 68 + 69 + static SIMPLE_DEV_PM_OPS(prism54_pm_ops, prism54_suspend, prism54_resume); 68 70 69 71 static struct pci_driver prism54_driver = { 70 72 .name = DRV_NAME, 71 73 .id_table = prism54_id_tbl, 72 74 .probe = prism54_probe, 73 75 .remove = prism54_remove, 74 - .suspend = prism54_suspend, 75 - .resume = prism54_resume, 76 + .driver.pm = &prism54_pm_ops, 76 77 }; 77 78 78 79 /****************************************************************************** ··· 244 243 pci_disable_device(pdev); 245 244 } 246 245 247 - static int 248 - prism54_suspend(struct pci_dev *pdev, pm_message_t state) 246 + static int __maybe_unused 247 + prism54_suspend(struct device *dev) 249 248 { 250 - struct net_device *ndev = pci_get_drvdata(pdev); 249 + struct net_device *ndev = dev_get_drvdata(dev); 251 250 islpci_private *priv = ndev ? netdev_priv(ndev) : NULL; 252 251 BUG_ON(!priv); 253 - 254 - 255 - pci_save_state(pdev); 256 252 257 253 /* tell the device not to trigger interrupts for now... */ 258 254 isl38xx_disable_interrupts(priv->device_base); ··· 264 266 return 0; 265 267 } 266 268 267 - static int 268 - prism54_resume(struct pci_dev *pdev) 269 + static int __maybe_unused 270 + prism54_resume(struct device *dev) 269 271 { 270 - struct net_device *ndev = pci_get_drvdata(pdev); 272 + struct net_device *ndev = dev_get_drvdata(dev); 271 273 islpci_private *priv = ndev ? netdev_priv(ndev) : NULL; 272 - int err; 273 274 274 275 BUG_ON(!priv); 275 276 276 277 printk(KERN_NOTICE "%s: got resume request\n", ndev->name); 277 - 278 - err = pci_enable_device(pdev); 279 - if (err) { 280 - printk(KERN_ERR "%s: pci_enable_device failed on resume\n", 281 - ndev->name); 282 - return err; 283 - } 284 - 285 - pci_restore_state(pdev); 286 278 287 279 /* alright let's go into the PREBOOT state */ 288 280 islpci_reset(priv, 1);