diff options
author | Amit Kucheria <amit.kucheria@linaro.org> | 2011-01-12 10:54:23 -0600 |
---|---|---|
committer | Amit Kucheria <amit.kucheria@linaro.org> | 2011-01-12 10:54:23 -0600 |
commit | a0adae4313f5bd1cb649ddd52bb34c953c405b4c (patch) | |
tree | 92ee3970973393966a21c1c39d0a815417ccf7a8 | |
parent | ee851a1e8df5d777219d51fd285efe53e8e71d18 (diff) | |
download | powerdebug-a0adae4313f5bd1cb649ddd52bb34c953c405b4c.tar.gz |
Mass whitespace fixups
Get rid of blank lines, add spaces around operators, etc.
-rw-r--r-- | clocks.c | 30 | ||||
-rw-r--r-- | display.c | 36 | ||||
-rw-r--r-- | powerdebug.c | 32 | ||||
-rw-r--r-- | regulator.c | 26 | ||||
-rw-r--r-- | sensor.c | 27 | ||||
-rw-r--r-- | sensor.h | 1 |
6 files changed, 74 insertions, 78 deletions
@@ -32,15 +32,15 @@ int init_clock_details(void) if (!dump) { create_selectedwindow(); sprintf(clock_lines[0], "Unable to locate debugfs " - "mount point. Mount debugfs " - "and try again..\n"); + "mount point. Mount debugfs " + "and try again..\n"); print_one_clock(0, clock_lines[0], 1, 0); old_clock_line_no = 1; return(1); } else { fprintf(stderr, "powerdebug: Unable to locate debugfs " - "mount point. Mount debugfs and try " - "again..\n"); + "mount point. Mount debugfs and try " + "again..\n"); exit(1); } } @@ -97,7 +97,7 @@ void find_parents_for_clock(char *clkname, int complete) sprintf(name, "Parents for \"%s\" Clock : \n", clkname); print_one_clock(0, name, 1, 1); dump_all_parents(clkname); -} +} int read_and_print_clock_info(int verbose, int hrow, int selected) { @@ -147,7 +147,7 @@ void print_clock_info(int verbose, int hrow, int selected) delta = calc_delta_screen_size(hrow); while (clock_lines[count + delta] && - strcmp(clock_lines[count + delta], "")) { + strcmp(clock_lines[count + delta], "")) { if (count < delta) { count++; continue; @@ -318,7 +318,7 @@ void read_clock_info(char *clkpath) } struct clock_info *read_clock_info_recur(char *clkpath, int level, - struct clock_info *parent) + struct clock_info *parent) { int ret = 0; DIR *dir; @@ -380,16 +380,16 @@ 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); + 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)); + 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; + = 0; clk->last_child = 1; (*parent)->children[(*parent)->num_children] = clk; (*parent)->children[(*parent)->num_children + 1] = NULL; @@ -406,7 +406,7 @@ void dump_parent(struct clock_info *clk, int line) if (maxline < line) maxline = line; - + if (clk && clk->parent) dump_parent(clk->parent, ++line); @@ -512,7 +512,7 @@ void dump_clock_info(struct clock_info *clk, int level, int bmp) else { char *unit = "Hz"; double drate = (double)clk->rate; - + if (drate > 1000 && drate < 1000000) { unit = "KHz"; drate /= 1000; @@ -564,7 +564,7 @@ char *debugfs_locate_mpoint(void) } while (fscanf(filep, "%*s %s %s %*s %*d %*d\n", - debugfs_mntpoint, fsname) == 2) + debugfs_mntpoint, fsname) == 2) if (!strcmp(fsname, "debugfs")) break; fclose(filep); @@ -99,7 +99,7 @@ void create_windows(void) if (selectedwindow == CLOCK) strcpy(footer_items[2], " Other Keys: 'Left', 'Right', 'Up', 'Down', 'enter', " - " '/', 'Esc' "); + " '/', 'Esc' "); else strcpy(footer_items[2], " Other Keys: 'Left', 'Right' "); @@ -122,13 +122,13 @@ void create_selectedwindow(void) switch (selectedwindow) { case REGULATOR: regulator_win = win; - break; + break; case CLOCK: clock_win = win; - break; + break; case SENSOR: sensor_win = win; - break; + break; } selected_win = win; @@ -160,8 +160,8 @@ void show_header(void) wrefresh(header_win); werase(footer_win); - for (i=0; i<NUM_FOOTER_ITEMS; i++) { - if (strlen(footer_items[i])==0) + for (i = 0; i < NUM_FOOTER_ITEMS; i++) { + if (strlen(footer_items[i]) == 0) continue; wattron(footer_win, A_REVERSE); print(footer_win, j, 0, "%s", footer_items[i]); @@ -190,40 +190,40 @@ void show_regulator_info(int verbose) print(regulator_win, 84, 0, "Max u-volts"); wattroff(regulator_win, A_BOLD); - for (i=0; i<numregulators; i++) { + for (i = 0; i < numregulators; i++) { int col = 0; - if((i + 2) > (maxy-2)) + if ((i + 2) > (maxy-2)) break; - if(regulators_info[i].num_users > 0) + if (regulators_info[i].num_users > 0) wattron(regulator_win, WA_BOLD); else wattroff(regulator_win, WA_BOLD); print(regulator_win, col, count, "%s", - regulators_info[i].name); + regulators_info[i].name); col += 12; print(regulator_win, col, count, "%s", - regulators_info[i].status); + regulators_info[i].status); col += 12; print(regulator_win, col, count, "%s", - regulators_info[i].state); + regulators_info[i].state); col += 12; print(regulator_win, col, count, "%s", - regulators_info[i].type); + regulators_info[i].type); col += 12; print(regulator_win, col, count, "%d", - regulators_info[i].num_users); + regulators_info[i].num_users); col += 12; print(regulator_win, col, count, "%d", - regulators_info[i].microvolts); + regulators_info[i].microvolts); col += 12; print(regulator_win, col, count, "%d", - regulators_info[i].min_microvolts); + regulators_info[i].min_microvolts); col += 12; print(regulator_win, col, count, "%d", - regulators_info[i].max_microvolts); + regulators_info[i].max_microvolts); count++; } @@ -253,7 +253,7 @@ void print_sensor_header(void) wattroff(sensor_win, A_BOLD); wattron(sensor_win, A_BLINK); print(sensor_win, 0, 1, "Currently Sensor information available" - " only in Dump mode!"); + " only in Dump mode!"); wattroff(sensor_win, A_BLINK); wrefresh(sensor_win); } diff --git a/powerdebug.c b/powerdebug.c index e12d917..871b947 100644 --- a/powerdebug.c +++ b/powerdebug.c @@ -39,11 +39,11 @@ void usage(void) printf(" -s, --sensor Show sensor information\n"); printf(" -c, --clock Show clock information\n"); printf(" -p, --findparents Show all parents for a particular" - " clock\n"); + " clock\n"); printf(" -t, --time Set ticktime in seconds (eg. 10.0)\n"); printf(" -d, --dump Dump information once (no refresh)\n"); printf(" -v, --verbose Verbose mode (use with -r and/or" - " -s)\n"); + " -s)\n"); printf(" -V, --version Show Version\n"); printf(" -h, --help Help\n"); @@ -134,7 +134,7 @@ int main(int argc, char **argv) break; case '?': fprintf (stderr, "%s: Unknown option %c'.\n", - argv[0], optopt); + argv[0], optopt); exit(1); default: usage(); @@ -161,19 +161,18 @@ int main(int argc, char **argv) init_regulator_ds(); - while(1) { + while (1) { int key = 0; struct timeval tval; fd_set readfds; if (!dump) { - if(firsttime[0]) + if (firsttime[0]) init_curses(); create_windows(); show_header(); } - if (regulators || selectedwindow == REGULATOR) { read_regulator_info(); if (!dump) { @@ -204,14 +203,14 @@ int main(int argc, char **argv) if (refreshwin) command = REFRESH_WINDOW; hrow = read_and_print_clock_info( - verbose, - highlighted_row, - command); + verbose, + highlighted_row, + command); highlighted_row = hrow; enter_hit = 0; } else find_parents_for_clock(clkname_str, - enter_hit); + enter_hit); } if (!ret && dump) { if (findparent) @@ -268,7 +267,7 @@ int main(int argc, char **argv) findparent_ncurses = 1; if ((keystroke == 27 || oldselectedwin != - selectedwindow) && findparent_ncurses) { + selectedwindow) && findparent_ncurses) { findparent_ncurses = 0; clkname_str[0] = '\0'; } @@ -285,11 +284,11 @@ int main(int argc, char **argv) } else { if (strlen(clkname_str) || keystroke != '/') { - str[0] = keystroke; - str[1] = '\0'; - if (len < 63) - strcat(clkname_str, - str); + str[0] = keystroke; + str[1] = '\0'; + if (len < 63) + strcat(clkname_str, + str); } } } @@ -317,4 +316,3 @@ int main(int argc, char **argv) } exit(0); } - diff --git a/regulator.c b/regulator.c index 5936e21..bc3554f 100644 --- a/regulator.c +++ b/regulator.c @@ -24,7 +24,7 @@ int init_regulator_ds(void) regdir = opendir("/sys/class/regulator"); if (!regdir) return(1); - while((item = readdir(regdir))) { + while ((item = readdir(regdir))) { if (strncmp(item->d_name, "regulator", 9)) continue; @@ -33,20 +33,20 @@ int init_regulator_ds(void) closedir(regdir); regulators_info = (struct regulator_info *)malloc(numregulators* - sizeof(struct regulator_info)); + sizeof(struct regulator_info)); if (!regulators_info) { fprintf(stderr, "init_regulator_ds: Not enough memory to " - "read information for %d regulators!\n", numregulators); + "read information for %d regulators!\n", numregulators); return(1); } - return(0); + return(0); } void print_string_val(char *name, char *val) { printf("\t%s=%s", name, val); - if(!strchr(val, '\n')) + if (!strchr(val, '\n')) printf("\n"); } @@ -57,9 +57,9 @@ void print_regulator_info(int verbose) printf("\nRegulator Information:\n"); printf("*********************\n\n"); - for (i=0; i<numregulators; i++) { - printf("Regulator %d:\n", i+1); - print_string_val("name", regulators_info[i].name); + for (i = 0; i < numregulators; i++) { + printf("Regulator %d:\n", i + 1); + print_string_val("name", regulators_info[i].name); if (strcmp(regulators_info[i].status, "")) print_string_val("status", regulators_info[i].status); if (strcmp(regulators_info[i].state, "")) @@ -155,7 +155,7 @@ int read_regulator_info(void) regdir = opendir("/sys/class/regulator"); if (!regdir) return(1); - while((item = readdir(regdir))) { + while ((item = readdir(regdir))) { if (strlen(item->d_name) < 3) continue; @@ -163,7 +163,7 @@ int read_regulator_info(void) continue; len = sprintf(filename, "/sys/class/regulator/%s", - item->d_name); + item->d_name); dir = opendir(filename); if (!dir) @@ -176,7 +176,7 @@ int read_regulator_info(void) } strcpy(regulators_info[count-1].name, item->d_name); - while((ritem = readdir(dir))) { + while ((ritem = readdir(dir))) { if (strlen(ritem->d_name) < 3) continue; @@ -191,11 +191,11 @@ int read_regulator_info(void) continue; read_info_from_dirent(ritem, fptr, count - 1); } -exit: + exit: closedir(dir); if (ret) break; - } + } closedir(regdir); return ret; @@ -30,7 +30,6 @@ char *get_num(char *fname, char *sensor) str = strdup(tmpstr); return str; } - void get_sensor_info(char *path, char *fname, char *sensor, int verbose) { @@ -44,21 +43,21 @@ void get_sensor_info(char *path, char *fname, char *sensor, int verbose) sprintf(filename, "%s/%s", path, fname); - if(!strcmp(sensor, "in")) { + if (!strcmp(sensor, "in")) { items = (char **)items_in; suffix = (char **)suffix_in; } - if(!strcmp(sensor, "temp")) { + if (!strcmp(sensor, "temp")) { items = (char **)items_temp; suffix = (char **)suffix_temp; } - if(!strcmp(sensor, "fan")) { + if (!strcmp(sensor, "fan")) { items = (char **)items_fan; suffix = (char **)suffix_fan; } - if(!strcmp(sensor, "pwm")) { + if (!strcmp(sensor, "pwm")) { items = (char **)items_pwm; suffix = (char **)suffix_pwm; } @@ -68,28 +67,28 @@ void get_sensor_info(char *path, char *fname, char *sensor, int verbose) return; item = strrchr(fname, '_'); - if(!item) + if (!item) return; - if(item) + if (item) item++; - if(item > (fname + strlen(fname))) + if (item > (fname + strlen(fname))) return; num = get_num(fname, sensor); filep = fopen(filename, "r"); - if(!filep) + if (!filep) goto exit; ret = fscanf(filep, "%s", result); fclose(filep); - if(ret != 1) + if (ret != 1) goto exit; - while(strcmp(items[count], "")) { - if(!strcmp(items[count], item)) + while (strcmp(items[count], "")) { + if (!strcmp(items[count], item)) printf("\'temp\' %s sensor %s\t\t%d%s\n", num, items[count], atoi(result)/1000, suffix[count]); @@ -141,7 +140,7 @@ int read_and_print_sensor_info(int verbose) if (subitem->d_name[0] == '.') /* skip hidden files */ continue; - if(!strncmp(subitem->d_name, "in", 2)) + if (!strncmp(subitem->d_name, "in", 2)) get_sensor_info(devpath, subitem->d_name, "in", verbose); else if (!strncmp(subitem->d_name, "temp", 4)) @@ -160,7 +159,7 @@ int read_and_print_sensor_info(int verbose) } closedir(dir); - if(!found && verbose) { + if (!found && verbose) { printf("Could not find sensor information!"); printf(" Looks like /sys/class/hwmon is empty.\n"); } @@ -22,4 +22,3 @@ char *items_fan[32] = {"min", "max", "input", "label", "div", "target", ""}; char *suffix_fan[32] = {"RPM", "RPM", "RPM", "", "", "RPM", ""}; char *items_pwm[32] = {"freq", "enable", "mode", ""}; char *suffix_pwm[32] = {"Hz", "", "", ""}; - |