From 4382f8773eaa94c43dc6cc0f19591d2607a34f20 Mon Sep 17 00:00:00 2001 From: Amaury Pouly Date: Fri, 6 Oct 2017 18:31:35 +0200 Subject: cleanup linux cpuinfo code sonynwz: quirk for cpufreq broken driver There was some redundancy between frequency_linux(cpu, true) and current_scaling_frequency(), also I see no reason to compile the cpuinfo stuff unconditionally and the scaling info only on DX since it was already printed some partial scaling info anyway. Thus compile all the code unconditionally and simplify the logic in the debug menu. Also avoid putting buffers of size PATH_MAX on stack since it can be quite big and we only requires 64 bytes for those paths. On Sony NWZ, the cpu driver reports frequency in MHz instead of kHz thus we need to make the cpuinfo code aware of that bug. Change-Id: I61af45ab5f179ecc909b4841b9137a915a60193a --- apps/debug_menu.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'apps/debug_menu.c') diff --git a/apps/debug_menu.c b/apps/debug_menu.c index 5224dbe267..4947f30695 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c @@ -240,9 +240,13 @@ static const char* get_cpuinfo(int selected_item, void *data, { int cpu = (selected_item - 5) / (state_count + 1); int cpu_line = (selected_item - 5) % (state_count + 1); -#if defined(DX50) || defined(DX90) + + /* scaling info */ int min_freq = min_scaling_frequency(cpu); int cur_freq = current_scaling_frequency(cpu); + /* fallback if scaling frequency is not available */ + if(cur_freq <= 0) + cur_freq = frequency_linux(cpu); int max_freq = max_scaling_frequency(cpu); char governor[20]; bool have_governor = current_scaling_governor(cpu, governor, sizeof(governor)); @@ -256,16 +260,6 @@ static const char* get_cpuinfo(int selected_item, void *data, cur_freq > 0 ? cur_freq/1000 : -1, max_freq > 0 ? max_freq/1000 : -1); } -#else - int freq1 = frequency_linux(cpu, false); - int freq2 = frequency_linux(cpu, true); - if (cpu_line == 0) - { - sprintf(buffer, " CPU%d: Cur/Scal freq: %d/%d MHz", cpu, - freq1 > 0 ? freq1/1000 : -1, - freq2 > 0 ? freq2/1000 : -1); - } -#endif else { cpustatetimes_linux(cpu, states, ARRAYLEN(states)); -- cgit v1.2.3