From: Amit Arora <[email protected]> Tell the user if for some reason the C and/or P states are not available.
Output on a system without cpuidle and cpufreq currently looks like this: http://paste.ubuntu.com/501957/ With this patch applied, the output looks like: http://paste.ubuntu.com/501974/ Signed-off-by: Amit Arora <[email protected]> --- display.c | 25 +++++++++++++++++++++++-- powertop.c | 4 +++- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/display.c b/display.c index f9b6e56..7b5f8db 100644 --- a/display.c +++ b/display.c @@ -100,7 +100,10 @@ void setup_windows(void) int yline = (maxcstate >= maxpstate) ? maxcstate+1 : maxpstate; /* number of states is one more than the MAX state! */ - yline++; + if (!maxcstate && !maxpstate) + yline = 0; + else + yline++; getmaxyx(stdscr, maxy, maxx); @@ -172,7 +175,7 @@ void show_title_bar(void) p_wrefresh(status_bar_window); } -void show_cstates(void) +void show_c_and_p_states(void) { int i, count = 0; int maxcstatelines = (maxcstate >= maxpstate) ? maxcstate+1 : maxpstate; @@ -204,6 +207,24 @@ void show_cstates(void) p_wrefresh(cstate_window); } +void show_cstates(void) +{ + + if (!maxcstate) { + strcpy(cstate_lines[0], "<C-state information is unavailable>"); + strcpy(cstate_lines[1], ""); + topcstate = 99; /* Dummy value, to avoid "bold" text */ + } + + if (!maxpstate) { + strcpy(cpufreqstrings[0], + "<P-state information is unavailable>"); + strcpy(cpufreqstrings[1], ""); + topfreq = 99; /* Dummy value, to avoid "bold" text */ + } + + show_c_and_p_states(); +} void show_acpi_power_line(double rate, double cap, double capdelta, time_t ti) { diff --git a/powertop.c b/powertop.c index 42ef69c..03015de 100644 --- a/powertop.c +++ b/powertop.c @@ -411,7 +411,9 @@ static void read_data_acpi(uint64_t * usage, uint64_t * duration) duration[clevel] += strtoull(c, NULL, 10); clevel++; - if (clevel > maxcstate) + /* set maxcstate only if clevel is a valid state */ + if (clevel > maxcstate && + (usage[clevel] || duration[clevel])) maxcstate = clevel; } -- Thanks! Regards, Amit Arora _______________________________________________ Power mailing list [email protected] http://www.bughost.org/mailman/listinfo/power
