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 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?!

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;
> +}

-- 
With Best Regards,
Andy Shevchenko





[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