[v4,1/2] PCI: Refactor pci_bridge_d3_possible()
Commit Message
All of the cases handled by pci_bridge_d3_possible() are specific
to these branches:
```
case PCI_EXP_TYPE_ROOT_PORT:
case PCI_EXP_TYPE_UPSTREAM:
case PCI_EXP_TYPE_DOWNSTREAM:
```
Drop a level of indentation by returning false in the default case
instead. No intended functional changes.
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
v3->v4:
* New patch
---
drivers/pci/pci.c | 68 +++++++++++++++++++++++------------------------
1 file changed, 34 insertions(+), 34 deletions(-)
Comments
On Wed, May 24, 2023 at 9:07 PM Mario Limonciello
<mario.limonciello@amd.com> wrote:
>
> All of the cases handled by pci_bridge_d3_possible() are specific
> to these branches:
> ```
> case PCI_EXP_TYPE_ROOT_PORT:
> case PCI_EXP_TYPE_UPSTREAM:
> case PCI_EXP_TYPE_DOWNSTREAM:
> ```
> Drop a level of indentation by returning false in the default case
> instead. No intended functional changes.
>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Acked-by: Rafael J. Wysocki <rafael@kernel.org>
> ---
> v3->v4:
> * New patch
> ---
> drivers/pci/pci.c | 68 +++++++++++++++++++++++------------------------
> 1 file changed, 34 insertions(+), 34 deletions(-)
>
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 5ede93222bc1..d1fa040bcea7 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -2978,48 +2978,48 @@ bool pci_bridge_d3_possible(struct pci_dev *bridge)
> case PCI_EXP_TYPE_ROOT_PORT:
> case PCI_EXP_TYPE_UPSTREAM:
> case PCI_EXP_TYPE_DOWNSTREAM:
> - if (pci_bridge_d3_disable)
> - return false;
> + break;
> + default:
> + return false;
> + }
>
> - /*
> - * Hotplug ports handled by firmware in System Management Mode
> - * may not be put into D3 by the OS (Thunderbolt on non-Macs).
> - */
> - if (bridge->is_hotplug_bridge && !pciehp_is_native(bridge))
> - return false;
> + if (pci_bridge_d3_disable)
> + return false;
>
> - if (pci_bridge_d3_force)
> - return true;
> + /*
> + * Hotplug ports handled by firmware in System Management Mode
> + * may not be put into D3 by the OS (Thunderbolt on non-Macs).
> + */
> + if (bridge->is_hotplug_bridge && !pciehp_is_native(bridge))
> + return false;
>
> - /* Even the oldest 2010 Thunderbolt controller supports D3. */
> - if (bridge->is_thunderbolt)
> - return true;
> + if (pci_bridge_d3_force)
> + return true;
>
> - /* Platform might know better if the bridge supports D3 */
> - if (platform_pci_bridge_d3(bridge))
> - return true;
> + /* Even the oldest 2010 Thunderbolt controller supports D3. */
> + if (bridge->is_thunderbolt)
> + return true;
>
> - /*
> - * Hotplug ports handled natively by the OS were not validated
> - * by vendors for runtime D3 at least until 2018 because there
> - * was no OS support.
> - */
> - if (bridge->is_hotplug_bridge)
> - return false;
> + /* Platform might know better if the bridge supports D3 */
> + if (platform_pci_bridge_d3(bridge))
> + return true;
>
> - if (dmi_check_system(bridge_d3_blacklist))
> - return false;
> + /*
> + * Hotplug ports handled natively by the OS were not validated
> + * by vendors for runtime D3 at least until 2018 because there
> + * was no OS support.
> + */
> + if (bridge->is_hotplug_bridge)
> + return false;
>
> - /*
> - * It should be safe to put PCIe ports from 2015 or newer
> - * to D3.
> - */
> - if (dmi_get_bios_year() >= 2015)
> - return true;
> - break;
> - }
> + if (dmi_check_system(bridge_d3_blacklist))
> + return false;
>
> - return false;
> + /*
> + * It should be safe to put PCIe ports from 2015 or newer
> + * to D3.
> + */
> + return dmi_get_bios_year() >= 2015;
> }
>
> static int pci_dev_check_d3cold(struct pci_dev *dev, void *data)
> --
> 2.34.1
>
On Wed, May 24, 2023 at 02:07:25PM -0500, Mario Limonciello wrote:
> All of the cases handled by pci_bridge_d3_possible() are specific
> to these branches:
> ```
> case PCI_EXP_TYPE_ROOT_PORT:
> case PCI_EXP_TYPE_UPSTREAM:
> case PCI_EXP_TYPE_DOWNSTREAM:
> ```
> Drop a level of indentation by returning false in the default case
> instead. No intended functional changes.
>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
@@ -2978,48 +2978,48 @@ bool pci_bridge_d3_possible(struct pci_dev *bridge)
case PCI_EXP_TYPE_ROOT_PORT:
case PCI_EXP_TYPE_UPSTREAM:
case PCI_EXP_TYPE_DOWNSTREAM:
- if (pci_bridge_d3_disable)
- return false;
+ break;
+ default:
+ return false;
+ }
- /*
- * Hotplug ports handled by firmware in System Management Mode
- * may not be put into D3 by the OS (Thunderbolt on non-Macs).
- */
- if (bridge->is_hotplug_bridge && !pciehp_is_native(bridge))
- return false;
+ if (pci_bridge_d3_disable)
+ return false;
- if (pci_bridge_d3_force)
- return true;
+ /*
+ * Hotplug ports handled by firmware in System Management Mode
+ * may not be put into D3 by the OS (Thunderbolt on non-Macs).
+ */
+ if (bridge->is_hotplug_bridge && !pciehp_is_native(bridge))
+ return false;
- /* Even the oldest 2010 Thunderbolt controller supports D3. */
- if (bridge->is_thunderbolt)
- return true;
+ if (pci_bridge_d3_force)
+ return true;
- /* Platform might know better if the bridge supports D3 */
- if (platform_pci_bridge_d3(bridge))
- return true;
+ /* Even the oldest 2010 Thunderbolt controller supports D3. */
+ if (bridge->is_thunderbolt)
+ return true;
- /*
- * Hotplug ports handled natively by the OS were not validated
- * by vendors for runtime D3 at least until 2018 because there
- * was no OS support.
- */
- if (bridge->is_hotplug_bridge)
- return false;
+ /* Platform might know better if the bridge supports D3 */
+ if (platform_pci_bridge_d3(bridge))
+ return true;
- if (dmi_check_system(bridge_d3_blacklist))
- return false;
+ /*
+ * Hotplug ports handled natively by the OS were not validated
+ * by vendors for runtime D3 at least until 2018 because there
+ * was no OS support.
+ */
+ if (bridge->is_hotplug_bridge)
+ return false;
- /*
- * It should be safe to put PCIe ports from 2015 or newer
- * to D3.
- */
- if (dmi_get_bios_year() >= 2015)
- return true;
- break;
- }
+ if (dmi_check_system(bridge_d3_blacklist))
+ return false;
- return false;
+ /*
+ * It should be safe to put PCIe ports from 2015 or newer
+ * to D3.
+ */
+ return dmi_get_bios_year() >= 2015;
}
static int pci_dev_check_d3cold(struct pci_dev *dev, void *data)