* [PATCH v1] ACPI: processor: idle: Eliminate static variable flat_state_cnt
@ 2025-08-13 10:38 Rafael J. Wysocki
2025-08-13 11:07 ` Sudeep Holla
2025-08-14 13:40 ` lihuisong (C)
0 siblings, 2 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2025-08-13 10:38 UTC (permalink / raw)
To: Linux ACPI; +Cc: LKML, Linux PM, Sudeep Holla, Artem Bityutskiy
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Instead of using static variable flat_state_cnt to pass data between
functions involved in the _LPI information processing, pass the current
number of "flattened" idle states to flatten_lpi_states() and make it
return the updated number of those states. At the same time, use a
local variable called state_count to store the number of "flattened"
idle states found so far in acpi_processor_get_lpi_info().
No intentional functional impact.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/acpi/processor_idle.c | 25 +++++++++++--------------
1 file changed, 11 insertions(+), 14 deletions(-)
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -998,11 +998,6 @@
return ret;
}
-/*
- * flat_state_cnt - the number of composite LPI states after the process of flattening
- */
-static int flat_state_cnt;
-
/**
* combine_lpi_states - combine local and parent LPI states to form a composite LPI state
*
@@ -1045,9 +1040,10 @@
curr_level->composite_states[curr_level->composite_states_size++] = t;
}
-static int flatten_lpi_states(struct acpi_processor *pr,
- struct acpi_lpi_states_array *curr_level,
- struct acpi_lpi_states_array *prev_level)
+static unsigned int flatten_lpi_states(struct acpi_processor *pr,
+ unsigned int flat_state_cnt,
+ struct acpi_lpi_states_array *curr_level,
+ struct acpi_lpi_states_array *prev_level)
{
int i, j, state_count = curr_level->size;
struct acpi_lpi_state *p, *t = curr_level->entries;
@@ -1087,7 +1083,7 @@
}
kfree(curr_level->entries);
- return 0;
+ return flat_state_cnt;
}
int __weak acpi_processor_ffh_lpi_probe(unsigned int cpu)
@@ -1102,6 +1098,7 @@
acpi_handle handle = pr->handle, pr_ahandle;
struct acpi_device *d = NULL;
struct acpi_lpi_states_array info[2], *tmp, *prev, *curr;
+ unsigned int state_count;
/* make sure our architecture has support */
ret = acpi_processor_ffh_lpi_probe(pr->id);
@@ -1114,14 +1111,13 @@
if (!acpi_has_method(handle, "_LPI"))
return -EINVAL;
- flat_state_cnt = 0;
prev = &info[0];
curr = &info[1];
handle = pr->handle;
ret = acpi_processor_evaluate_lpi(handle, prev);
if (ret)
return ret;
- flatten_lpi_states(pr, prev, NULL);
+ state_count = flatten_lpi_states(pr, 0, prev, NULL);
status = acpi_get_parent(handle, &pr_ahandle);
while (ACPI_SUCCESS(status)) {
@@ -1143,18 +1139,19 @@
break;
/* flatten all the LPI states in this level of hierarchy */
- flatten_lpi_states(pr, curr, prev);
+ state_count = flatten_lpi_states(pr, state_count, curr, prev);
tmp = prev, prev = curr, curr = tmp;
status = acpi_get_parent(handle, &pr_ahandle);
}
- pr->power.count = flat_state_cnt;
/* reset the index after flattening */
- for (i = 0; i < pr->power.count; i++)
+ for (i = 0; i < state_count; i++)
pr->power.lpi_states[i].index = i;
+ pr->power.count = state_count;
+
/* Tell driver that _LPI is supported. */
pr->flags.has_lpi = 1;
pr->flags.power = 1;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1] ACPI: processor: idle: Eliminate static variable flat_state_cnt
2025-08-13 10:38 [PATCH v1] ACPI: processor: idle: Eliminate static variable flat_state_cnt Rafael J. Wysocki
@ 2025-08-13 11:07 ` Sudeep Holla
2025-08-14 13:40 ` lihuisong (C)
1 sibling, 0 replies; 3+ messages in thread
From: Sudeep Holla @ 2025-08-13 11:07 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Linux ACPI, LKML, Linux PM, Sudeep Holla, Artem Bityutskiy
On Wed, Aug 13, 2025 at 12:38:58PM +0200, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> Instead of using static variable flat_state_cnt to pass data between
> functions involved in the _LPI information processing, pass the current
> number of "flattened" idle states to flatten_lpi_states() and make it
> return the updated number of those states. At the same time, use a
> local variable called state_count to store the number of "flattened"
> idle states found so far in acpi_processor_get_lpi_info().
>
> No intentional functional impact.
>
Thanks for this cleanup.
Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
Tested-by: Sudeep Holla <sudeep.holla@arm.com>
--
Regards,
Sudeep
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1] ACPI: processor: idle: Eliminate static variable flat_state_cnt
2025-08-13 10:38 [PATCH v1] ACPI: processor: idle: Eliminate static variable flat_state_cnt Rafael J. Wysocki
2025-08-13 11:07 ` Sudeep Holla
@ 2025-08-14 13:40 ` lihuisong (C)
1 sibling, 0 replies; 3+ messages in thread
From: lihuisong (C) @ 2025-08-14 13:40 UTC (permalink / raw)
To: Rafael J. Wysocki, Linux ACPI
Cc: LKML, Linux PM, Sudeep Holla, Artem Bityutskiy, lihuisong
在 2025/8/13 18:38, Rafael J. Wysocki 写道:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> Instead of using static variable flat_state_cnt to pass data between
> functions involved in the _LPI information processing, pass the current
> number of "flattened" idle states to flatten_lpi_states() and make it
> return the updated number of those states. At the same time, use a
> local variable called state_count to store the number of "flattened"
> idle states found so far in acpi_processor_get_lpi_info().
>
> No intentional functional impact.
>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
>
LGTM,
Acked-by: lihuisong@huawei.com
>
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-08-14 13:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-13 10:38 [PATCH v1] ACPI: processor: idle: Eliminate static variable flat_state_cnt Rafael J. Wysocki
2025-08-13 11:07 ` Sudeep Holla
2025-08-14 13:40 ` lihuisong (C)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).