Skip to content

Commit bf39c92

Browse files
committed
PCI: PM: Rearrange pci_target_state()
Make pci_target_state() return D3cold or D0 without checking PME support if the current power state of the device is D3cold or if it does not support the standard PCI PM, respectively. Next, drop the tergat_state local variable that has become redundant from it. Signed-off-by: Rafael J. Wysocki <[email protected]> Tested-by: Ferry Toth <[email protected]>
1 parent f091837 commit bf39c92

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

drivers/pci/pci.c

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2583,8 +2583,6 @@ EXPORT_SYMBOL(pci_wake_from_d3);
25832583
*/
25842584
static pci_power_t pci_target_state(struct pci_dev *dev, bool wakeup)
25852585
{
2586-
pci_power_t target_state = PCI_D3hot;
2587-
25882586
if (platform_pci_power_manageable(dev)) {
25892587
/*
25902588
* Call the platform to find the target state for the device.
@@ -2594,32 +2592,29 @@ static pci_power_t pci_target_state(struct pci_dev *dev, bool wakeup)
25942592
switch (state) {
25952593
case PCI_POWER_ERROR:
25962594
case PCI_UNKNOWN:
2597-
break;
2595+
return PCI_D3hot;
2596+
25982597
case PCI_D1:
25992598
case PCI_D2:
26002599
if (pci_no_d1d2(dev))
2601-
break;
2602-
fallthrough;
2603-
default:
2604-
target_state = state;
2600+
return PCI_D3hot;
26052601
}
26062602

2607-
return target_state;
2603+
return state;
26082604
}
26092605

2610-
if (!dev->pm_cap)
2611-
target_state = PCI_D0;
2612-
26132606
/*
26142607
* If the device is in D3cold even though it's not power-manageable by
26152608
* the platform, it may have been powered down by non-standard means.
26162609
* Best to let it slumber.
26172610
*/
26182611
if (dev->current_state == PCI_D3cold)
2619-
target_state = PCI_D3cold;
2612+
return PCI_D3cold;
2613+
else if (!dev->pm_cap)
2614+
return PCI_D0;
26202615

26212616
if (wakeup && dev->pme_support) {
2622-
pci_power_t state = target_state;
2617+
pci_power_t state = PCI_D3hot;
26232618

26242619
/*
26252620
* Find the deepest state from which the device can generate
@@ -2634,7 +2629,7 @@ static pci_power_t pci_target_state(struct pci_dev *dev, bool wakeup)
26342629
return PCI_D0;
26352630
}
26362631

2637-
return target_state;
2632+
return PCI_D3hot;
26382633
}
26392634

26402635
/**

0 commit comments

Comments
 (0)