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

misc/phantom.c: 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. All required operations are
done by PCI core.

Driver needs to do only device-specific operations.

Compile-tested only.

Signed-off-by: Vaibhav Gupta <vaibhavgupta40@gmail.com>
Link: https://lore.kernel.org/r/20200629081531.214734-5-vaibhavgupta40@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Vaibhav Gupta and committed by
Greg Kroah-Hartman
6bbf5256 ff249c1c

+8 -12
+8 -12
drivers/misc/phantom.c
··· 457 457 pci_disable_device(pdev); 458 458 } 459 459 460 - #ifdef CONFIG_PM 461 - static int phantom_suspend(struct pci_dev *pdev, pm_message_t state) 460 + static int __maybe_unused phantom_suspend(struct device *dev_d) 462 461 { 463 - struct phantom_device *dev = pci_get_drvdata(pdev); 462 + struct phantom_device *dev = dev_get_drvdata(dev_d); 464 463 465 464 iowrite32(0, dev->caddr + PHN_IRQCTL); 466 465 ioread32(dev->caddr + PHN_IRQCTL); /* PCI posting */ 467 466 468 - synchronize_irq(pdev->irq); 467 + synchronize_irq(to_pci_dev(dev_d)->irq); 469 468 470 469 return 0; 471 470 } 472 471 473 - static int phantom_resume(struct pci_dev *pdev) 472 + static int __maybe_unused phantom_resume(struct device *dev_d) 474 473 { 475 - struct phantom_device *dev = pci_get_drvdata(pdev); 474 + struct phantom_device *dev = dev_get_drvdata(dev_d); 476 475 477 476 iowrite32(0, dev->caddr + PHN_IRQCTL); 478 477 479 478 return 0; 480 479 } 481 - #else 482 - #define phantom_suspend NULL 483 - #define phantom_resume NULL 484 - #endif 485 480 486 481 static struct pci_device_id phantom_pci_tbl[] = { 487 482 { .vendor = PCI_VENDOR_ID_PLX, .device = PCI_DEVICE_ID_PLX_9050, ··· 486 491 }; 487 492 MODULE_DEVICE_TABLE(pci, phantom_pci_tbl); 488 493 494 + static SIMPLE_DEV_PM_OPS(phantom_pm_ops, phantom_suspend, phantom_resume); 495 + 489 496 static struct pci_driver phantom_pci_driver = { 490 497 .name = "phantom", 491 498 .id_table = phantom_pci_tbl, 492 499 .probe = phantom_probe, 493 500 .remove = phantom_remove, 494 - .suspend = phantom_suspend, 495 - .resume = phantom_resume 501 + .driver.pm = &phantom_pm_ops, 496 502 }; 497 503 498 504 static CLASS_ATTR_STRING(version, 0444, PHANTOM_VERSION);