Commit 3a3c244c authored by Rafael J. Wysocki's avatar Rafael J. Wysocki Committed by Jesse Barnes

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: default avatarRafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: default avatarJesse Barnes <jbarnes@virtuousgeek.org>
parent ae40582e
...@@ -475,7 +475,7 @@ static void pciehp_remove (struct pcie_device *dev) ...@@ -475,7 +475,7 @@ static void pciehp_remove (struct pcie_device *dev)
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int pciehp_suspend (struct pcie_device *dev, pm_message_t state) static int pciehp_suspend (struct pcie_device *dev)
{ {
dev_info(&dev->device, "%s ENTRY\n", __func__); dev_info(&dev->device, "%s ENTRY\n", __func__);
return 0; return 0;
...@@ -503,7 +503,7 @@ static int pciehp_resume (struct pcie_device *dev) ...@@ -503,7 +503,7 @@ static int pciehp_resume (struct pcie_device *dev)
} }
return 0; return 0;
} }
#endif #endif /* PM */
static struct pcie_port_service_driver hpdriver_portdrv = { static struct pcie_port_service_driver hpdriver_portdrv = {
.name = PCIE_MODULE_NAME, .name = PCIE_MODULE_NAME,
......
...@@ -40,9 +40,6 @@ MODULE_LICENSE("GPL"); ...@@ -40,9 +40,6 @@ MODULE_LICENSE("GPL");
static int __devinit aer_probe (struct pcie_device *dev); static int __devinit aer_probe (struct pcie_device *dev);
static void aer_remove(struct pcie_device *dev); static void aer_remove(struct pcie_device *dev);
static int aer_suspend(struct pcie_device *dev, pm_message_t state)
{return 0;}
static int aer_resume(struct pcie_device *dev) {return 0;}
static pci_ers_result_t aer_error_detected(struct pci_dev *dev, static pci_ers_result_t aer_error_detected(struct pci_dev *dev,
enum pci_channel_state error); enum pci_channel_state error);
static void aer_error_resume(struct pci_dev *dev); static void aer_error_resume(struct pci_dev *dev);
...@@ -61,9 +58,6 @@ static struct pcie_port_service_driver aerdriver = { ...@@ -61,9 +58,6 @@ static struct pcie_port_service_driver aerdriver = {
.probe = aer_probe, .probe = aer_probe,
.remove = aer_remove, .remove = aer_remove,
.suspend = aer_suspend,
.resume = aer_resume,
.err_handler = &aer_error_handlers, .err_handler = &aer_error_handlers,
.reset_link = aer_root_reset, .reset_link = aer_root_reset,
......
...@@ -38,8 +38,8 @@ extern struct bus_type pcie_port_bus_type; ...@@ -38,8 +38,8 @@ extern struct bus_type pcie_port_bus_type;
extern int pcie_port_device_probe(struct pci_dev *dev); extern int pcie_port_device_probe(struct pci_dev *dev);
extern int pcie_port_device_register(struct pci_dev *dev); extern int pcie_port_device_register(struct pci_dev *dev);
#ifdef CONFIG_PM #ifdef CONFIG_PM
extern int pcie_port_device_suspend(struct pci_dev *dev, pm_message_t state); extern int pcie_port_device_suspend(struct device *dev);
extern int pcie_port_device_resume(struct pci_dev *dev); extern int pcie_port_device_resume(struct device *dev);
#endif #endif
extern void pcie_port_device_remove(struct pci_dev *dev); extern void pcie_port_device_remove(struct pci_dev *dev);
extern int __must_check pcie_port_bus_register(void); extern int __must_check pcie_port_bus_register(void);
......
...@@ -410,13 +410,12 @@ int pcie_port_device_register(struct pci_dev *dev) ...@@ -410,13 +410,12 @@ int pcie_port_device_register(struct pci_dev *dev)
static int suspend_iter(struct device *dev, void *data) static int suspend_iter(struct device *dev, void *data)
{ {
struct pcie_port_service_driver *service_driver; struct pcie_port_service_driver *service_driver;
pm_message_t state = * (pm_message_t *) data;
if ((dev->bus == &pcie_port_bus_type) && if ((dev->bus == &pcie_port_bus_type) &&
(dev->driver)) { (dev->driver)) {
service_driver = to_service_driver(dev->driver); service_driver = to_service_driver(dev->driver);
if (service_driver->suspend) if (service_driver->suspend)
service_driver->suspend(to_pcie_device(dev), state); service_driver->suspend(to_pcie_device(dev));
} }
return 0; return 0;
} }
...@@ -424,11 +423,10 @@ static int suspend_iter(struct device *dev, void *data) ...@@ -424,11 +423,10 @@ static int suspend_iter(struct device *dev, void *data)
/** /**
* pcie_port_device_suspend - suspend port services associated with a PCIe port * pcie_port_device_suspend - suspend port services associated with a PCIe port
* @dev: PCI Express port to handle * @dev: PCI Express port to handle
* @state: Representation of system power management transition in progress
*/ */
int pcie_port_device_suspend(struct pci_dev *dev, pm_message_t state) int pcie_port_device_suspend(struct device *dev)
{ {
return device_for_each_child(&dev->dev, &state, suspend_iter); return device_for_each_child(dev, NULL, suspend_iter);
} }
static int resume_iter(struct device *dev, void *data) static int resume_iter(struct device *dev, void *data)
...@@ -448,11 +446,11 @@ static int resume_iter(struct device *dev, void *data) ...@@ -448,11 +446,11 @@ static int resume_iter(struct device *dev, void *data)
* pcie_port_device_suspend - resume port services associated with a PCIe port * pcie_port_device_suspend - resume port services associated with a PCIe port
* @dev: PCI Express port to handle * @dev: PCI Express port to handle
*/ */
int pcie_port_device_resume(struct pci_dev *dev) int pcie_port_device_resume(struct device *dev)
{ {
return device_for_each_child(&dev->dev, NULL, resume_iter); return device_for_each_child(dev, NULL, resume_iter);
} }
#endif #endif /* PM */
static int remove_iter(struct device *dev, void *data) static int remove_iter(struct device *dev, void *data)
{ {
......
...@@ -44,21 +44,21 @@ static int pcie_portdrv_restore_config(struct pci_dev *dev) ...@@ -44,21 +44,21 @@ static int pcie_portdrv_restore_config(struct pci_dev *dev)
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int pcie_portdrv_suspend(struct pci_dev *dev, pm_message_t state) static struct dev_pm_ops pcie_portdrv_pm_ops = {
{ .suspend = pcie_port_device_suspend,
return pcie_port_device_suspend(dev, state); .resume = pcie_port_device_resume,
.freeze = pcie_port_device_suspend,
.thaw = pcie_port_device_resume,
.poweroff = pcie_port_device_suspend,
.restore = pcie_port_device_resume,
};
} #define PCIE_PORTDRV_PM_OPS (&pcie_portdrv_pm_ops)
static int pcie_portdrv_resume(struct pci_dev *dev) #else /* !PM */
{
pci_set_master(dev); #define PCIE_PORTDRV_PM_OPS NULL
return pcie_port_device_resume(dev); #endif /* !PM */
}
#else
#define pcie_portdrv_suspend NULL
#define pcie_portdrv_resume NULL
#endif
/* /*
* pcie_portdrv_probe - Probe PCI-Express port devices * pcie_portdrv_probe - Probe PCI-Express port devices
...@@ -268,10 +268,9 @@ static struct pci_driver pcie_portdriver = { ...@@ -268,10 +268,9 @@ static struct pci_driver pcie_portdriver = {
.probe = pcie_portdrv_probe, .probe = pcie_portdrv_probe,
.remove = pcie_portdrv_remove, .remove = pcie_portdrv_remove,
.suspend = pcie_portdrv_suspend,
.resume = pcie_portdrv_resume,
.err_handler = &pcie_portdrv_err_handler, .err_handler = &pcie_portdrv_err_handler,
.driver.pm = PCIE_PORTDRV_PM_OPS,
}; };
static int __init pcie_portdrv_init(void) static int __init pcie_portdrv_init(void)
......
...@@ -59,7 +59,7 @@ struct pcie_port_service_driver { ...@@ -59,7 +59,7 @@ struct pcie_port_service_driver {
const char *name; const char *name;
int (*probe) (struct pcie_device *dev); int (*probe) (struct pcie_device *dev);
void (*remove) (struct pcie_device *dev); void (*remove) (struct pcie_device *dev);
int (*suspend) (struct pcie_device *dev, pm_message_t state); int (*suspend) (struct pcie_device *dev);
int (*resume) (struct pcie_device *dev); int (*resume) (struct pcie_device *dev);
/* Service Error Recovery Handler */ /* Service Error Recovery Handler */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment