Re: [PATCH v9 3/3] PCI/ACPI: Use device constraints to decide PCI target state fallback policy

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 8/4/2023 8:17 AM, Mika Westerberg wrote:
On Thu, Aug 03, 2023 at 08:02:29PM -0500, Mario Limonciello wrote:
+/**
+ * acpi_pci_device_constraint - determine if the platform has a contraint for the device
+ * @dev: PCI device to check
+ * @result (out): the constraint specified by the platform
+ *
+ * If the platform has specified a constraint for a device, this function will
+ * return 0 and set @result to the constraint.
+ * Otherwise, it will return an error code.
+ */
+int acpi_pci_device_constraint(struct pci_dev *dev, int *result)
+{
+	int constraint;
+
+	constraint = acpi_get_lps0_constraint(&dev->dev);
+	pci_dbg(dev, "ACPI device constraint: %d\n", constraint);
+	if (constraint < 0)
+		return constraint;
+	*result = constraint;

Is there something preventing to return the constraint directly instead
of storing it into "result"?

My aim was to make the caller use it a pass/fail function.

I'll adjust it so that the caller would look for >= 0 instead.


+
+	return 0;
+}
+
  static void acpi_pci_config_space_access(struct pci_dev *dev, bool enable)
  {
  	int val = enable ? ACPI_REG_CONNECT : ACPI_REG_DISCONNECT;
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 60230da957e0c..6c70f921467c6 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -1082,6 +1082,14 @@ static inline bool platform_pci_bridge_d3(struct pci_dev *dev)
  	return acpi_pci_bridge_d3(dev);
  }
+static inline int platform_get_constraint(struct pci_dev *dev, int *result)

Ditto here.

+{
+	if (pci_use_mid_pm())
+		return -ENODEV;
+
+	return acpi_pci_device_constraint(dev, result);
+}
+



[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux