Skip to content

Commit e4c628e

Browse files
committed
ACPI: processor: idle: Eliminate static variable flat_state_cnt
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> Reviewed-by: Sudeep Holla <sudeep.holla@arm.com> Tested-by: Sudeep Holla <sudeep.holla@arm.com> Acked-by: lihuisong@huawei.com Link: https://patch.msgid.link/10715991.nUPlyArG6x@rafael.j.wysocki
1 parent eb58738 commit e4c628e

1 file changed

Lines changed: 11 additions & 14 deletions

File tree

drivers/acpi/processor_idle.c

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -998,11 +998,6 @@ static int acpi_processor_evaluate_lpi(acpi_handle handle,
998998
return ret;
999999
}
10001000

1001-
/*
1002-
* flat_state_cnt - the number of composite LPI states after the process of flattening
1003-
*/
1004-
static int flat_state_cnt;
1005-
10061001
/**
10071002
* combine_lpi_states - combine local and parent LPI states to form a composite LPI state
10081003
*
@@ -1045,9 +1040,10 @@ static void stash_composite_state(struct acpi_lpi_states_array *curr_level,
10451040
curr_level->composite_states[curr_level->composite_states_size++] = t;
10461041
}
10471042

1048-
static int flatten_lpi_states(struct acpi_processor *pr,
1049-
struct acpi_lpi_states_array *curr_level,
1050-
struct acpi_lpi_states_array *prev_level)
1043+
static unsigned int flatten_lpi_states(struct acpi_processor *pr,
1044+
unsigned int flat_state_cnt,
1045+
struct acpi_lpi_states_array *curr_level,
1046+
struct acpi_lpi_states_array *prev_level)
10511047
{
10521048
int i, j, state_count = curr_level->size;
10531049
struct acpi_lpi_state *p, *t = curr_level->entries;
@@ -1087,7 +1083,7 @@ static int flatten_lpi_states(struct acpi_processor *pr,
10871083
}
10881084

10891085
kfree(curr_level->entries);
1090-
return 0;
1086+
return flat_state_cnt;
10911087
}
10921088

10931089
int __weak acpi_processor_ffh_lpi_probe(unsigned int cpu)
@@ -1102,6 +1098,7 @@ static int acpi_processor_get_lpi_info(struct acpi_processor *pr)
11021098
acpi_handle handle = pr->handle, pr_ahandle;
11031099
struct acpi_device *d = NULL;
11041100
struct acpi_lpi_states_array info[2], *tmp, *prev, *curr;
1101+
unsigned int state_count;
11051102

11061103
/* make sure our architecture has support */
11071104
ret = acpi_processor_ffh_lpi_probe(pr->id);
@@ -1114,14 +1111,13 @@ static int acpi_processor_get_lpi_info(struct acpi_processor *pr)
11141111
if (!acpi_has_method(handle, "_LPI"))
11151112
return -EINVAL;
11161113

1117-
flat_state_cnt = 0;
11181114
prev = &info[0];
11191115
curr = &info[1];
11201116
handle = pr->handle;
11211117
ret = acpi_processor_evaluate_lpi(handle, prev);
11221118
if (ret)
11231119
return ret;
1124-
flatten_lpi_states(pr, prev, NULL);
1120+
state_count = flatten_lpi_states(pr, 0, prev, NULL);
11251121

11261122
status = acpi_get_parent(handle, &pr_ahandle);
11271123
while (ACPI_SUCCESS(status)) {
@@ -1143,18 +1139,19 @@ static int acpi_processor_get_lpi_info(struct acpi_processor *pr)
11431139
break;
11441140

11451141
/* flatten all the LPI states in this level of hierarchy */
1146-
flatten_lpi_states(pr, curr, prev);
1142+
state_count = flatten_lpi_states(pr, state_count, curr, prev);
11471143

11481144
tmp = prev, prev = curr, curr = tmp;
11491145

11501146
status = acpi_get_parent(handle, &pr_ahandle);
11511147
}
11521148

1153-
pr->power.count = flat_state_cnt;
11541149
/* reset the index after flattening */
1155-
for (i = 0; i < pr->power.count; i++)
1150+
for (i = 0; i < state_count; i++)
11561151
pr->power.lpi_states[i].index = i;
11571152

1153+
pr->power.count = state_count;
1154+
11581155
/* Tell driver that _LPI is supported. */
11591156
pr->flags.has_lpi = 1;
11601157
pr->flags.power = 1;

0 commit comments

Comments
 (0)