The first two patches had been post long time before, so I did not add 'v2' to them. They includes some comments from Daniel Lezcano. The last two patches are for working items defined for powerdebug.
From: Yong Shen yong.shen@linaro.org
everytime when screen refresh, the clock_info data stucture will be reacclocated, which does not make sence. This patch addresses this issue.
Signed-off-by: Yong Shen yong.shen@linaro.org --- clocks.c | 204 ++++++++++++++++++++++++++++++++++++---------------------- clocks.h | 3 +- powerdebug.c | 2 + powerdebug.h | 3 +- 4 files changed, 133 insertions(+), 79 deletions(-)
diff --git a/clocks.c b/clocks.c index b556644..dc5c03b 100644 --- a/clocks.c +++ b/clocks.c @@ -133,18 +133,18 @@ static void dump_parent(struct clock_info *clk, int line, bool dump) static struct clock_info *find_clock(struct clock_info *clk, char *clkarg) { int i; - struct clock_info *ret = clk; + struct clock_info *ret = clk, *tmp;
if (!strcmp(clk->name, clkarg)) return ret;
if (clk->children) { - for (i = 0; i < clk->num_children; i++) { - if (!strcmp(clk->children[i]->name, clkarg)) - return clk->children[i]; + for (tmp = clk->children, i = 0; i < clk->num_children; i++, tmp = tmp->buddy) { + if (!strcmp(tmp->name, clkarg)) + return tmp; } - for (i = 0; i < clk->num_children; i++) { - ret = find_clock(clk->children[i], clkarg); + for (tmp = clk->children, i = 0; i < clk->num_children; i++, tmp = tmp->buddy) { + ret = find_clock(tmp, clkarg); if (ret) return ret; } @@ -194,51 +194,11 @@ void find_parents_for_clock(char *clkname, int complete) dump_all_parents(clkname, false); }
-static void destroy_clocks_info_recur(struct clock_info *clock) -{ - int i; - - if (clock && clock->num_children) { - for (i = (clock->num_children - 1); i >= 0; i--) { - fflush(stdin); - destroy_clocks_info_recur(clock->children[i]); - if (!i) { - free(clock->children); - clock->children = NULL; - clock->num_children = 0; - } - } - } -} - -static void destroy_clocks_info(void) -{ - int i; - - if (!clocks_info) - return; - - if (clocks_info->num_children) { - for (i = (clocks_info->num_children - 1); i >= 0 ; i--) { - destroy_clocks_info_recur(clocks_info->children[i]); - if (!i) { - free(clocks_info->children); - clocks_info->children = NULL; - } - } - } - clocks_info->num_children = 0; - free(clocks_info); - clocks_info = NULL; -} - - int read_and_print_clock_info(int verbose, int hrow, int selected) { print_one_clock(0, "Reading Clock Tree ...", 1, 1);
if (!old_clock_line_no || selected == REFRESH_WINDOW) { - destroy_clocks_info(); read_clock_info(clk_dir_path); }
@@ -280,11 +240,12 @@ static void prepare_name_str(char *namestr, struct clock_info *clock) static void collapse_all_subclocks(struct clock_info *clock) { int i; + struct clock_info *tmp;
clock->expanded = 0; if (clock->num_children) - for (i = 0; i < clock->num_children; i++) - collapse_all_subclocks(clock->children[i]); + for (tmp = clock->children, i = 0; i < clock->num_children; i++, tmp = tmp->buddy) + collapse_all_subclocks(tmp); }
static void add_clock_details_recur(struct clock_info *clock, @@ -295,6 +256,7 @@ static void add_clock_details_recur(struct clock_info *clock, char rate_str[64]; char name_str[256]; double drate = (double)clock->rate; + struct clock_info *tmp;
if (drate > 1000 && drate < 1000000) { unit = "KHz"; @@ -324,23 +286,23 @@ static void add_clock_details_recur(struct clock_info *clock, }
if (clock->expanded && clock->num_children) - for (i = 0; i < clock->num_children; i++) - add_clock_details_recur(clock->children[i], - hrow, selected); + for (tmp = clock->children, i = 0; i < clock->num_children; i++, tmp = tmp->buddy) + add_clock_details_recur(tmp, hrow, selected); + strcpy(clock_lines[clock_line_no], ""); }
void print_clock_info(int verbose, int hrow, int selected) { int i, count = 0, delta; + struct clock_info *tmp;
(void)verbose;
print_clock_header();
- for (i = 0; i < clocks_info->num_children; i++) - add_clock_details_recur(clocks_info->children[i], - hrow, selected); + for (tmp = clocks_info->children, i = 0; i < clocks_info->num_children; i++, tmp = tmp->buddy) + add_clock_details_recur(tmp, hrow, selected);
delta = calc_delta_screen_size(hrow);
@@ -377,6 +339,99 @@ void read_and_dump_clock_info(int verbose) printf("\n\n"); }
+static struct clock_info *clk_head; +static unsigned int max_node_num, max_clk_num, alloc_index; +static int clk_number_recursive(char *clk_path) +{ + DIR *dir; + struct dirent *item; + char filename[NAME_MAX]; + int ret; + struct stat buf; + + dir = opendir(clk_path); + if (!dir) + return 0; + + while ((item = readdir(dir))) { + /* skip hidden dirs except ".." */ + if (item->d_name[0] == '.') + continue; + + sprintf(filename, "%s/%s", clk_path, item->d_name); + ret = stat(filename, &buf); + + if (ret < 0) { + printf("Error doing a stat on %s\n", filename); + exit(1); + } + + if (!S_ISDIR(buf.st_mode)) + continue; + + max_clk_num++; + clk_number_recursive(filename); + } + closedir(dir); + + return max_clk_num; +} + +static int get_clk_number(char *clk_path) +{ + if ((max_clk_num != 0)) /* no nodes have been added */ + return max_clk_num; + else { + max_clk_num = 0; + /*recaculate the number*/ + return clk_number_recursive(clk_path); + } +} + +int init_clk_info_memory_allocator(char *clk_path) +{ + int clk_number = get_clk_number(clk_path); + + if (max_node_num < clk_number) { + int alloc_number = clk_number * 2; + /* we need more nodes than actual clock number + to host the extra info due to original design scheme */ + if (max_node_num == 0) + clk_head = (struct clock_info *)malloc( + sizeof(struct clock_info) * alloc_number); + else + clk_head = (struct clock_info *)realloc( + clk_head, + sizeof(struct clock_info *) * alloc_number); + + max_node_num = alloc_number; + } + alloc_index = 0; +} + +inline struct clock_info *alloc_clk_info() +{ + alloc_index++; + /* we are pretty sure we have enough nodes, + since we checked every refresh */ + if (alloc_index < max_node_num) + return &clk_head[alloc_index - 1]; + else + return NULL; +} + +static void release_all_clk_info_mem(void) +{ + if (clk_head) + free(clk_head); +} + +void clock_finalize(void) +{ + release_all_clk_info_mem(); +} + + void read_clock_info(char *clkpath) { DIR *dir; @@ -389,7 +444,8 @@ void read_clock_info(char *clkpath) if (!dir) return;
- clocks_info = (struct clock_info *)malloc(sizeof(struct clock_info)); + init_clk_info_memory_allocator(clkpath); + clocks_info = alloc_clk_info(); memset(clocks_info, 0, sizeof(clocks_info)); strcpy(clocks_info->name, "/"); clocks_info->level = 0; @@ -401,14 +457,14 @@ void read_clock_info(char *clkpath)
strcpy(clockname, item->d_name); sprintf(filename, "%s/%s", clkpath, item->d_name); - cur = (struct clock_info *)malloc(sizeof(struct clock_info)); + cur = alloc_clk_info(); memset(cur, 0, sizeof(struct clock_info)); strcpy(cur->name, clockname); cur->parent = clocks_info; cur->num_children = 0; cur->expanded = 0; cur->level = 1; - insert_children(&clocks_info, cur); + insert_children(clocks_info, cur); child = read_clock_info_recur(filename, 2, cur); } closedir(dir); @@ -456,7 +512,7 @@ struct clock_info *read_clock_info_recur(char *clkpath, int level, if (!S_ISDIR(buf.st_mode)) continue;
- cur = (struct clock_info *)malloc(sizeof(struct clock_info)); + cur = alloc_clk_info(); memset(cur, 0, sizeof(cur)); strcpy(cur->name, item->d_name); cur->children = NULL; @@ -465,7 +521,7 @@ struct clock_info *read_clock_info_recur(char *clkpath, int level, cur->expanded = 0; cur->level = level; child = read_clock_info_recur(filename, level + 1, cur); - insert_children(&parent, cur); + insert_children(parent, cur); cur->parent = parent; } closedir(dir); @@ -473,29 +529,22 @@ struct clock_info *read_clock_info_recur(char *clkpath, int level, return cur; }
-void insert_children(struct clock_info **parent, struct clock_info *clk) +void insert_children(struct clock_info *parent, struct clock_info *clk) { - if (!(*parent)->num_children || (*parent)->children == NULL) { - (*parent)->children = (struct clock_info **) - malloc(sizeof(struct clock_info *)*2); - (*parent)->num_children = 0; - } else - (*parent)->children = (struct clock_info **) - realloc((*parent)->children, - sizeof(struct clock_info *) * - ((*parent)->num_children + 2)); - if ((*parent)->num_children > 0) - (*parent)->children[(*parent)->num_children - 1]->last_child - = 0; + if (parent->children == NULL) + clk->buddy = clk; + else + clk->buddy = parent->children; + parent->children = clk; + clk->last_child = 1; - (*parent)->children[(*parent)->num_children] = clk; - (*parent)->children[(*parent)->num_children + 1] = NULL; - (*parent)->num_children++; + parent->num_children++; }
void dump_clock_info(struct clock_info *clk, int level, int bmp) { int i, j; + struct clock_info *tmp;
if (!clk) return; @@ -541,9 +590,10 @@ void dump_clock_info(struct clock_info *clk, int level, int bmp) xbmp = tbmp & xbmp; } else xbmp = bmp; - for (i = 0; i < clk->num_children; i++) { + + for (tmp = clk->children, i = 0; i < clk->num_children; i++, tmp = tmp->buddy) { tbmp = xbmp | (1 << level); - dump_clock_info(clk->children[i], level + 1, tbmp); + dump_clock_info(tmp, level + 1, tbmp); } } } diff --git a/clocks.h b/clocks.h index 9ad9804..5f8e195 100644 --- a/clocks.h +++ b/clocks.h @@ -25,7 +25,8 @@ struct clock_info { int expanded; int level; struct clock_info *parent; - struct clock_info **children; + struct clock_info *children; + struct clock_info *buddy; } *clocks_info;
extern int clock_init(void); diff --git a/powerdebug.c b/powerdebug.c index 4d55f17..8afe588 100644 --- a/powerdebug.c +++ b/powerdebug.c @@ -389,5 +389,7 @@ int main(int argc, char **argv) powerdebug_dump(options, regulators_info, numregulators) : powerdebug_display(options, regulators_info, numregulators);
+ clock_finalize(); + return ret < 0; } diff --git a/powerdebug.h b/powerdebug.h index a122b7f..72c2578 100644 --- a/powerdebug.h +++ b/powerdebug.h @@ -34,7 +34,7 @@ extern void read_clock_info(char *clkpath); extern struct clock_info *read_clock_info_recur(char *clkpath, int level, struct clock_info *parent); extern void dump_clock_info(struct clock_info *clk, int level, int bmp); -extern void insert_children(struct clock_info **parent, struct clock_info *clk); +extern inline void insert_children(struct clock_info *parent, struct clock_info *clk); extern void find_parents_for_clock(char *clkname, int complete); extern int read_and_print_clock_info(int verbose, int hrow, int selected); extern void print_clock_info(int verbose, int hrow, int selected); @@ -54,3 +54,4 @@ extern void create_selectedwindow(int selectedwindow); struct regulator_info; extern void show_regulator_info(struct regulator_info *reg_info, int nr_reg, int verbose); +extern void clock_finalize(void);
From: Yong Shen yong.shen@linaro.org
Signed-off-by: Yong Shen yong.shen@linaro.org --- clocks.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 55 insertions(+), 1 deletions(-)
diff --git a/clocks.c b/clocks.c index dc5c03b..25588f7 100644 --- a/clocks.c +++ b/clocks.c @@ -16,12 +16,18 @@ #include <stdio.h> #include <mntent.h> #include <sys/stat.h> +#include <sys/inotify.h> +#include <poll.h>
#include "powerdebug.h" #include "clocks.h"
#define MAX_LINES 120
+static int inotify_fd; +static int inotify_wd; +static struct pollfd fds; + static char clk_dir_path[PATH_MAX]; static int bold[MAX_LINES]; static char clock_lines[MAX_LINES][128]; @@ -58,11 +64,56 @@ int clock_init(void) if (locate_debugfs(clk_dir_path)) return -1;
+ inotify_fd = inotify_init(); + if ( inotify_fd < 0 ) { + fprintf(stderr, "inotify_init error.\n" ); + return -1; + } + + inotify_wd = inotify_add_watch(inotify_fd, clk_dir_path, + IN_ALL_EVENTS ); + + fds.fd = inotify_fd; + fds.events = POLLIN; + sprintf(clk_dir_path, "%s/clock", clk_dir_path);
return access(clk_dir_path, F_OK); }
+#define EVENT_SIZE ( sizeof (struct inotify_event) ) +#define BUF_LEN ( 10 * ( EVENT_SIZE + 16 ) ) + +static int debugfs_changed(void) +{ + int length, i = 0; + char buffer[BUF_LEN]; + + if (inotify_fd <= 0) { + return 1; + } + + poll(&fds, 1, 1); + if (fds.revents != POLLIN) { + return 0; + } + + length = read(inotify_fd, buffer, BUF_LEN); + + if (length < 0) + return 0; + + while (i < length) { + struct inotify_event *event = (struct inotify_event *) &buffer[i]; + if (event->mask & IN_ALL_EVENTS) + return 1; + + i += EVENT_SIZE + event->len; + } + + return 0; +} + static int file_read_from_format(char *file, int *value, const char *format) { FILE *f; @@ -379,7 +430,8 @@ static int clk_number_recursive(char *clk_path)
static int get_clk_number(char *clk_path) { - if ((max_clk_num != 0)) /* no nodes have been added */ + /* no nodes have been added */ + if ((max_clk_num != 0) && (!debugfs_changed())) return max_clk_num; else { max_clk_num = 0; @@ -429,6 +481,8 @@ static void release_all_clk_info_mem(void) void clock_finalize(void) { release_all_clk_info_mem(); + inotify_rm_watch(inotify_fd, inotify_wd); + close(inotify_fd); }
From: Yong Shen yong.shen@linaro.org
push 'S' key to switch to 'sorting' mode, all the clocks will be sorted by their name.
Signed-off-by: Yong Shen yong.shen@linaro.org --- clocks.c | 140 +++++++++++++++++++++++++++++++++++++++++----------------- display.c | 16 ++++--- powerdebug.c | 25 +++++----- powerdebug.h | 17 ++++++- 4 files changed, 136 insertions(+), 62 deletions(-)
diff --git a/clocks.c b/clocks.c index 25588f7..ac8f411 100644 --- a/clocks.c +++ b/clocks.c @@ -31,8 +31,11 @@ static struct pollfd fds; static char clk_dir_path[PATH_MAX]; static int bold[MAX_LINES]; static char clock_lines[MAX_LINES][128]; +static char clock_lines_ordered[MAX_LINES][128]; static int clock_line_no; static int old_clock_line_no; +static struct clock_info *clk_head; +static unsigned int max_node_num, max_clk_num, alloc_index;
static int locate_debugfs(char *clk_path) { @@ -245,30 +248,6 @@ void find_parents_for_clock(char *clkname, int complete) dump_all_parents(clkname, false); }
-int read_and_print_clock_info(int verbose, int hrow, int selected) -{ - print_one_clock(0, "Reading Clock Tree ...", 1, 1); - - if (!old_clock_line_no || selected == REFRESH_WINDOW) { - read_clock_info(clk_dir_path); - } - - if (!clocks_info->num_children) { - fprintf(stderr, "powerdebug: No clocks found. Exiting..\n"); - exit(1); - } - - if (selected == CLOCK_SELECTED) - selected = 1; - else - selected = 0; - - print_clock_info(verbose, hrow, selected); - hrow = (hrow < old_clock_line_no) ? hrow : old_clock_line_no - 1; - - return hrow; -} - static int calc_delta_screen_size(int hrow) { if (hrow >= (maxy - 3)) @@ -277,15 +256,18 @@ static int calc_delta_screen_size(int hrow) return 0; }
-static void prepare_name_str(char *namestr, struct clock_info *clock) +static void prepare_name_str(char *namestr, struct clock_info *clock, struct powerdebug_options *options) { int i;
- strcpy(namestr, ""); - if (clock->level > 1) - for (i = 0; i < (clock->level - 1); i++) - strcat(namestr, " "); - strcat(namestr, clock->name); + if (options->sorting == CLOCK_NO_SORT) { + strcpy(namestr, ""); + if (clock->level > 1) + for (i = 0; i < (clock->level - 1); i++) + strcat(namestr, " "); + strcat(namestr, clock->name); + } else + strcpy(namestr, clock->name); }
static void collapse_all_subclocks(struct clock_info *clock) @@ -300,7 +282,7 @@ static void collapse_all_subclocks(struct clock_info *clock) }
static void add_clock_details_recur(struct clock_info *clock, - int hrow, int selected) + int hrow, int selected, struct powerdebug_options *options) { int i; char *unit = " Hz"; @@ -323,7 +305,8 @@ static void add_clock_details_recur(struct clock_info *clock, bold[clock_line_no] = 0;
sprintf(rate_str, "%.2f %s", drate, unit); - prepare_name_str(name_str, clock); + prepare_name_str(name_str, clock, options); + sprintf(clock_lines[clock_line_no++], "%-55s %-4d %-12s %-12d %-12d", name_str, clock->flags, rate_str, clock->usecount, clock->num_children); @@ -336,24 +319,102 @@ static void add_clock_details_recur(struct clock_info *clock, selected = 0; }
- if (clock->expanded && clock->num_children) + if ((options->sorting == CLOCK_SORT) || (clock->expanded && clock->num_children)) for (tmp = clock->children, i = 0; i < clock->num_children; i++, tmp = tmp->buddy) - add_clock_details_recur(tmp, hrow, selected); + add_clock_details_recur(tmp, hrow, selected, options);
strcpy(clock_lines[clock_line_no], ""); }
-void print_clock_info(int verbose, int hrow, int selected) +static void clock_sort_out(void) +{ + int i, j, tmp; + + for (j = 0; j < max_clk_num; j++) { + for (i = 0; i < max_clk_num; i++) + if (clock_lines[i][0] != '\0') { + tmp = i; + break; + } + + for (i = tmp + 1; i < max_clk_num; i++) { + if (clock_lines[i][0] == '\0') + continue; + if (strcmp(clock_lines[tmp], clock_lines[i]) > 0) + tmp = i; + } + strcpy(clock_lines_ordered[j], clock_lines[tmp]); + clock_lines[tmp][0] = '\0'; + } +} + +static void print_clock_info_sorting(struct powerdebug_options *options, int hrow, int selected) { int i, count = 0, delta; struct clock_info *tmp;
- (void)verbose; + print_clock_header(); + + for (tmp = clocks_info->children, i = 0; i < clocks_info->num_children; i++, tmp = tmp->buddy) + add_clock_details_recur(tmp, hrow, selected, options); + + clock_sort_out(); + + delta = calc_delta_screen_size(hrow); + + while (clock_lines_ordered[count + delta] && + strcmp(clock_lines_ordered[count + delta], "")) { + if (count < delta) { + count++; + continue; + } + print_one_clock(count - delta, clock_lines_ordered[count + delta], + bold[count + delta], (hrow == (count + delta))); + count++; + } + + old_clock_line_no = clock_line_no; + clock_line_no = 0; +} + +int read_and_print_clock_info(struct powerdebug_options *options, int hrow, int selected) +{ + print_one_clock(0, "Reading Clock Tree ...", 1, 1); + + if (!old_clock_line_no || selected == REFRESH_WINDOW) { + read_clock_info(clk_dir_path); + } + + if (!clocks_info->num_children) { + fprintf(stderr, "powerdebug: No clocks found. Exiting..\n"); + exit(1); + } + + if (selected == CLOCK_SELECTED) + selected = 1; + else + selected = 0; + + if (options->sorting == CLOCK_NO_SORT) { + print_clock_info(options, hrow, selected); + } else if (options->sorting == CLOCK_SORT) { + print_clock_info_sorting(options, hrow, selected); + } + + hrow = (hrow < old_clock_line_no) ? hrow : old_clock_line_no - 1; + + return hrow; +} + +void print_clock_info(struct powerdebug_options *options, int hrow, int selected) +{ + int i, count = 0, delta; + struct clock_info *tmp;
print_clock_header();
for (tmp = clocks_info->children, i = 0; i < clocks_info->num_children; i++, tmp = tmp->buddy) - add_clock_details_recur(tmp, hrow, selected); + add_clock_details_recur(tmp, hrow, selected, options);
delta = calc_delta_screen_size(hrow);
@@ -390,8 +451,6 @@ void read_and_dump_clock_info(int verbose) printf("\n\n"); }
-static struct clock_info *clk_head; -static unsigned int max_node_num, max_clk_num, alloc_index; static int clk_number_recursive(char *clk_path) { DIR *dir; @@ -500,9 +559,8 @@ void read_clock_info(char *clkpath)
init_clk_info_memory_allocator(clkpath); clocks_info = alloc_clk_info(); - memset(clocks_info, 0, sizeof(clocks_info)); + memset(clocks_info, 0, sizeof(struct clock_info)); strcpy(clocks_info->name, "/"); - clocks_info->level = 0;
while ((item = readdir(dir))) { /* skip hidden dirs except ".." */ diff --git a/display.c b/display.c index 2d63908..2f7d655 100644 --- a/display.c +++ b/display.c @@ -18,7 +18,7 @@ #include "display.h"
#define print(w, x, y, fmt, args...) do { mvwprintw(w, y, x, fmt, ##args); } while (0) -#define NUM_FOOTER_ITEMS 5 +#define NUM_FOOTER_ITEMS 6
enum { PT_COLOR_DEFAULT = 1, PT_COLOR_HEADER_BAR, @@ -112,16 +112,18 @@ void create_windows(int selectedwindow) header_win = subwin(stdscr, 1, maxx, 0, 0); footer_win = subwin(stdscr, 1, maxx, maxy-1, 0);
- strcpy(footer_items[0], " Q (Quit) "); - strcpy(footer_items[1], " R (Refresh) "); + strcpy(footer_items[0], "Q(Quit)"); + strcpy(footer_items[1], "R(Refresh)"); + strcpy(footer_items[2], "S(Sorting)"); + strcpy(footer_items[3], "T(Tree)");
if (selectedwindow == CLOCK) - strcpy(footer_items[2], " Other Keys: 'Left', 'Right', 'Up', 'Down', 'enter', " - " '/', 'Esc' "); + strcpy(footer_items[4], " Other Keys: 'Left', 'Right', 'Up', 'Down', 'enter', " + " '/', 'Esc', "); else - strcpy(footer_items[2], " Other Keys: 'Left', 'Right' "); + strcpy(footer_items[4], " Other Keys: 'Left', 'Right' ");
- strcpy(footer_items[3], ""); + strcpy(footer_items[5], "");
werase(stdscr); refresh(); diff --git a/powerdebug.c b/powerdebug.c index 8afe588..b01a9d4 100644 --- a/powerdebug.c +++ b/powerdebug.c @@ -74,17 +74,6 @@ static struct option long_options[] = { { 0, 0, 0, 0 } };
-struct powerdebug_options { - bool verbose; - bool regulators; - bool sensors; - bool clocks; - bool dump; - unsigned int ticktime; - int selectedwindow; - char *clkname; -}; - int getoptions(int argc, char *argv[], struct powerdebug_options *options) { int c; @@ -92,6 +81,7 @@ int getoptions(int argc, char *argv[], struct powerdebug_options *options) memset(options, 0, sizeof(*options)); options->ticktime = 10; options->selectedwindow = -1; + options->sorting = CLOCK_NO_SORT;
while (1) { int optindex = 0; @@ -231,6 +221,16 @@ int keystroke_callback(bool *enter_hit, bool *findparent_ncurses, } else *refreshwin = false;
+ if (keychar == 'S') { + *refreshwin = true; + options->sorting = CLOCK_SORT; + } + + if (keychar == 'T') { + *refreshwin = true; + options->sorting = CLOCK_NO_SORT; + } + return 0; }
@@ -272,8 +272,9 @@ int mainloop(struct powerdebug_options *options, command = CLOCK_SELECTED; if (refreshwin) command = REFRESH_WINDOW; + hrow = read_and_print_clock_info( - options->verbose, + options, highlighted_row, command); highlighted_row = hrow; diff --git a/powerdebug.h b/powerdebug.h index 72c2578..a1c90eb 100644 --- a/powerdebug.h +++ b/powerdebug.h @@ -27,6 +27,19 @@ #define TOTAL_FEATURE_WINS 3 /* Regulator, Clock and Sensor (for now) */ enum {CLOCK, REGULATOR, SENSOR}; enum {CLOCK_SELECTED = 1, REFRESH_WINDOW}; +enum {CLOCK_NO_SORT = 1, CLOCK_SORT}; + +struct powerdebug_options { + bool verbose; + bool regulators; + bool sensors; + bool clocks; + bool dump; + unsigned int ticktime; + int selectedwindow; + int sorting; + char *clkname; +};
extern void read_and_dump_clock_info(int verbose); extern void read_and_dump_clock_info_one(char *clk, bool dump); @@ -36,8 +49,8 @@ extern struct clock_info *read_clock_info_recur(char *clkpath, int level, extern void dump_clock_info(struct clock_info *clk, int level, int bmp); extern inline void insert_children(struct clock_info *parent, struct clock_info *clk); extern void find_parents_for_clock(char *clkname, int complete); -extern int read_and_print_clock_info(int verbose, int hrow, int selected); -extern void print_clock_info(int verbose, int hrow, int selected); +extern int read_and_print_clock_info(struct powerdebug_options *options, int hrow, int selected); +extern void print_clock_info(struct powerdebug_options *options, int hrow, int selected); extern void print_string_val(char *name, char *val); extern void print_clock_header(void); extern void print_one_clock(int line, char *str, int bold, int highlight);
From: Yong Shen yong.shen@linaro.org
Add a simple postfix to 'status' and 'state' when displaying regulator information, to emphasis that 'status' is about hardware status while 'state' is a software concept.
Signed-off-by: Yong Shen yong.shen@linaro.org --- display.c | 4 ++-- regulator.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/display.c b/display.c index 2f7d655..5d30765 100644 --- a/display.c +++ b/display.c @@ -201,8 +201,8 @@ void show_regulator_info(struct regulator_info *reg_info, int nr_reg, int verbos werase(regulator_win); wattron(regulator_win, A_BOLD); print(regulator_win, 0, 0, "Name"); - print(regulator_win, 12, 0, "Status"); - print(regulator_win, 24, 0, "State"); + print(regulator_win, 12, 0, "Status(HW)"); + print(regulator_win, 24, 0, "State(SW)"); print(regulator_win, 36, 0, "Type"); print(regulator_win, 48, 0, "Users"); print(regulator_win, 60, 0, "Microvolts"); diff --git a/regulator.c b/regulator.c index 60529ed..8036e32 100644 --- a/regulator.c +++ b/regulator.c @@ -64,9 +64,9 @@ void regulator_print_info(struct regulator_info *reg_info, int nr_reg, int verbo printf("Regulator %d:\n", i + 1); print_string_val("name", reg_info[i].name); if (strcmp(reg_info[i].status, "")) - print_string_val("status", reg_info[i].status); + print_string_val("status(HW)", reg_info[i].status); if (strcmp(reg_info[i].state, "")) - print_string_val("state", reg_info[i].state); + print_string_val("state(SW)", reg_info[i].state);
if (!verbose) continue;