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

PCI: PCIe portdrv: Implement pm object

Implement pm object for the PCI Express port driver in order to use
the new power management framework and reduce the code size.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>

authored by

Rafael J. Wysocki and committed by
Jesse Barnes
3a3c244c ae40582e

+26 -35
+2 -2
drivers/pci/hotplug/pciehp_core.c
··· 475 475 } 476 476 477 477 #ifdef CONFIG_PM 478 - static int pciehp_suspend (struct pcie_device *dev, pm_message_t state) 478 + static int pciehp_suspend (struct pcie_device *dev) 479 479 { 480 480 dev_info(&dev->device, "%s ENTRY\n", __func__); 481 481 return 0; ··· 503 503 } 504 504 return 0; 505 505 } 506 - #endif 506 + #endif /* PM */ 507 507 508 508 static struct pcie_port_service_driver hpdriver_portdrv = { 509 509 .name = PCIE_MODULE_NAME,
-6
drivers/pci/pcie/aer/aerdrv.c
··· 40 40 41 41 static int __devinit aer_probe (struct pcie_device *dev); 42 42 static void aer_remove(struct pcie_device *dev); 43 - static int aer_suspend(struct pcie_device *dev, pm_message_t state) 44 - {return 0;} 45 - static int aer_resume(struct pcie_device *dev) {return 0;} 46 43 static pci_ers_result_t aer_error_detected(struct pci_dev *dev, 47 44 enum pci_channel_state error); 48 45 static void aer_error_resume(struct pci_dev *dev); ··· 57 60 58 61 .probe = aer_probe, 59 62 .remove = aer_remove, 60 - 61 - .suspend = aer_suspend, 62 - .resume = aer_resume, 63 63 64 64 .err_handler = &aer_error_handlers, 65 65
+2 -2
drivers/pci/pcie/portdrv.h
··· 38 38 extern int pcie_port_device_probe(struct pci_dev *dev); 39 39 extern int pcie_port_device_register(struct pci_dev *dev); 40 40 #ifdef CONFIG_PM 41 - extern int pcie_port_device_suspend(struct pci_dev *dev, pm_message_t state); 42 - extern int pcie_port_device_resume(struct pci_dev *dev); 41 + extern int pcie_port_device_suspend(struct device *dev); 42 + extern int pcie_port_device_resume(struct device *dev); 43 43 #endif 44 44 extern void pcie_port_device_remove(struct pci_dev *dev); 45 45 extern int __must_check pcie_port_bus_register(void);
+6 -8
drivers/pci/pcie/portdrv_core.c
··· 410 410 static int suspend_iter(struct device *dev, void *data) 411 411 { 412 412 struct pcie_port_service_driver *service_driver; 413 - pm_message_t state = * (pm_message_t *) data; 414 413 415 414 if ((dev->bus == &pcie_port_bus_type) && 416 415 (dev->driver)) { 417 416 service_driver = to_service_driver(dev->driver); 418 417 if (service_driver->suspend) 419 - service_driver->suspend(to_pcie_device(dev), state); 418 + service_driver->suspend(to_pcie_device(dev)); 420 419 } 421 420 return 0; 422 421 } ··· 423 424 /** 424 425 * pcie_port_device_suspend - suspend port services associated with a PCIe port 425 426 * @dev: PCI Express port to handle 426 - * @state: Representation of system power management transition in progress 427 427 */ 428 - int pcie_port_device_suspend(struct pci_dev *dev, pm_message_t state) 428 + int pcie_port_device_suspend(struct device *dev) 429 429 { 430 - return device_for_each_child(&dev->dev, &state, suspend_iter); 430 + return device_for_each_child(dev, NULL, suspend_iter); 431 431 } 432 432 433 433 static int resume_iter(struct device *dev, void *data) ··· 446 448 * pcie_port_device_suspend - resume port services associated with a PCIe port 447 449 * @dev: PCI Express port to handle 448 450 */ 449 - int pcie_port_device_resume(struct pci_dev *dev) 451 + int pcie_port_device_resume(struct device *dev) 450 452 { 451 - return device_for_each_child(&dev->dev, NULL, resume_iter); 453 + return device_for_each_child(dev, NULL, resume_iter); 452 454 } 453 - #endif 455 + #endif /* PM */ 454 456 455 457 static int remove_iter(struct device *dev, void *data) 456 458 {
+15 -16
drivers/pci/pcie/portdrv_pci.c
··· 44 44 } 45 45 46 46 #ifdef CONFIG_PM 47 - static int pcie_portdrv_suspend(struct pci_dev *dev, pm_message_t state) 48 - { 49 - return pcie_port_device_suspend(dev, state); 47 + static struct dev_pm_ops pcie_portdrv_pm_ops = { 48 + .suspend = pcie_port_device_suspend, 49 + .resume = pcie_port_device_resume, 50 + .freeze = pcie_port_device_suspend, 51 + .thaw = pcie_port_device_resume, 52 + .poweroff = pcie_port_device_suspend, 53 + .restore = pcie_port_device_resume, 54 + }; 50 55 51 - } 56 + #define PCIE_PORTDRV_PM_OPS (&pcie_portdrv_pm_ops) 52 57 53 - static int pcie_portdrv_resume(struct pci_dev *dev) 54 - { 55 - pci_set_master(dev); 56 - return pcie_port_device_resume(dev); 57 - } 58 - #else 59 - #define pcie_portdrv_suspend NULL 60 - #define pcie_portdrv_resume NULL 61 - #endif 58 + #else /* !PM */ 59 + 60 + #define PCIE_PORTDRV_PM_OPS NULL 61 + #endif /* !PM */ 62 62 63 63 /* 64 64 * pcie_portdrv_probe - Probe PCI-Express port devices ··· 268 268 .probe = pcie_portdrv_probe, 269 269 .remove = pcie_portdrv_remove, 270 270 271 - .suspend = pcie_portdrv_suspend, 272 - .resume = pcie_portdrv_resume, 273 - 274 271 .err_handler = &pcie_portdrv_err_handler, 272 + 273 + .driver.pm = PCIE_PORTDRV_PM_OPS, 275 274 }; 276 275 277 276 static int __init pcie_portdrv_init(void)
+1 -1
include/linux/pcieport_if.h
··· 59 59 const char *name; 60 60 int (*probe) (struct pcie_device *dev); 61 61 void (*remove) (struct pcie_device *dev); 62 - int (*suspend) (struct pcie_device *dev, pm_message_t state); 62 + int (*suspend) (struct pcie_device *dev); 63 63 int (*resume) (struct pcie_device *dev); 64 64 65 65 /* Service Error Recovery Handler */