diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2008-07-06 21:32:52 -0400 |
---|---|---|
committer | Jesse Barnes <jbarnes@virtuousgeek.org> | 2008-07-07 19:25:43 -0400 |
commit | 44e4e66eeae5338b3ca0b28f8352e60bf18d5ba8 (patch) | |
tree | 27c32f382f7af839733cbdc5dedf4fc979708a05 /drivers/pci/pci-acpi.c | |
parent | 961d9120fa6f078492a1c762dd91f2c097e56c83 (diff) |
PCI: rework pci_set_power_state function to call platform first
Rework pci_set_power_state() so that the platform callback is
invoked before the native mechanism, if necessary. Also, make
the function check if the device is power manageable by the
platform before invoking the platform callback.
This may matter if the device dependent on additional power
resources controlled by the platform is being put into D0, in which
case those power resources must be turned on before we attempt to
handle the device itself.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Pavel Machek <pavel@suse.cz>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers/pci/pci-acpi.c')
-rw-r--r-- | drivers/pci/pci-acpi.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index e4df71ab79b3..6bc0d8c870af 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c | |||
@@ -277,12 +277,11 @@ static int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state) | |||
277 | [PCI_D3hot] = ACPI_STATE_D3, | 277 | [PCI_D3hot] = ACPI_STATE_D3, |
278 | [PCI_D3cold] = ACPI_STATE_D3 | 278 | [PCI_D3cold] = ACPI_STATE_D3 |
279 | }; | 279 | }; |
280 | int error = -EINVAL; | ||
280 | 281 | ||
281 | if (!handle) | ||
282 | return -ENODEV; | ||
283 | /* If the ACPI device has _EJ0, ignore the device */ | 282 | /* If the ACPI device has _EJ0, ignore the device */ |
284 | if (ACPI_SUCCESS(acpi_get_handle(handle, "_EJ0", &tmp))) | 283 | if (!handle || ACPI_SUCCESS(acpi_get_handle(handle, "_EJ0", &tmp))) |
285 | return 0; | 284 | return -ENODEV; |
286 | 285 | ||
287 | switch (state) { | 286 | switch (state) { |
288 | case PCI_D0: | 287 | case PCI_D0: |
@@ -290,9 +289,14 @@ static int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state) | |||
290 | case PCI_D2: | 289 | case PCI_D2: |
291 | case PCI_D3hot: | 290 | case PCI_D3hot: |
292 | case PCI_D3cold: | 291 | case PCI_D3cold: |
293 | return acpi_bus_set_power(handle, state_conv[state]); | 292 | error = acpi_bus_set_power(handle, state_conv[state]); |
294 | } | 293 | } |
295 | return -EINVAL; | 294 | |
295 | if (!error) | ||
296 | dev_printk(KERN_INFO, &dev->dev, | ||
297 | "power state changed by ACPI to D%d\n", state); | ||
298 | |||
299 | return error; | ||
296 | } | 300 | } |
297 | 301 | ||
298 | static struct pci_platform_pm_ops acpi_pci_platform_pm = { | 302 | static struct pci_platform_pm_ops acpi_pci_platform_pm = { |