aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmit Arora <amit.arora@linaro.org>2010-10-28 11:31:24 +0530
committerAmit Arora <amit.arora@linaro.org>2010-10-28 11:31:24 +0530
commit6e774cd4e8eaebb1bd99909937427925dadc38e8 (patch)
treea2feb126ab0630144df266cd7091ac0ad1624f37
parented3e565b961db8dd95b098483d49b624268f3f97 (diff)
Fix coding style
-rw-r--r--clocks.c592
-rw-r--r--clocks.h22
-rw-r--r--display.c220
-rw-r--r--powerdebug.c217
-rw-r--r--powerdebug.h6
5 files changed, 528 insertions, 529 deletions
diff --git a/clocks.c b/clocks.c
index 7bedfa5..815f598 100644
--- a/clocks.c
+++ b/clocks.c
@@ -28,345 +28,345 @@ static int gadder = 0;
void init_clock_details(void)
{
- char *path = debugfs_locate_mpoint();
- struct stat buf;
-
-
- if (path)
- strcpy(clk_dir_path, path);
- else {
- fprintf(stderr, "powerdebug: Unable to locate debugfs mount"
- " point. Mount debugfs and try again..\n");
- exit(1);
- }
- sprintf(clk_dir_path, "%s/clock", clk_dir_path);
- //strcpy(clk_dir_path, "/debug/clock"); // Hardcoded for testing..
- if (stat(clk_dir_path, &buf)) {
- fprintf(stderr, "powerdebug: Unable to find clock tree"
- " information at %s. Exiting..\n", clk_dir_path);
- exit(1);
- }
- strcpy(clk_name, "");
- strcpy(highlighted_path, "");
+ char *path = debugfs_locate_mpoint();
+ struct stat buf;
+
+
+ if (path)
+ strcpy(clk_dir_path, path);
+ else {
+ fprintf(stderr, "powerdebug: Unable to locate debugfs mount"
+ " point. Mount debugfs and try again..\n");
+ exit(1);
+ }
+ sprintf(clk_dir_path, "%s/clock", clk_dir_path);
+ strcpy(clk_dir_path, "/debug/clock"); // Hardcoded for testing..
+ if (stat(clk_dir_path, &buf)) {
+ fprintf(stderr, "powerdebug: Unable to find clock tree"
+ " information at %s. Exiting..\n", clk_dir_path);
+ exit(1);
+ }
+ strcpy(clk_name, "");
+ strcpy(highlighted_path, "");
}
int get_int_from(char *file)
{
- FILE *filep;
- char result[NAME_MAX];
- int ret;
+ FILE *filep;
+ char result[NAME_MAX];
+ int ret;
- filep = fopen(file, "r");
+ filep = fopen(file, "r");
- if (!filep)
- return -1; //TBD : What should we return on failure, here ?
+ if (!filep)
+ return -1; //TBD : What should we return on failure, here ?
- ret = fscanf(filep, "%s", result);
- fclose(filep);
+ ret = fscanf(filep, "%s", result);
+ fclose(filep);
- return atoi(result);
+ return atoi(result);
}
int read_and_print_clock_info(int verbose, int hrow, int selected)
{
- if (selected) {
- // if (!(strcmp(clk_dir_path, "/debug/clock") &&
- // strcmp(highlighted_path, ".."))) {
- strcpy(clk_dir_path, highlighted_path);
- hrow = 0;
- clk_tree_level += gadder;
- if (clk_tree_level <=0)
- clk_tree_level = 1;
- }
-
- hrow = read_and_print_clock_one_level(verbose, hrow, selected);
-
- return hrow;
+ if (selected) {
+ // if (!(strcmp(clk_dir_path, "/debug/clock") &&
+ // strcmp(highlighted_path, ".."))) {
+ strcpy(clk_dir_path, highlighted_path);
+ hrow = 0;
+ clk_tree_level += gadder;
+ if (clk_tree_level <= 0)
+ clk_tree_level = 1;
+ }
+
+ hrow = read_and_print_clock_one_level(verbose, hrow, selected);
+
+ return hrow;
}
void set_hl_dir_path_to_parent(void)
{
- char *ptr;
-
- strcpy(highlighted_path, clk_dir_path);
- if (strcmp(clk_dir_path, "/clock/debug")) {
- ptr = strrchr(highlighted_path, '/');
- if (ptr)
- ptr[0]='\0';
- }
+ char *ptr;
+
+ strcpy(highlighted_path, clk_dir_path);
+ if (strcmp(clk_dir_path, "/clock/debug")) {
+ ptr = strrchr(highlighted_path, '/');
+ if (ptr)
+ ptr[0] = '\0';
+ }
}
int read_and_print_clock_one_level(int verbose, int hrow, int selected)
{
- int line = 0, usecount = 0, flags = 0, rate = 0;
+ int line = 0, usecount = 0, flags = 0, rate = 0;
// int parent_dir_row = 1000;
- DIR *dir, *subdir;
- char filename[PATH_MAX], devpath[PATH_MAX], clockname[NAME_MAX];
- struct dirent *item, *subitem;
-
- (void)verbose;
-
- print_clock_header(clk_tree_level);
-
- sprintf(filename, "%s", clk_dir_path);
-
- dir = opendir(filename);
- if (!dir)
- return 0;
-
- while ((item = readdir(dir))) {
- /* skip hidden dirs except ".." */
- if (item->d_name[0] == '.' && strcmp(item->d_name, ".."))
- continue;
-
- if (selected && hrow == line && !strcmp(item->d_name, "..")) {
- sprintf(devpath, "%s", clk_dir_path);
- strcpy(clockname, "..");
- } else {
- sprintf(devpath, "%s/%s", clk_dir_path, item->d_name);
- strcpy(clockname, item->d_name);
- }
-
- subdir = opendir(devpath);
-
- if (!subdir)
- continue;
-
- while ((subitem = readdir(subdir))) {
- if (subitem->d_name[0] == '.') /* skip hidden files */
- continue;
-
- sprintf(filename, "%s/%s", devpath, subitem->d_name);
-
- if (!strcmp(subitem->d_name, "flags"))
- flags = get_int_from(filename);
-
- if (!strcmp(subitem->d_name, "rate"))
- rate = get_int_from(filename);
-
- if (!strcmp(subitem->d_name, "usecount"))
- usecount = get_int_from(filename);
- }
-
- if (hrow == line) {
- if (!strcmp(clockname, "..")) {
- if (clk_tree_level != 1) {
- set_hl_dir_path_to_parent();
- gadder = -1;
- }
- } else {
- strcpy(highlighted_path, devpath);
- gadder = 1;
- }
- }
-
-// sprintf(clockname, "%s:dp-%s:n-%s:hp-%s",
-// clockname, clk_dir_path, clk_name, highlighted_path);
-
-/* if (strcmp(clockname, "..")) {
- int row = line + 1;
-
- if (line > parent_dir_row)
- row--;
- print_clock_info_line(row, clockname, flags, rate, usecount,
- (hrow == line) ? 1 : 0);
- } else {
- print_clock_info_line(0, clockname, flags, rate, usecount,
- (hrow == line) ? 1 : 0);
- parent_dir_row = line;
- }
+ DIR *dir, *subdir;
+ char filename[PATH_MAX], devpath[PATH_MAX], clockname[NAME_MAX];
+ struct dirent *item, *subitem;
+
+ (void)verbose;
+
+ print_clock_header(clk_tree_level);
+
+ sprintf(filename, "%s", clk_dir_path);
+
+ dir = opendir(filename);
+ if (!dir)
+ return 0;
+
+ while ((item = readdir(dir))) {
+ /* skip hidden dirs except ".." */
+ if (item->d_name[0] == '.' && strcmp(item->d_name, ".."))
+ continue;
+
+ if (selected && hrow == line && !strcmp(item->d_name, "..")) {
+ sprintf(devpath, "%s", clk_dir_path);
+ strcpy(clockname, "..");
+ } else {
+ sprintf(devpath, "%s/%s", clk_dir_path, item->d_name);
+ strcpy(clockname, item->d_name);
+ }
+
+ subdir = opendir(devpath);
+
+ if (!subdir)
+ continue;
+
+ while ((subitem = readdir(subdir))) {
+ if (subitem->d_name[0] == '.') /* skip hidden files */
+ continue;
+
+ sprintf(filename, "%s/%s", devpath, subitem->d_name);
+
+ if (!strcmp(subitem->d_name, "flags"))
+ flags = get_int_from(filename);
+
+ if (!strcmp(subitem->d_name, "rate"))
+ rate = get_int_from(filename);
+
+ if (!strcmp(subitem->d_name, "usecount"))
+ usecount = get_int_from(filename);
+ }
+
+ if (hrow == line) {
+ if (!strcmp(clockname, "..")) {
+ if (clk_tree_level != 1) {
+ set_hl_dir_path_to_parent();
+ gadder = -1;
+ }
+ } else {
+ strcpy(highlighted_path, devpath);
+ gadder = 1;
+ }
+ }
+
+// sprintf(clockname, "%s:dp-%s:n-%s:hp-%s",
+// clockname, clk_dir_path, clk_name, highlighted_path);
+
+/* if (strcmp(clockname, "..")) {
+ int row = line + 1;
+
+ if (line > parent_dir_row)
+ row--;
+ print_clock_info_line(row, clockname, flags, rate, usecount,
+ (hrow == line) ? 1 : 0);
+ } else {
+ print_clock_info_line(0, clockname, flags, rate, usecount,
+ (hrow == line) ? 1 : 0);
+ parent_dir_row = line;
+ }
*/
- print_clock_info_line(line, clockname, flags, rate, usecount,
- (hrow == line) ? 1 : 0);
- line++;
+ print_clock_info_line(line, clockname, flags, rate, usecount,
+ (hrow == line) ? 1 : 0);
+ line++;
- closedir(subdir);
- }
+ closedir(subdir);
+ }
- closedir(dir);
+ closedir(dir);
- if (hrow >= (line - 1))
- hrow = -1;
- return hrow;
+ if (hrow >= (line - 1))
+ hrow = -1;
+ return hrow;
}
void dump_clock_info(int verbose)
{
- (void)verbose;
- printf("Clock Tree :\n");
- printf("**********\n");
- read_clock_info(clk_dir_path);
- print_clock_info(clocks_info, 1, 1);
+ (void)verbose;
+ printf("Clock Tree :\n");
+ printf("**********\n");
+ read_clock_info(clk_dir_path);
+ print_clock_info(clocks_info, 1, 1);
}
void read_clock_info(char *clkpath)
{
- DIR *dir;
- struct dirent *item;
- char filename[NAME_MAX], clockname[NAME_MAX];
- struct clock_info *child;
- struct clock_info *cur;
-
- dir = opendir(clkpath);
- if (!dir)
- return;
-
- clocks_info = (struct clock_info *)malloc(sizeof(struct clock_info));
- memset(clocks_info, 0, sizeof(clocks_info));
- strcpy(clocks_info->name, "/");
-
- while ((item = readdir(dir))) {
- /* skip hidden dirs except ".." */
- if (item->d_name[0] == '.')
- continue;
-
- strcpy(clockname, item->d_name);
- sprintf(filename, "%s/%s", clkpath, item->d_name);
- cur = (struct clock_info *)malloc(sizeof(struct clock_info));
- memset(cur, 0, sizeof(cur));
- strcpy(cur->name, clockname);
- cur->parent = clocks_info;
- insert_children(&clocks_info, cur);
- child = read_clock_info_recur(filename, 2, cur);
- }
- closedir(dir);
+ DIR *dir;
+ struct dirent *item;
+ char filename[NAME_MAX], clockname[NAME_MAX];
+ struct clock_info *child;
+ struct clock_info *cur;
+
+ dir = opendir(clkpath);
+ if (!dir)
+ return;
+
+ clocks_info = (struct clock_info *)malloc(sizeof(struct clock_info));
+ memset(clocks_info, 0, sizeof(clocks_info));
+ strcpy(clocks_info->name, "/");
+
+ while ((item = readdir(dir))) {
+ /* skip hidden dirs except ".." */
+ if (item->d_name[0] == '.')
+ continue;
+
+ strcpy(clockname, item->d_name);
+ sprintf(filename, "%s/%s", clkpath, item->d_name);
+ cur = (struct clock_info *)malloc(sizeof(struct clock_info));
+ memset(cur, 0, sizeof(cur));
+ strcpy(cur->name, clockname);
+ cur->parent = clocks_info;
+ insert_children(&clocks_info, cur);
+ child = read_clock_info_recur(filename, 2, cur);
+ }
+ closedir(dir);
}
struct clock_info *read_clock_info_recur(char *clkpath, int level,
- struct clock_info *parent)
+ struct clock_info *parent)
{
- int ret = 0;
- DIR *dir;
- char filename[PATH_MAX];
- struct dirent *item;
- struct clock_info *cur = NULL;
- struct stat buf;
-
- dir = opendir(clkpath);
- if (!dir)
- return NULL;
-
- while ((item = readdir(dir))) {
- struct clock_info *child;
- /* skip hidden dirs except ".." */
- if (item->d_name[0] == '.' )
- continue;
-
- sprintf(filename, "%s/%s", clkpath, item->d_name);
-
- ret = stat(filename, &buf);
-
- if (ret < 0) {
- printf("Error doing a stat on %s\n", filename);
- exit(1);
- }
-
- if (S_ISREG(buf.st_mode))
- {
- if (!strcmp(item->d_name, "flags"))
- parent->flags = get_int_from(filename);
- if (!strcmp(item->d_name, "rate"))
- parent->rate = get_int_from(filename);
- if (!strcmp(item->d_name, "usecount"))
- parent->usecount = get_int_from(filename);
- continue;
- }
-
- if (!S_ISDIR(buf.st_mode))
- continue;
-
- cur = (struct clock_info *)malloc(sizeof(struct clock_info));
- memset(cur, 0, sizeof(cur));
- strcpy(cur->name, item->d_name);
- cur->children = NULL;
- cur->parent = NULL;
- cur->num_children = 0;
- child = read_clock_info_recur(filename, level + 1, cur);
-
- insert_children(&parent, cur);
- cur->parent = parent;
- }
- closedir(dir);
-
- return cur;
+ int ret = 0;
+ DIR *dir;
+ char filename[PATH_MAX];
+ struct dirent *item;
+ struct clock_info *cur = NULL;
+ struct stat buf;
+
+ dir = opendir(clkpath);
+ if (!dir)
+ return NULL;
+
+ while ((item = readdir(dir))) {
+ struct clock_info *child;
+ /* skip hidden dirs except ".." */
+ if (item->d_name[0] == '.' )
+ continue;
+
+ sprintf(filename, "%s/%s", clkpath, item->d_name);
+
+ ret = stat(filename, &buf);
+
+ if (ret < 0) {
+ printf("Error doing a stat on %s\n", filename);
+ exit(1);
+ }
+
+ if (S_ISREG(buf.st_mode)) {
+ if (!strcmp(item->d_name, "flags"))
+ parent->flags = get_int_from(filename);
+ if (!strcmp(item->d_name, "rate"))
+ parent->rate = get_int_from(filename);
+ if (!strcmp(item->d_name, "usecount"))
+ parent->usecount = get_int_from(filename);
+ continue;
+ }
+
+ if (!S_ISDIR(buf.st_mode))
+ continue;
+
+ cur = (struct clock_info *)malloc(sizeof(struct clock_info));
+ memset(cur, 0, sizeof(cur));
+ strcpy(cur->name, item->d_name);
+ cur->children = NULL;
+ cur->parent = NULL;
+ cur->num_children = 0;
+ child = read_clock_info_recur(filename, level + 1, cur);
+
+ insert_children(&parent, cur);
+ cur->parent = parent;
+ }
+ closedir(dir);
+
+ return cur;
}
void insert_children(struct clock_info **parent, struct clock_info *clk)
{
- if (!(*parent)->children) {
- (*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;
- clk->last_child = 1;
- (*parent)->children[(*parent)->num_children] = clk;
- (*parent)->children[(*parent)->num_children + 1] = NULL;
- (*parent)->num_children++;
+ if (!(*parent)->children) {
+ (*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;
+ clk->last_child = 1;
+ (*parent)->children[(*parent)->num_children] = clk;
+ (*parent)->children[(*parent)->num_children + 1] = NULL;
+ (*parent)->num_children++;
}
void print_clock_info(struct clock_info *clk, int level, int bmp)
{
- int i, j;
-
- if (!clk)
- return;
-
- for (i = 1, j = 0; i < level; i++, j = (i - 1)) {
- if (i == (level - 1)) {
- if (clk->last_child)
- printf("`-- ");
- else
- printf("|-- ");
- } else {
- if ((1<<j) & bmp)
- printf("| ");
- else
- printf(" ");
- }
- }
- if (clk == clocks_info)
- printf("%s\n", clk->name);
- else {
- char *unit = "Hz";
- double drate = (double)clk->rate;
-
- if (drate > 1000 && drate < 1000000) {
- unit = "KHz";
- drate /= 1000;
- }
- if (drate > 1000000) {
- unit = "MHz";
- drate /= 1000000;
- }
- printf("%s (flags:%d,usecount:%d,rate:%5.2f %s)\n",
- clk->name, clk->flags, clk->usecount, drate, unit);
- //printf("%s (flags:%d,usecount:%d,rate:%5.2f %s, bmp=0x%x)\n",
- // clk->name, clk->flags, clk->usecount, drate, unit, bmp);
- }
- if (clk->children) {
- int tbmp = bmp;
- int xbmp = -1;
-
- if (clk->last_child) {
- xbmp ^= 1 << (level - 2 );
-
- xbmp = tbmp & xbmp;
- } else
- xbmp = bmp;
- for (i = 0; i<clk->num_children; i++) {
- //if (clk->children[i]->last_child)
- tbmp = xbmp | (1<<level);
- print_clock_info(clk->children[i], level + 1, tbmp);
- }
- }
+ int i, j;
+
+ if (!clk)
+ return;
+
+ for (i = 1, j = 0; i < level; i++, j = (i - 1)) {
+ if (i == (level - 1)) {
+ if (clk->last_child)
+ printf("`-- ");
+ else
+ printf("|-- ");
+ } else {
+ if ((1<<j) & bmp)
+ printf("| ");
+ else
+ printf(" ");
+ }
+ }
+ if (clk == clocks_info)
+ printf("%s\n", clk->name);
+ else {
+ char *unit = "Hz";
+ double drate = (double)clk->rate;
+
+ if (drate > 1000 && drate < 1000000) {
+ unit = "KHz";
+ drate /= 1000;
+ }
+ if (drate > 1000000) {
+ unit = "MHz";
+ drate /= 1000000;
+ }
+ printf("%s (flags:%d,usecount:%d,rate:%5.2f %s)\n",
+ clk->name, clk->flags, clk->usecount, drate, unit);
+ //printf("%s (flags:%d,usecount:%d,rate:%5.2f %s, bmp=0x%x)\n",
+ // clk->name, clk->flags, clk->usecount, drate, unit, bmp);
+ }
+ if (clk->children) {
+ int tbmp = bmp;
+ int xbmp = -1;
+
+ if (clk->last_child) {
+ xbmp ^= 1 << (level - 2);
+
+ xbmp = tbmp & xbmp;
+ } else
+ xbmp = bmp;
+ for (i = 0; i < clk->num_children; i++) {
+ //if (clk->children[i]->last_child)
+ tbmp = xbmp | (1 << level);
+ print_clock_info(clk->children[i], level + 1, tbmp);
+ }
+ }
}
char *debugfs_locate_mpoint(void)
@@ -379,8 +379,8 @@ char *debugfs_locate_mpoint(void)
path = likely_mpoints;
while (*path) {
- ret = statfs(*path, &sfs);
- if (ret >= 0 && sfs.f_type == (long)DEBUGFS_MAGIC)
+ ret = statfs(*path, &sfs);
+ if (ret >= 0 && sfs.f_type == (long)DEBUGFS_MAGIC)
return *path;
path++;
}
@@ -388,8 +388,8 @@ char *debugfs_locate_mpoint(void)
filep = fopen("/proc/mounts", "r");
if (filep == NULL) {
fprintf(stderr, "powerdebug: Error opening /proc/mounts.");
- exit(1);
- }
+ exit(1);
+ }
while (fscanf(filep, "%*s %s %s %*s %*d %*d\n",
debugfs_mntpoint, fsname) == 2)
diff --git a/clocks.h b/clocks.h
index 91cf434..2157162 100644
--- a/clocks.h
+++ b/clocks.h
@@ -19,20 +19,20 @@
#include <linux/magic.h>
struct clock_info {
- char name[NAME_MAX];
- int flags;
- int rate;
- int usecount;
- int num_children;
- int last_child;
- struct clock_info *parent;
- struct clock_info **children;
+ char name[NAME_MAX];
+ int flags;
+ int rate;
+ int usecount;
+ int num_children;
+ int last_child;
+ struct clock_info *parent;
+ struct clock_info **children;
} *clocks_info;
char debugfs_mntpoint[1024];
char *likely_mpoints[] = {
- "/sys/kernel/debug",
- "/debug",
- NULL
+ "/sys/kernel/debug",
+ "/debug",
+ NULL
};
diff --git a/display.c b/display.c
index b396367..557b6eb 100644
--- a/display.c
+++ b/display.c
@@ -62,26 +62,26 @@ void killall_windows(int all)
void init_curses(void)
{
- initscr();
- start_color();
- keypad(stdscr, TRUE);
- noecho();
- cbreak();
- curs_set(0);
- nonl();
- use_default_colors();
-
- init_pair(PT_COLOR_DEFAULT, COLOR_WHITE, COLOR_BLACK);
- init_pair(PT_COLOR_ERROR, COLOR_BLACK, COLOR_RED);
- //init_pair(PT_COLOR_HEADER_BAR, COLOR_BLACK, COLOR_WHITE);
- init_pair(PT_COLOR_HEADER_BAR, COLOR_BLACK, COLOR_GREEN);
- init_pair(PT_COLOR_YELLOW, COLOR_WHITE, COLOR_YELLOW);
- init_pair(PT_COLOR_GREEN, COLOR_WHITE, COLOR_GREEN);
- init_pair(PT_COLOR_BRIGHT, COLOR_WHITE, COLOR_BLACK);
- init_pair(PT_COLOR_BLUE, COLOR_WHITE, COLOR_BLUE);
- init_pair(PT_COLOR_RED, COLOR_WHITE, COLOR_RED);
-
- atexit(fini_curses);
+ initscr();
+ start_color();
+ keypad(stdscr, TRUE);
+ noecho();
+ cbreak();
+ curs_set(0);
+ nonl();
+ use_default_colors();
+
+ init_pair(PT_COLOR_DEFAULT, COLOR_WHITE, COLOR_BLACK);
+ init_pair(PT_COLOR_ERROR, COLOR_BLACK, COLOR_RED);
+ //init_pair(PT_COLOR_HEADER_BAR, COLOR_BLACK, COLOR_WHITE);
+ init_pair(PT_COLOR_HEADER_BAR, COLOR_BLACK, COLOR_GREEN);
+ init_pair(PT_COLOR_YELLOW, COLOR_WHITE, COLOR_YELLOW);
+ init_pair(PT_COLOR_GREEN, COLOR_WHITE, COLOR_GREEN);
+ init_pair(PT_COLOR_BRIGHT, COLOR_WHITE, COLOR_BLACK);
+ init_pair(PT_COLOR_BLUE, COLOR_WHITE, COLOR_BLUE);
+ init_pair(PT_COLOR_RED, COLOR_WHITE, COLOR_RED);
+
+ atexit(fini_curses);
}
@@ -107,34 +107,34 @@ void create_windows(void)
void create_selectedwindow(void)
{
- WINDOW *win;
+ WINDOW *win;
- killall_windows(0);
+ killall_windows(0);
- getmaxyx(stdscr, maxy, maxx);
+ getmaxyx(stdscr, maxy, maxx);
+
+ win = subwin(stdscr, maxy - 2, maxx, 1, 0);
- win = subwin(stdscr, maxy - 2, maxx, 1, 0);
+ switch (selectedwindow) {
+ case REGULATOR: regulator_win = win;
+ break;
- switch (selectedwindow) {
- case REGULATOR: regulator_win = win;
- break;
+ case CLOCK: clock_win = win;
+ break;
- case CLOCK: clock_win = win;
- break;
+ case SENSOR: sensor_win = win;
+ break;
+ }
- case SENSOR: sensor_win = win;
- break;
- }
+ selected_win = win;
- selected_win = win;
-
- refresh();
+ refresh();
}
void show_header(void)
{
int i, j = 0;
- //char format[64];
+ //char format[64];
wattrset(header_win, COLOR_PAIR(PT_COLOR_HEADER_BAR));
wbkgd(header_win, COLOR_PAIR(PT_COLOR_HEADER_BAR));
@@ -144,19 +144,19 @@ void show_header(void)
VERSION);
//print(header_win, 50, 0, "Refresh Rate %4.2f Secs", ticktime);
- for (i = 0; i < TOTAL_FEATURE_WINS; i++) {
- if (selectedwindow == i)
- wattron(header_win, A_REVERSE);
- else
- wattroff(header_win, A_REVERSE);
+ for (i = 0; i < TOTAL_FEATURE_WINS; i++) {
+ if (selectedwindow == i)
+ wattron(header_win, A_REVERSE);
+ else
+ wattroff(header_win, A_REVERSE);
- //sprintf(format, " %%-%ds ", sizeof(win_names[i]) + 2);
- //sprintf(format, " %%s ");
+ //sprintf(format, " %%-%ds ", sizeof(win_names[i]) + 2);
+ //sprintf(format, " %%s ");
- print(header_win, i*(maxx / TOTAL_FEATURE_WINS) + 20, 0,
- " %s ", win_names[i]);
- }
- wrefresh(header_win);
+ print(header_win, i*(maxx / TOTAL_FEATURE_WINS) + 20, 0,
+ " %s ", win_names[i]);
+ }
+ wrefresh(header_win);
werase(footer_win);
@@ -177,7 +177,7 @@ void show_regulator_info(int verbose)
{
int i, count = 1;
- (void)verbose;
+ (void)verbose;
werase(regulator_win);
wattron(regulator_win, A_BOLD);
@@ -198,10 +198,10 @@ void show_regulator_info(int verbose)
break;
if(regulators_info[i].num_users > 0)
- wattron(regulator_win, WA_BOLD);
- else
- wattroff(regulator_win, WA_BOLD);
-
+ wattron(regulator_win, WA_BOLD);
+ else
+ wattroff(regulator_win, WA_BOLD);
+
print(regulator_win, col, count, "%s",
regulators_info[i].name);
col += 12;
@@ -234,72 +234,72 @@ void show_regulator_info(int verbose)
void print_clock_header(int level)
{
- char lev[NAME_MAX];
-
- sprintf(lev, "(Level %d)\n", level);
- werase(clock_win);
- wattron(clock_win, A_BOLD);
- print(clock_win, 0, 0, "Name %s", lev);
- print(clock_win, 48, 0, "Flags");
- print(clock_win, 60, 0, "Rate");
- print(clock_win, 72, 0, "Usecount");
- wattroff(clock_win, A_BOLD);
+ char lev[NAME_MAX];
+
+ sprintf(lev, "(Level %d)\n", level);
+ werase(clock_win);
+ wattron(clock_win, A_BOLD);
+ print(clock_win, 0, 0, "Name %s", lev);
+ print(clock_win, 48, 0, "Flags");
+ print(clock_win, 60, 0, "Rate");
+ print(clock_win, 72, 0, "Usecount");
+ wattroff(clock_win, A_BOLD);
wrefresh(clock_win);
}
void print_sensor_header(void)
{
- werase(sensor_win);
- wattron(sensor_win, A_BOLD);
- print(sensor_win, 0, 0, "Name");
- print(sensor_win, 36, 0, "Temperature");
- wattroff(sensor_win, A_BOLD);
- wattron(sensor_win, A_BLINK);
- print(sensor_win, 0, 1, "Currently Sensor information available"
- " only in Dump mode!");
- wattroff(sensor_win, A_BLINK);
+ werase(sensor_win);
+ wattron(sensor_win, A_BOLD);
+ print(sensor_win, 0, 0, "Name");
+ print(sensor_win, 36, 0, "Temperature");
+ wattroff(sensor_win, A_BOLD);
+ wattron(sensor_win, A_BLINK);
+ print(sensor_win, 0, 1, "Currently Sensor information available"
+ " only in Dump mode!");
+ wattroff(sensor_win, A_BLINK);
wrefresh(sensor_win);
}
void print_clock_info_line(int line, char *clockname, int flags, int rate,
- int usecount, int highlight)
+ int usecount, int highlight)
{
- if (usecount)
- wattron(clock_win, WA_BOLD);
- else {
- wattroff(clock_win, WA_BOLD);
- wattron(clock_win, WA_DIM);
- }
-
- if (highlight)
- wattron(clock_win, WA_REVERSE);
- else
- wattroff(clock_win, WA_REVERSE);
-
- print(clock_win, 0, line + 1, "%s", clockname);
- if (strcmp(clockname, "..")) {
- double drate = 0.0;
- char unit[8];
-
- print(clock_win, 48, line + 1, "%d", flags);
- if (rate > 1000 && rate < 1000000) {
- drate = (double)rate/1000.0;
- strcpy(unit, "KHz");
- } else if (rate > 1000000) {
- drate = (double)rate/1000000.0;
- strcpy(unit, "MHz");
- } else {
- drate = (double)rate;
- strcpy(unit, " Hz");
- }
- print(clock_win, 60, line + 1, "%6.2f %s", drate, unit);
- print(clock_win, 72, line + 1, "%d", usecount);
- }
-
- if (highlight)
- wattroff(clock_win, WA_BOLD|WA_STANDOUT);
- else
- wattroff(clock_win, WA_DIM);
-
- wrefresh(clock_win);
+ if (usecount)
+ wattron(clock_win, WA_BOLD);
+ else {
+ wattroff(clock_win, WA_BOLD);
+ wattron(clock_win, WA_DIM);
+ }
+
+ if (highlight)
+ wattron(clock_win, WA_REVERSE);
+ else
+ wattroff(clock_win, WA_REVERSE);
+
+ print(clock_win, 0, line + 1, "%s", clockname);
+ if (strcmp(clockname, "..")) {
+ double drate = 0.0;
+ char unit[8];
+
+ print(clock_win, 48, line + 1, "%d", flags);
+ if (rate > 1000 && rate < 1000000) {
+ drate = (double)rate/1000.0;
+ strcpy(unit, "KHz");
+ } else if (rate > 1000000) {
+ drate = (double)rate/1000000.0;
+ strcpy(unit, "MHz");
+ } else {
+ drate = (double)rate;
+ strcpy(unit, " Hz");
+ }
+ print(clock_win, 60, line + 1, "%6.2f %s", drate, unit);
+ print(clock_win, 72, line + 1, "%d", usecount);
+ }
+
+ if (highlight)
+ wattroff(clock_win, WA_BOLD|WA_STANDOUT);
+ else
+ wattroff(clock_win, WA_DIM);
+
+ wrefresh(clock_win);
}
diff --git a/powerdebug.c b/powerdebug.c
index 8c84932..2bef01f 100644
--- a/powerdebug.c
+++ b/powerdebug.c
@@ -24,9 +24,9 @@ int selectedwindow = -1;
double ticktime = 10.0; /* in seconds */
char *win_names[TOTAL_FEATURE_WINS] = {
- "Regulators",
- "Clocks",
- "Sensors" };
+ "Regulators",
+ "Clocks",
+ "Sensors" };
int init_regulator_ds(void)
{
@@ -219,7 +219,7 @@ int read_regulator_info(void)
if (!fptr)
continue;
- read_info_from_dirent(ritem, fptr, count - 1);
+ read_info_from_dirent(ritem, fptr, count - 1);
}
exit:
closedir(dir);
@@ -236,18 +236,18 @@ int main(int argc, char **argv)
{
int c, i;
int firsttime[TOTAL_FEATURE_WINS];
- int enter_hit = 0;
+ int enter_hit = 0;
int regulators = 0, sensors = 0, clocks = 0, verbose = 0;
- int r_share = 0, s_share = 0, c_share = 0; //%age share of the win size
+ int r_share = 0, s_share = 0, c_share = 0; //%age share of the win size
- for (i = 0; i < TOTAL_FEATURE_WINS; i++)
- firsttime[i] = 1;
+ for (i = 0; i < TOTAL_FEATURE_WINS; i++)
+ firsttime[i] = 1;
/*
* Options:
- * -r, --regulator : regulator
- * -s, --sensor : sensors
- * -c, --clock : clocks
+ * -r, --regulator : regulator
+ * -s, --sensor : sensors
+ * -c, --clock : clocks
* -t, --time : ticktime
* -d, --dump : dump
* -v, --verbose : verbose
@@ -259,9 +259,9 @@ int main(int argc, char **argv)
while (1) {
int optindex = 0;
static struct option long_options[] = {
- {"regulator", 0, 0, 'r'},
- {"sensor", 0, 0, 's'},
- {"clock", 0, 0, 'c'},
+ {"regulator", 0, 0, 'r'},
+ {"sensor", 0, 0, 's'},
+ {"clock", 0, 0, 'c'},
{"time", 0, 0, 't'},
{"dump", 0, 0, 'd'},
{"verbose", 0, 0, 'v'},
@@ -275,50 +275,50 @@ int main(int argc, char **argv)
break;
switch (c) {
- case 'r':
- regulators = 1;
- selectedwindow = REGULATOR;
- break;
- case 's':
- sensors = 1;
- selectedwindow = SENSOR;
- break;
- case 'c':
- clocks = 1;
- selectedwindow = CLOCK;
- break;
- case 't':
- ticktime = strtod(optarg, NULL);
- break;
- case 'd':
- dump = 1;
- break;
- case 'v':
- verbose = 1;
- break;
- case 'V':
- version();
- break;
- case 'h':
- usage(argv);
- break;
- case '?':
- fprintf (stderr, "%s: Unknown option %c'.\n",
- argv[0], optopt);
- exit(1);
- default:
- usage(argv);
- break;
+ case 'r':
+ regulators = 1;
+ selectedwindow = REGULATOR;
+ break;
+ case 's':
+ sensors = 1;
+ selectedwindow = SENSOR;
+ break;
+ case 'c':
+ clocks = 1;
+ selectedwindow = CLOCK;
+ break;
+ case 't':
+ ticktime = strtod(optarg, NULL);
+ break;
+ case 'd':
+ dump = 1;
+ break;
+ case 'v':
+ verbose = 1;
+ break;
+ case 'V':
+ version();
+ break;
+ case 'h':
+ usage(argv);
+ break;
+ case '?':
+ fprintf (stderr, "%s: Unknown option %c'.\n",
+ argv[0], optopt);
+ exit(1);
+ default:
+ usage(argv);
+ break;
}
}
- if (!dump && (regulators || clocks || sensors)) {
- fprintf(stderr, "Option supported only in dump mode (-d)\n");
- usage(argv);
- }
+ if (!dump && (regulators || clocks || sensors)) {
+ fprintf(stderr, "Option supported only in dump mode (-d)\n");
+ usage(argv);
+ }
- if (!dump)
- selectedwindow = REGULATOR;
+ if (!dump)
+ selectedwindow = REGULATOR;
init_regulator_ds();
@@ -332,54 +332,53 @@ int main(int argc, char **argv)
init_curses();
create_windows();
show_header();
- if (sensors)
- s_share = 20;
- if (regulators) {
- if (!sensors && clocks)
- r_share = 50;
- else if (clocks)
- r_share = 40;
- else
- r_share = 80;
- }
- c_share = 100 - (r_share + s_share);
+ if (sensors)
+ s_share = 20;
+ if (regulators) {
+ if (!sensors && clocks)
+ r_share = 50;
+ else if (clocks)
+ r_share = 40;
+ else
+ r_share = 80;
+ }
+ c_share = 100 - (r_share + s_share);
}
if (selectedwindow == REGULATOR) {
read_regulator_info();
if (!dump) {
- create_selectedwindow();
+ create_selectedwindow();
show_regulator_info(verbose);
- }
+ }
else
print_regulator_info(verbose);
}
- if (selectedwindow == CLOCK) {
- if (firsttime[CLOCK]) {
- init_clock_details();
- firsttime[CLOCK] = 0;
- }
- if (!dump) {
- int hrow;
-
- create_selectedwindow();
- hrow = read_and_print_clock_info(verbose,
- highlighted_row,
- enter_hit);
- highlighted_row = hrow;
- enter_hit = 0;
- } else
- dump_clock_info(verbose);
- }
+ if (selectedwindow == CLOCK) {
+ if (firsttime[CLOCK]) {
+ init_clock_details();
+ firsttime[CLOCK] = 0;
+ }
+ if (!dump) {
+ int hrow;
+
+ create_selectedwindow();
+ hrow = read_and_print_clock_info(verbose,
+ highlighted_row,
+ enter_hit);
+ highlighted_row = hrow;
+ enter_hit = 0;
+ } else
+ dump_clock_info(verbose);
+ }
if (selectedwindow == SENSOR) {
- if (!dump) {
- create_selectedwindow();
- print_sensor_header();
- }
- else
- read_and_print_sensor_info(verbose);
+ if (!dump) {
+ create_selectedwindow();
+ print_sensor_header();
+ } else
+ read_and_print_sensor_info(verbose);
}
if (dump)
@@ -400,33 +399,33 @@ int main(int argc, char **argv)
if (keystroke == EOF)
exit(0);
- if (keystroke == KEY_RIGHT || keystroke == 9)
- selectedwindow++;
+ if (keystroke == KEY_RIGHT || keystroke == 9)
+ selectedwindow++;
- if (keystroke == KEY_LEFT || keystroke == 353)
- selectedwindow--;
+ if (keystroke == KEY_LEFT || keystroke == 353)
+ selectedwindow--;
- if (selectedwindow >= TOTAL_FEATURE_WINS)
- selectedwindow = 0;
+ if (selectedwindow >= TOTAL_FEATURE_WINS)
+ selectedwindow = 0;
- if (selectedwindow < 0)
- selectedwindow = TOTAL_FEATURE_WINS - 1;
+ if (selectedwindow < 0)
+ selectedwindow = TOTAL_FEATURE_WINS - 1;
- if (selectedwindow == CLOCK) {
- if (keystroke == KEY_DOWN)
- highlighted_row++;
- if (keystroke == KEY_UP && highlighted_row > 0)
- highlighted_row--;
- }
+ if (selectedwindow == CLOCK) {
+ if (keystroke == KEY_DOWN)
+ highlighted_row++;
+ if (keystroke == KEY_UP && highlighted_row > 0)
+ highlighted_row--;
+ }
keychar = toupper(keystroke);
- //killall_windows(1); fini_curses();
- //printf("key entered %d:%c\n", keystroke, keychar);
- //exit(1);
+ //killall_windows(1); fini_curses();
+ //printf("key entered %d:%c\n", keystroke, keychar);
+ //exit(1);
- if (keystroke == 13)
- enter_hit = 1;
+ if (keystroke == 13)
+ enter_hit = 1;
if (keychar == 'Q')
exit(0);
diff --git a/powerdebug.h b/powerdebug.h
index 901cf77..f4d05c4 100644
--- a/powerdebug.h
+++ b/powerdebug.h
@@ -57,8 +57,8 @@ extern void version(void);
extern void print_regulator_info(int verbose);
extern void dump_clock_info(int verbose);
extern void read_clock_info(char *clkpath);
-extern struct clock_info *read_clock_info_recur(char *clkpath, int level, struct
- clock_info *parent);
+extern struct clock_info *read_clock_info_recur(char *clkpath, int level,
+ struct clock_info *parent);
extern void print_clock_info(struct clock_info *clk, int level, int bmp);
extern void insert_children(struct clock_info **parent, struct clock_info *clk);
extern int read_and_print_clock_info(int verbose, int hrow, int selected);
@@ -69,7 +69,7 @@ extern void init_clock_details(void);
extern void print_clock_header(int level);
extern void print_sensor_header(void);
extern void print_clock_info_line(int line, char *clockname, int flags,
- int rate, int usecount, int highlight);
+ int rate, int usecount, int highlight);
extern char *debugfs_locate_mpoint(void);
extern void init_curses(void);