Commit e4c628e9 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki
Browse files

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: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: default avatarSudeep Holla <sudeep.holla@arm.com>
Tested-by: default avatarSudeep Holla <sudeep.holla@arm.com>
Acked-by: default avatar <lihuisong@huawei.com>
Link: https://patch.msgid.link/10715991.nUPlyArG6x@rafael.j.wysocki
parent eb58738d
Loading
Loading
Loading
Loading
+11 −14
Original line number Diff line number Diff line
@@ -998,11 +998,6 @@ static int acpi_processor_evaluate_lpi(acpi_handle handle,
	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,7 +1040,8 @@ static void stash_composite_state(struct acpi_lpi_states_array *curr_level,
	curr_level->composite_states[curr_level->composite_states_size++] = t;
}

static int flatten_lpi_states(struct acpi_processor *pr,
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)
{
@@ -1087,7 +1083,7 @@ static int flatten_lpi_states(struct acpi_processor *pr,
	}

	kfree(curr_level->entries);
	return 0;
	return flat_state_cnt;
}

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)
	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 @@ static int acpi_processor_get_lpi_info(struct acpi_processor *pr)
	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 @@ static int acpi_processor_get_lpi_info(struct acpi_processor *pr)
			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;