Skip to content

Commit adfac8f

Browse files
rafaeljwbjorn-helgaas
authored andcommitted
PCI/PM: Use pci_power_up() in pci_set_power_state()
Make it explicitly clear that the code to put devices into D0 in pci_set_power_state() and in pci_pm_default_resume_early() is the same by making the latter use pci_power_up() for transitions into D0. Code rearrangement, no intentional functional impact. Link: https://lore.kernel.org/r/2520019.OZ1nXS5aSj@kreacher Signed-off-by: Rafael J. Wysocki <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Reviewed-by: Mika Westerberg <[email protected]>
1 parent 81cfa59 commit adfac8f

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

drivers/pci/pci.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,6 +1032,16 @@ static void __pci_start_power_transition(struct pci_dev *dev, pci_power_t state)
10321032
}
10331033
}
10341034

1035+
/**
1036+
* pci_power_up - Put the given device into D0
1037+
* @dev: PCI device to power up
1038+
*/
1039+
int pci_power_up(struct pci_dev *dev)
1040+
{
1041+
__pci_start_power_transition(dev, PCI_D0);
1042+
return pci_raw_set_power_state(dev, PCI_D0);
1043+
}
1044+
10351045
/**
10361046
* __pci_dev_set_current_state - Set current state of a PCI device
10371047
* @dev: Device to handle
@@ -1117,15 +1127,16 @@ int pci_set_power_state(struct pci_dev *dev, pci_power_t state)
11171127
if (dev->current_state == state)
11181128
return 0;
11191129

1130+
if (state == PCI_D0)
1131+
return pci_power_up(dev);
1132+
11201133
/*
11211134
* This device is quirked not to be put into D3, so don't put it in
11221135
* D3
11231136
*/
11241137
if (state >= PCI_D3hot && (dev->dev_flags & PCI_DEV_FLAGS_NO_D3))
11251138
return 0;
11261139

1127-
__pci_start_power_transition(dev, state);
1128-
11291140
/*
11301141
* To put device in D3cold, we put device into D3hot in native
11311142
* way, then put device into D3cold with platform ops
@@ -1140,16 +1151,6 @@ int pci_set_power_state(struct pci_dev *dev, pci_power_t state)
11401151
}
11411152
EXPORT_SYMBOL(pci_set_power_state);
11421153

1143-
/**
1144-
* pci_power_up - Put the given device into D0 forcibly
1145-
* @dev: PCI device to power up
1146-
*/
1147-
void pci_power_up(struct pci_dev *dev)
1148-
{
1149-
__pci_start_power_transition(dev, PCI_D0);
1150-
pci_raw_set_power_state(dev, PCI_D0);
1151-
}
1152-
11531154
/**
11541155
* pci_choose_state - Choose the power state of a PCI device
11551156
* @dev: PCI device to be suspended

drivers/pci/pci.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ struct pci_platform_pm_ops {
8585
int pci_set_platform_pm(const struct pci_platform_pm_ops *ops);
8686
void pci_update_current_state(struct pci_dev *dev, pci_power_t state);
8787
void pci_refresh_power_state(struct pci_dev *dev);
88-
void pci_power_up(struct pci_dev *dev);
88+
int pci_power_up(struct pci_dev *dev);
8989
void pci_disable_enabled_device(struct pci_dev *dev);
9090
int pci_finish_runtime_suspend(struct pci_dev *dev);
9191
void pcie_clear_root_pme_status(struct pci_dev *dev);

0 commit comments

Comments
 (0)