diff mbox series

[v3,3/4] PCI/ACPI: Move _OSC query checks to separate function

Message ID 20210824122054.29481-4-joro@8bytes.org (mailing list archive)
State Accepted
Delegated to: Bjorn Helgaas
Headers show
Series PCI/ACPI: Simplify PCIe _OSC feature negotiation | expand

Commit Message

Joerg Roedel Aug. 24, 2021, 12:20 p.m. UTC
From: Joerg Roedel <jroedel@suse.de>

Move the checks about whether the _OSC controls are requested from the
firmware to a separate function.

Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
 drivers/acpi/pci_root.c | 28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)

Comments

Rafael J. Wysocki Sept. 1, 2021, 6:57 p.m. UTC | #1
On Tue, Aug 24, 2021 at 2:21 PM Joerg Roedel <joro@8bytes.org> wrote:
>
> From: Joerg Roedel <jroedel@suse.de>
>
> Move the checks about whether the _OSC controls are requested from the
> firmware to a separate function.
>
> Signed-off-by: Joerg Roedel <jroedel@suse.de>

Reviewed-by: Rafael J. Wysocki <rafael@kernel.org>

> ---
>  drivers/acpi/pci_root.c | 28 +++++++++++++++++++---------
>  1 file changed, 19 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
> index ed4e6b55e9bc..f12e512bcddc 100644
> --- a/drivers/acpi/pci_root.c
> +++ b/drivers/acpi/pci_root.c
> @@ -449,6 +449,24 @@ static u32 calculate_control(void)
>         return control;
>  }
>
> +static bool os_control_query_checks(struct acpi_pci_root *root, u32 support)
> +{
> +       struct acpi_device *device = root->device;
> +
> +       if (pcie_ports_disabled) {
> +               dev_info(&device->dev, "PCIe port services disabled; not requesting _OSC control\n");
> +               return false;
> +       }
> +
> +       if ((support & ACPI_PCIE_REQ_SUPPORT) != ACPI_PCIE_REQ_SUPPORT) {
> +               decode_osc_support(root, "not requesting OS control; OS requires",
> +                                  ACPI_PCIE_REQ_SUPPORT);
> +               return false;
> +       }
> +
> +       return true;
> +}
> +
>  static void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm,
>                                  bool is_pcie)
>  {
> @@ -485,16 +503,8 @@ static void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm,
>                 return;
>         }
>
> -       if (pcie_ports_disabled) {
> -               dev_info(&device->dev, "PCIe port services disabled; not requesting _OSC control\n");
> +       if (!os_control_query_checks(root, support))
>                 return;
> -       }
> -
> -       if ((support & ACPI_PCIE_REQ_SUPPORT) != ACPI_PCIE_REQ_SUPPORT) {
> -               decode_osc_support(root, "not requesting OS control; OS requires",
> -                                  ACPI_PCIE_REQ_SUPPORT);
> -               return;
> -       }
>
>         requested = control = calculate_control();
>
> --
> 2.32.0
>
diff mbox series

Patch

diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index ed4e6b55e9bc..f12e512bcddc 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -449,6 +449,24 @@  static u32 calculate_control(void)
 	return control;
 }
 
+static bool os_control_query_checks(struct acpi_pci_root *root, u32 support)
+{
+	struct acpi_device *device = root->device;
+
+	if (pcie_ports_disabled) {
+		dev_info(&device->dev, "PCIe port services disabled; not requesting _OSC control\n");
+		return false;
+	}
+
+	if ((support & ACPI_PCIE_REQ_SUPPORT) != ACPI_PCIE_REQ_SUPPORT) {
+		decode_osc_support(root, "not requesting OS control; OS requires",
+				   ACPI_PCIE_REQ_SUPPORT);
+		return false;
+	}
+
+	return true;
+}
+
 static void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm,
 				 bool is_pcie)
 {
@@ -485,16 +503,8 @@  static void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm,
 		return;
 	}
 
-	if (pcie_ports_disabled) {
-		dev_info(&device->dev, "PCIe port services disabled; not requesting _OSC control\n");
+	if (!os_control_query_checks(root, support))
 		return;
-	}
-
-	if ((support & ACPI_PCIE_REQ_SUPPORT) != ACPI_PCIE_REQ_SUPPORT) {
-		decode_osc_support(root, "not requesting OS control; OS requires",
-				   ACPI_PCIE_REQ_SUPPORT);
-		return;
-	}
 
 	requested = control = calculate_control();