Skip to content

Commit 6407e5e

Browse files
committed
PCI: PM: Make pci_choose_state() call pci_target_state()
The pci_choose_state() and pci_target_state() implementations are somewhat divergent without a good reason, because they are used for similar purposes. Change the pci_choose_state() implementation to use pci_target_state() internally except for transitions to the working state of the system in which case it is expected to return D0. Signed-off-by: Rafael J. Wysocki <[email protected]> Tested-by: Ferry Toth <[email protected]>
1 parent bf39c92 commit 6407e5e

File tree

2 files changed

+16
-41
lines changed

2 files changed

+16
-41
lines changed

drivers/pci/pci-acpi.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -910,9 +910,6 @@ pci_power_t acpi_pci_choose_state(struct pci_dev *pdev)
910910
{
911911
int acpi_state, d_max;
912912

913-
if (acpi_pci_disabled)
914-
return PCI_POWER_ERROR;
915-
916913
if (pdev->no_d3cold)
917914
d_max = ACPI_STATE_D3_HOT;
918915
else

drivers/pci/pci.c

Lines changed: 16 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,44 +1394,6 @@ int pci_set_power_state(struct pci_dev *dev, pci_power_t state)
13941394
}
13951395
EXPORT_SYMBOL(pci_set_power_state);
13961396

1397-
/**
1398-
* pci_choose_state - Choose the power state of a PCI device
1399-
* @dev: PCI device to be suspended
1400-
* @state: target sleep state for the whole system. This is the value
1401-
* that is passed to suspend() function.
1402-
*
1403-
* Returns PCI power state suitable for given device and given system
1404-
* message.
1405-
*/
1406-
pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state)
1407-
{
1408-
pci_power_t ret;
1409-
1410-
if (!dev->pm_cap)
1411-
return PCI_D0;
1412-
1413-
ret = platform_pci_choose_state(dev);
1414-
if (ret != PCI_POWER_ERROR)
1415-
return ret;
1416-
1417-
switch (state.event) {
1418-
case PM_EVENT_ON:
1419-
return PCI_D0;
1420-
case PM_EVENT_FREEZE:
1421-
case PM_EVENT_PRETHAW:
1422-
/* REVISIT both freeze and pre-thaw "should" use D0 */
1423-
case PM_EVENT_SUSPEND:
1424-
case PM_EVENT_HIBERNATE:
1425-
return PCI_D3hot;
1426-
default:
1427-
pci_info(dev, "unrecognized suspend event %d\n",
1428-
state.event);
1429-
BUG();
1430-
}
1431-
return PCI_D0;
1432-
}
1433-
EXPORT_SYMBOL(pci_choose_state);
1434-
14351397
#define PCI_EXP_SAVE_REGS 7
14361398

14371399
static struct pci_cap_saved_state *_pci_find_saved_cap(struct pci_dev *pci_dev,
@@ -2843,6 +2805,22 @@ void pci_dev_complete_resume(struct pci_dev *pci_dev)
28432805
spin_unlock_irq(&dev->power.lock);
28442806
}
28452807

2808+
/**
2809+
* pci_choose_state - Choose the power state of a PCI device.
2810+
* @dev: Target PCI device.
2811+
* @state: Target state for the whole system.
2812+
*
2813+
* Returns PCI power state suitable for @dev and @state.
2814+
*/
2815+
pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state)
2816+
{
2817+
if (state.event == PM_EVENT_ON)
2818+
return PCI_D0;
2819+
2820+
return pci_target_state(dev, false);
2821+
}
2822+
EXPORT_SYMBOL(pci_choose_state);
2823+
28462824
void pci_config_pm_runtime_get(struct pci_dev *pdev)
28472825
{
28482826
struct device *dev = &pdev->dev;

0 commit comments

Comments
 (0)