1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-01-31 10:10:46 +00:00

cpufreq: Fix list_frequencies when not available

On intel_pstate machines, we can't get a list of available CPU
frequencies. In that case, return empty list as per the docastring.
This commit is contained in:
Brendan Jackman 2017-12-07 13:56:12 +00:00 committed by marcbonnici
parent 0c7d440070
commit dd4c37901b

View File

@ -181,8 +181,15 @@ class CpufreqModule(Module):
# On some devices scaling_frequencies is not generated. # On some devices scaling_frequencies is not generated.
# http://adrynalyne-teachtofish.blogspot.co.uk/2011/11/how-to-enable-scalingavailablefrequenci.html # http://adrynalyne-teachtofish.blogspot.co.uk/2011/11/how-to-enable-scalingavailablefrequenci.html
# Fall back to parsing stats/time_in_state # Fall back to parsing stats/time_in_state
cmd = 'cat /sys/devices/system/cpu/{}/cpufreq/stats/time_in_state'.format(cpu) path = '/sys/devices/system/cpu/{}/cpufreq/stats/time_in_state'.format(cpu)
out_iter = iter(self.target.execute(cmd).strip().split()) try:
out_iter = iter(self.target.read_value(path).split())
except TargetError:
if not self.target.file_exists(path):
# Probably intel_pstate. Can't get available freqs.
return []
raise
available_frequencies = map(int, reversed([f for f, _ in zip(out_iter, out_iter)])) available_frequencies = map(int, reversed([f for f, _ in zip(out_iter, out_iter)]))
return available_frequencies return available_frequencies