Re: [PATCH v11 6/9] ACPI: x86: s2idle: Add a function to get constraints for a device

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

 





On 8/10/2023 10:47 AM, Andy Shevchenko wrote:
On Wed, Aug 09, 2023 at 01:54:50PM -0500, Mario Limonciello wrote:
Other parts of the kernel may use constraints information to make
decisions on what power state to put a device into.

...

+int acpi_get_lps0_constraint(struct device *dev)
+{

+	int i;
+
+	for (i = 0; i < lpi_constraints_table_size; ++i) {
+		static struct lpi_constraints *entry;

static?!

Whoops!  Good catch!


Seems to me with the code in lpi_check_constraints() this actually can be first
(separate patch maybe with conversion of the mentioned user) transformed to

#define for_each_lpi_constraint(entry)
	for (int i = 0;
	     entry = &lpi_constraints_table[i], i < lpi_constraints_table_size;
	     i++)

+		int val;
+
+		entry = &lpi_constraints_table[i];
+		if (!device_match_acpi_handle(dev, entry->handle))
+			continue;
+		val = entry->enabled ? entry->min_dstate : 0;
+		acpi_handle_debug(entry->handle,
+				  "ACPI device constraint: %d\n", val);
+		return val;
+	}

So will become

	struct lpi_constraints *entry;
	int val;

	for_each_lpi_constraint(entry) {
		if (!device_match_acpi_handle(dev, entry->handle))
			continue;
		val = entry->enabled ? entry->min_dstate : 0;
		acpi_handle_debug(entry->handle,
				  "ACPI device constraint: %d\n", val);
		return val;
	}

+	return -ENODEV;
+}


Much appreciated suggestion.  I'll incorporate this in the next version.



[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]
  Powered by Linux