Create a single structure for powerdebug options.
Signed-off-by: Daniel Lezcano daniel.lezcano@free.fr --- powerdebug.c | 173 +++++++++++++++++++++++++++++++++------------------------- 1 files changed, 98 insertions(+), 75 deletions(-)
diff --git a/powerdebug.c b/powerdebug.c index 3f4d60c..efdb1a2 100644 --- a/powerdebug.c +++ b/powerdebug.c @@ -19,7 +19,6 @@ int dump; int highlighted_row; int selectedwindow = -1; -double ticktime = 10.0; /* in seconds */
char *win_names[TOTAL_FEATURE_WINS] = { "Clocks", @@ -45,119 +44,143 @@ void usage(void) " -s)\n"); printf(" -V, --version Show Version\n"); printf(" -h, --help Help\n"); - - exit(0); }
void version() { printf("powerdebug version %s\n", VERSION); - exit(0); }
-int main(int argc, char **argv) -{ - int c, i; - int firsttime[TOTAL_FEATURE_WINS]; - int enter_hit = 0, verbose = 0, findparent_ncurses = 0, refreshwin = 0; - int regulators = 0, sensors = 0, clocks = 0, findparent = 0; - char clkarg[64], clkname_str[64]; +/* + * Options: + * -r, --regulator : regulator + * -s, --sensor : sensors + * -c, --clock : clocks + * -p, --findparents : clockname whose parents have to be found + * -t, --time : ticktime + * -d, --dump : dump + * -v, --verbose : verbose + * -V, --version : version + * -h, --help : help + * no option / default : show usage! + */ + +static struct option long_options[] = { + { "regulator", 0, 0, 'r' }, + { "sensor", 0, 0, 's' }, + { "clock", 0, 0, 'c' }, + { "findparents", 1, 0, 'p' }, + { "time", 1, 0, 't' }, + { "dump", 0, 0, 'd' }, + { "verbose", 0, 0, 'v' }, + { "version", 0, 0, 'V' }, + { "help", 0, 0, 'h' }, + { 0, 0, 0, 0 } +};
- for (i = 0; i < TOTAL_FEATURE_WINS; i++) - firsttime[i] = 1; +struct powerdebug_options { + int findparent; + int verbose; + int regulators; + int sensors; + int clocks; + int ticktime; + char clkarg[64]; +}; + +int getoptions(int argc, char *argv[], struct powerdebug_options *options) +{ + int c;
- /* - * Options: - * -r, --regulator : regulator - * -s, --sensor : sensors - * -c, --clock : clocks - * -p, --findparents : clockname whose parents have to be found - * -t, --time : ticktime - * -d, --dump : dump - * -v, --verbose : verbose - * -V, --version : version - * -h, --help : help - * no option / default : show usage! - */ + memset(options, 0, sizeof(*options)); + options->ticktime = 10;
while (1) { int optindex = 0; - static struct option long_options[] = { - {"regulator", 0, 0, 'r'}, - {"sensor", 0, 0, 's'}, - {"clock", 0, 0, 'c'}, - {"findparents", 1, 0, 'p'}, - {"time", 1, 0, 't'}, - {"dump", 0, 0, 'd'}, - {"verbose", 0, 0, 'v'}, - {"version", 0, 0, 'V'}, - {"help", 0, 0, 'h'}, - {0, 0, 0, 0} - }; - - c = getopt_long(argc, argv, "rscp:t:dvVh", long_options, &optindex); + + c = getopt_long(argc, argv, "rscp:t:dvVh", + long_options, &optindex); if (c == -1) break;
switch (c) { case 'r': - regulators = 1; + options->regulators = 1; selectedwindow = REGULATOR; break; case 's': - sensors = 1; + options->sensors = 1; selectedwindow = SENSOR; break; case 'c': - clocks = 1; + options->clocks = 1; selectedwindow = CLOCK; break; case 'p': - findparent = 1; - strcpy(clkarg, optarg); + options->findparent = 1; + strcpy(options->clkarg, optarg); break; case 't': - ticktime = strtod(optarg, NULL); + options->ticktime = strtod(optarg, NULL); break; case 'd': dump = 1; break; case 'v': - verbose = 1; + options->verbose = 1; break; case 'V': version(); break; - case 'h': - usage(); - break; case '?': - fprintf (stderr, "%s: Unknown option %c'.\n", + fprintf(stderr, "%s: Unknown option %c'.\n", argv[0], optopt); - exit(1); default: - usage(); - break; + return -1; } }
- if (dump && !(regulators || clocks || sensors)) { - //fprintf(stderr, "Dump mode (-d) supported only with -c, -r " - // "or -s ..\n"); - //usage(); - // By Default lets show everything we have! - regulators = clocks = sensors = 1; + if (dump && !(options->regulators || + options->clocks || options->sensors)) { + /* By Default lets show everything we have */ + options->regulators = options->clocks = options->sensors = 1; }
- if (findparent && (!clocks || !dump)) { + if (options->findparent && (!options->clocks || !dump)) { fprintf(stderr, "-p option passed without -c and -d." " Exiting...\n"); - usage(); + return -1; }
if (!dump && selectedwindow == -1) selectedwindow = CLOCK;
+ return 0; +} + +int main(int argc, char **argv) +{ + int i; + int findparent_ncurses = 0, refreshwin = 0; + int enter_hit = 0; + int firsttime[TOTAL_FEATURE_WINS]; + char clkname_str[64]; + struct powerdebug_options *options; + + for (i = 0; i < TOTAL_FEATURE_WINS; i++) + firsttime[i] = 1; + + options = malloc(sizeof(*options)); + if (!options) { + fprintf(stderr, "failed to allocated memory\n"); + return -1; + } + + if (getoptions(argc, argv, options)) { + usage(); + return 1; + } + init_regulator_ds();
while (1) { @@ -172,17 +195,17 @@ int main(int argc, char **argv) show_header(); }
- if (regulators || selectedwindow == REGULATOR) { + if (options->regulators || selectedwindow == REGULATOR) { read_regulator_info(); if (!dump) { create_selectedwindow(); - show_regulator_info(verbose); + show_regulator_info(options->verbose); } else - print_regulator_info(verbose); + print_regulator_info(options->verbose); }
- if (clocks || selectedwindow == CLOCK) { + if (options->clocks || selectedwindow == CLOCK) { int ret = 0; if (firsttime[CLOCK]) { ret = init_clock_details(); @@ -202,7 +225,7 @@ int main(int argc, char **argv) if (refreshwin) command = REFRESH_WINDOW; hrow = read_and_print_clock_info( - verbose, + options->verbose, highlighted_row, command); highlighted_row = hrow; @@ -212,19 +235,19 @@ int main(int argc, char **argv) enter_hit); } if (!ret && dump) { - if (findparent) - read_and_dump_clock_info_one(clkarg); + if (options->findparent) + read_and_dump_clock_info_one(options->clkarg); else - read_and_dump_clock_info(verbose); + read_and_dump_clock_info(options->verbose); } }
- if (sensors || selectedwindow == SENSOR) { + if (options->sensors || selectedwindow == SENSOR) { if (!dump) { create_selectedwindow(); print_sensor_header(); } else - read_and_print_sensor_info(verbose); + read_and_print_sensor_info(options->verbose); }
if (dump) @@ -232,8 +255,8 @@ int main(int argc, char **argv)
FD_ZERO(&readfds); FD_SET(0, &readfds); - tval.tv_sec = ticktime; - tval.tv_usec = (ticktime - tval.tv_sec) * 1000000; + tval.tv_sec = options->ticktime; + tval.tv_usec = (options->ticktime - tval.tv_sec) * 1000000;
key = select(1, &readfds, NULL, NULL, &tval);
@@ -308,7 +331,7 @@ int main(int argc, char **argv) exit(0); if (keychar == 'R') { refreshwin = 1; - ticktime = 3; + options->ticktime = 3; } else refreshwin = 0; }
Signed-off-by: Daniel Lezcano daniel.lezcano@free.fr --- powerdebug.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/powerdebug.c b/powerdebug.c index efdb1a2..05c0e34 100644 --- a/powerdebug.c +++ b/powerdebug.c @@ -85,7 +85,7 @@ struct powerdebug_options { int sensors; int clocks; int ticktime; - char clkarg[64]; + char *clkarg; };
int getoptions(int argc, char *argv[], struct powerdebug_options *options) @@ -118,7 +118,11 @@ int getoptions(int argc, char *argv[], struct powerdebug_options *options) break; case 'p': options->findparent = 1; - strcpy(options->clkarg, optarg); + options->clkarg = strdup(optarg); + if (!options->clkarg) { + fprintf(stderr, "failed to allocate memory"); + return -1; + } break; case 't': options->ticktime = strtod(optarg, NULL);
Signed-off-by: Daniel Lezcano daniel.lezcano@free.fr --- powerdebug.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/powerdebug.c b/powerdebug.c index 05c0e34..7de6ddd 100644 --- a/powerdebug.c +++ b/powerdebug.c @@ -125,7 +125,7 @@ int getoptions(int argc, char *argv[], struct powerdebug_options *options) } break; case 't': - options->ticktime = strtod(optarg, NULL); + options->ticktime = atoi(optarg); break; case 'd': dump = 1;
Signed-off-by: Daniel Lezcano daniel.lezcano@free.fr --- powerdebug.c | 3 ++- powerdebug.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/powerdebug.c b/powerdebug.c index 7de6ddd..8d74538 100644 --- a/powerdebug.c +++ b/powerdebug.c @@ -185,7 +185,8 @@ int main(int argc, char **argv) return 1; }
- init_regulator_ds(); + if (init_regulator_ds()) + return -1;
while (1) { int key = 0; diff --git a/powerdebug.h b/powerdebug.h index 8a3b5bd..8401a84 100644 --- a/powerdebug.h +++ b/powerdebug.h @@ -39,8 +39,8 @@ extern double ticktime;
extern void version(void);
+extern int init_regulator_ds(void); extern void print_regulator_info(int verbose); -extern void init_regulator_ds(void); extern void read_regulator_info(void); extern void print_regulator_info(int verbose);
Signed-off-by: Daniel Lezcano daniel.lezcano@free.fr --- powerdebug.c | 48 +++++++++++++++++++++++++++++------------------- 1 files changed, 29 insertions(+), 19 deletions(-)
diff --git a/powerdebug.c b/powerdebug.c index 8d74538..71efcd1 100644 --- a/powerdebug.c +++ b/powerdebug.c @@ -162,32 +162,17 @@ int getoptions(int argc, char *argv[], struct powerdebug_options *options) return 0; }
-int main(int argc, char **argv) +int mainloop(struct powerdebug_options *options) { - int i; int findparent_ncurses = 0, refreshwin = 0; int enter_hit = 0; int firsttime[TOTAL_FEATURE_WINS]; + int i; char clkname_str[64]; - struct powerdebug_options *options;
for (i = 0; i < TOTAL_FEATURE_WINS; i++) firsttime[i] = 1;
- options = malloc(sizeof(*options)); - if (!options) { - fprintf(stderr, "failed to allocated memory\n"); - return -1; - } - - if (getoptions(argc, argv, options)) { - usage(); - return 1; - } - - if (init_regulator_ds()) - return -1; - while (1) { int key = 0; struct timeval tval; @@ -333,7 +318,7 @@ int main(int argc, char **argv) enter_hit = 1;
if (keychar == 'Q' && !findparent_ncurses) - exit(0); + break; if (keychar == 'R') { refreshwin = 1; options->ticktime = 3; @@ -341,5 +326,30 @@ int main(int argc, char **argv) refreshwin = 0; } } - exit(0); + + return 0; +} + +int main(int argc, char **argv) +{ + struct powerdebug_options *options; + + options = malloc(sizeof(*options)); + if (!options) { + fprintf(stderr, "failed to allocated memory\n"); + return -1; + } + + if (getoptions(argc, argv, options)) { + usage(); + return 1; + } + + if (init_regulator_ds()) + return 1; + + if (mainloop(options)) + return 1; + + return 0; }
Signed-off-by: Daniel Lezcano daniel.lezcano@free.fr --- powerdebug.c | 160 +++++++++++++++++++++++++++++++--------------------------- 1 files changed, 86 insertions(+), 74 deletions(-)
diff --git a/powerdebug.c b/powerdebug.c index 71efcd1..73f10dc 100644 --- a/powerdebug.c +++ b/powerdebug.c @@ -162,6 +162,87 @@ int getoptions(int argc, char *argv[], struct powerdebug_options *options) return 0; }
+int keystroke_callback(int *enter_hit, int *findparent_ncurses, + char *clkname_str, int *refreshwin, + struct powerdebug_options *options) +{ + char keychar; + int keystroke = getch(); + int oldselectedwin = selectedwindow; + + if (keystroke == EOF) + exit(0); + + if (keystroke == KEY_RIGHT || keystroke == 9) + selectedwindow++; + + if (keystroke == KEY_LEFT || keystroke == 353) + selectedwindow--; + + if (selectedwindow >= TOTAL_FEATURE_WINS) + selectedwindow = 0; + + 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 (keystroke == 47) + *findparent_ncurses = 1; + + if ((keystroke == 27 || oldselectedwin != + selectedwindow) && *findparent_ncurses) { + *findparent_ncurses = 0; + clkname_str[0] = '\0'; + } + + if (*findparent_ncurses && keystroke != 13) { + int len = strlen(clkname_str); + char str[2]; + + if (keystroke == 263) { + if (len > 0) + len--; + + clkname_str[len] = '\0'; + } else { + if (strlen(clkname_str) || + keystroke != '/') { + str[0] = keystroke; + str[1] = '\0'; + if (len < 63) + strcat(clkname_str, + str); + } + } + } + } + + keychar = toupper(keystroke); +//#define DEBUG +#ifdef DEBUG + killall_windows(1); fini_curses(); + printf("key entered %d:%c\n", keystroke, keychar); + exit(1); +#endif + + if (keystroke == 13) + *enter_hit = 1; + + if (keychar == 'Q' && !*findparent_ncurses) + return 1; + if (keychar == 'R') { + *refreshwin = 1; + options->ticktime = 3; + } else + *refreshwin = 0; + + return 0; +} + int mainloop(struct powerdebug_options *options) { int findparent_ncurses = 0, refreshwin = 0; @@ -249,82 +330,13 @@ int mainloop(struct powerdebug_options *options) tval.tv_usec = (options->ticktime - tval.tv_sec) * 1000000;
key = select(1, &readfds, NULL, NULL, &tval); + if (!key) + continue;
- if (key) { - char keychar; - int keystroke = getch(); - int oldselectedwin = selectedwindow; - - if (keystroke == EOF) - exit(0); - - if (keystroke == KEY_RIGHT || keystroke == 9) - selectedwindow++; - - if (keystroke == KEY_LEFT || keystroke == 353) - selectedwindow--; - - if (selectedwindow >= TOTAL_FEATURE_WINS) - selectedwindow = 0; - - 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 (keystroke == 47) - findparent_ncurses = 1; - - if ((keystroke == 27 || oldselectedwin != - selectedwindow) && findparent_ncurses) { - findparent_ncurses = 0; - clkname_str[0] = '\0'; - } - - if (findparent_ncurses && keystroke != 13) { - int len = strlen(clkname_str); - char str[2]; - - if (keystroke == 263) { - if (len > 0) - len--; - - clkname_str[len] = '\0'; - } else { - if (strlen(clkname_str) || - keystroke != '/') { - str[0] = keystroke; - str[1] = '\0'; - if (len < 63) - strcat(clkname_str, - str); - } - } - } - } - - keychar = toupper(keystroke); -//#define DEBUG -#ifdef DEBUG - killall_windows(1); fini_curses(); - printf("key entered %d:%c\n", keystroke, keychar); - exit(1); -#endif - - if (keystroke == 13) - enter_hit = 1; + if (keystroke_callback(&enter_hit, &findparent_ncurses, + clkname_str, &refreshwin, options)) + break;
- if (keychar == 'Q' && !findparent_ncurses) - break; - if (keychar == 'R') { - refreshwin = 1; - options->ticktime = 3; - } else - refreshwin = 0; - } }
return 0;
sizeof(int) : 4 sizeof(bool): 1
Signed-off-by: Daniel Lezcano daniel.lezcano@free.fr --- clocks.h | 1 - powerdebug.c | 50 ++++++++++++++++++++++++++------------------------ powerdebug.h | 2 +- regulator.h | 1 - 4 files changed, 27 insertions(+), 27 deletions(-)
diff --git a/clocks.h b/clocks.h index e2be430..a240b72 100644 --- a/clocks.h +++ b/clocks.h @@ -20,7 +20,6 @@ #include <linux/magic.h>
extern int maxy; -extern int dump;
#define MAX_LINES 120
diff --git a/powerdebug.c b/powerdebug.c index 73f10dc..f5d95d3 100644 --- a/powerdebug.c +++ b/powerdebug.c @@ -14,9 +14,10 @@ *******************************************************************************/
#include <getopt.h> +#include <stdbool.h> #include "powerdebug.h"
-int dump; +bool dump = false; int highlighted_row; int selectedwindow = -1;
@@ -79,12 +80,12 @@ static struct option long_options[] = { };
struct powerdebug_options { - int findparent; - int verbose; - int regulators; - int sensors; - int clocks; - int ticktime; + bool verbose; + bool findparent; + bool regulators; + bool sensors; + bool clocks; + unsigned int ticktime; char *clkarg; };
@@ -105,19 +106,19 @@ int getoptions(int argc, char *argv[], struct powerdebug_options *options)
switch (c) { case 'r': - options->regulators = 1; + options->regulators = true; selectedwindow = REGULATOR; break; case 's': - options->sensors = 1; + options->sensors = true; selectedwindow = SENSOR; break; case 'c': - options->clocks = 1; + options->clocks = true; selectedwindow = CLOCK; break; case 'p': - options->findparent = 1; + options->findparent = true; options->clkarg = strdup(optarg); if (!options->clkarg) { fprintf(stderr, "failed to allocate memory"); @@ -128,10 +129,10 @@ int getoptions(int argc, char *argv[], struct powerdebug_options *options) options->ticktime = atoi(optarg); break; case 'd': - dump = 1; + dump = true; break; case 'v': - options->verbose = 1; + options->verbose = true; break; case 'V': version(); @@ -147,7 +148,7 @@ int getoptions(int argc, char *argv[], struct powerdebug_options *options) if (dump && !(options->regulators || options->clocks || options->sensors)) { /* By Default lets show everything we have */ - options->regulators = options->clocks = options->sensors = 1; + options->regulators = options->clocks = options->sensors = true; }
if (options->findparent && (!options->clocks || !dump)) { @@ -162,8 +163,8 @@ int getoptions(int argc, char *argv[], struct powerdebug_options *options) return 0; }
-int keystroke_callback(int *enter_hit, int *findparent_ncurses, - char *clkname_str, int *refreshwin, +int keystroke_callback(bool *enter_hit, bool *findparent_ncurses, + char *clkname_str, bool *refreshwin, struct powerdebug_options *options) { char keychar; @@ -191,11 +192,11 @@ int keystroke_callback(int *enter_hit, int *findparent_ncurses, if (keystroke == KEY_UP && highlighted_row > 0) highlighted_row--; if (keystroke == 47) - *findparent_ncurses = 1; + *findparent_ncurses = true;
if ((keystroke == 27 || oldselectedwin != selectedwindow) && *findparent_ncurses) { - *findparent_ncurses = 0; + *findparent_ncurses = false; clkname_str[0] = '\0'; }
@@ -230,23 +231,24 @@ int keystroke_callback(int *enter_hit, int *findparent_ncurses, #endif
if (keystroke == 13) - *enter_hit = 1; + *enter_hit = true;
if (keychar == 'Q' && !*findparent_ncurses) return 1; if (keychar == 'R') { - *refreshwin = 1; + *refreshwin = true; options->ticktime = 3; } else - *refreshwin = 0; + *refreshwin = false;
return 0; }
int mainloop(struct powerdebug_options *options) { - int findparent_ncurses = 0, refreshwin = 0; - int enter_hit = 0; + bool findparent_ncurses = false; + bool refreshwin = false; + bool enter_hit = false; int firsttime[TOTAL_FEATURE_WINS]; int i; char clkname_str[64]; @@ -300,7 +302,7 @@ int mainloop(struct powerdebug_options *options) highlighted_row, command); highlighted_row = hrow; - enter_hit = 0; + enter_hit = false; } else find_parents_for_clock(clkname_str, enter_hit); diff --git a/powerdebug.h b/powerdebug.h index 8401a84..4a7c9b0 100644 --- a/powerdebug.h +++ b/powerdebug.h @@ -34,7 +34,7 @@ extern char *win_names[TOTAL_FEATURE_WINS]; extern int selectedwindow;
extern int numregulators; -extern int dump; +extern bool dump; extern double ticktime;
extern void version(void); diff --git a/regulator.h b/regulator.h index 4276933..3ecf6b8 100644 --- a/regulator.h +++ b/regulator.h @@ -41,4 +41,3 @@ struct regulator_info { } *regulators_info;
extern int numregulators; -extern int dump;
Signed-off-by: Daniel Lezcano daniel.lezcano@free.fr --- powerdebug.h | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-)
diff --git a/powerdebug.h b/powerdebug.h index 4a7c9b0..402145b 100644 --- a/powerdebug.h +++ b/powerdebug.h @@ -35,9 +35,6 @@ extern int selectedwindow;
extern int numregulators; extern bool dump; -extern double ticktime; - -extern void version(void);
extern int init_regulator_ds(void); extern void print_regulator_info(int verbose);
Signed-off-by: Daniel Lezcano daniel.lezcano@free.fr --- display.c | 5 +++++ powerdebug.c | 6 ------ powerdebug.h | 1 - 3 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/display.c b/display.c index d3ec421..43db4a4 100644 --- a/display.c +++ b/display.c @@ -30,6 +30,11 @@ static WINDOW *footer_win; int maxx, maxy; char footer_items[NUM_FOOTER_ITEMS][64];
+static char *win_names[TOTAL_FEATURE_WINS] = { + "Clocks", + "Regulators", + "Sensors" +};
void fini_curses(void) { endwin(); diff --git a/powerdebug.c b/powerdebug.c index f5d95d3..ecbbd9d 100644 --- a/powerdebug.c +++ b/powerdebug.c @@ -21,12 +21,6 @@ bool dump = false; int highlighted_row; int selectedwindow = -1;
-char *win_names[TOTAL_FEATURE_WINS] = { - "Clocks", - "Regulators", - "Sensors" -}; - void usage(void) { printf("Usage: powerdebug [OPTIONS]\n"); diff --git a/powerdebug.h b/powerdebug.h index 402145b..e87932e 100644 --- a/powerdebug.h +++ b/powerdebug.h @@ -30,7 +30,6 @@ enum {CLOCK_SELECTED = 1, REFRESH_WINDOW};
extern struct regulator_info *regulators_info;
-extern char *win_names[TOTAL_FEATURE_WINS]; extern int selectedwindow;
extern int numregulators;
Signed-off-by: Daniel Lezcano daniel.lezcano@free.fr --- clocks.c | 142 +++++++++++++++++++++++++++++----------------------------- clocks.h | 1 - powerdebug.c | 8 ++-- powerdebug.h | 7 +-- 4 files changed, 78 insertions(+), 80 deletions(-)
diff --git a/clocks.c b/clocks.c index 9a76c19..ac9aaf5 100644 --- a/clocks.c +++ b/clocks.c @@ -20,7 +20,7 @@ static char clk_dir_path[PATH_MAX]; static char clk_name[NAME_MAX]; static int bold[MAX_LINES];
-int init_clock_details(void) +int init_clock_details(bool dump) { char *path = debugfs_locate_mpoint(); struct stat buf; @@ -80,7 +80,73 @@ int get_int_from(char *file) return atoi(result); }
-void find_parents_for_clock(char *clkname, int complete) +static void dump_parent(struct clock_info *clk, int line, bool dump) +{ + char *unit = "Hz"; + double drate; + static char spaces[64]; + char str[256]; + static int maxline; + + if (maxline < line) + maxline = line; + + if (clk && clk->parent) + dump_parent(clk->parent, ++line, dump); + + drate = (double)clk->rate; + if (drate > 1000 && drate < 1000000) { + unit = "KHz"; + drate /= 1000; + } + if (drate > 1000000) { + unit = "MHz"; + drate /= 1000000; + } + if (clk == clocks_info) { + line++; + strcpy(spaces, ""); + sprintf(str, "%s%s (flags:%d,usecount:%d,rate:%5.2f %s)\n", + spaces, clk->name, clk->flags, clk->usecount, drate, + unit); + } else { + if (!(clk->parent == clocks_info)) + strcat(spaces, " "); + sprintf(str, "%s`- %s (flags:%d,usecount:%d,rate:%5.2f %s)\n", + spaces, clk->name, clk->flags, clk->usecount, drate, + unit); + } + if (dump) + //printf("line=%d:m%d:l%d %s", maxline - line + 2, maxline, line, str); + printf("%s", str); + else + print_one_clock(maxline - line + 2, str, 1, 0); +} + +static void dump_all_parents(char *clkarg, bool dump) +{ + struct clock_info *clk; + char spaces[1024]; + + strcpy(spaces, ""); + + clk = find_clock(clocks_info, clkarg); + + if (!clk) + printf("Clock NOT found!\n"); + else { + /* while(clk && clk != clocks_info) { */ + /* printf("%s\n", clk->name); */ + /* strcat(spaces, " "); */ + /* clk = clk->parent; */ + /* printf("%s <-- ", spaces); */ + /* } */ + /* printf(" /\n"); */ + dump_parent(clk, 1, dump); + } +} + +void find_parents_for_clock(char *clkname, int complete, bool dump) { char name[256];
@@ -95,7 +161,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); + dump_all_parents(clkname, dump); }
int read_and_print_clock_info(int verbose, int hrow, int selected) @@ -261,11 +327,11 @@ void destroy_clocks_info_recur(struct clock_info *clock) } }
-void read_and_dump_clock_info_one(char *clk) +void read_and_dump_clock_info_one(char *clk, bool dump) { printf("\nParents for "%s" Clock :\n\n", clk); read_clock_info(clk_dir_path); - dump_all_parents(clk); + dump_all_parents(clk, dump); printf("\n\n"); }
@@ -395,72 +461,6 @@ void insert_children(struct clock_info **parent, struct clock_info *clk) (*parent)->num_children++; }
-void dump_parent(struct clock_info *clk, int line) -{ - char *unit = "Hz"; - double drate; - static char spaces[64]; - char str[256]; - static int maxline; - - if (maxline < line) - maxline = line; - - if (clk && clk->parent) - dump_parent(clk->parent, ++line); - - drate = (double)clk->rate; - if (drate > 1000 && drate < 1000000) { - unit = "KHz"; - drate /= 1000; - } - if (drate > 1000000) { - unit = "MHz"; - drate /= 1000000; - } - if (clk == clocks_info) { - line++; - strcpy(spaces, ""); - sprintf(str, "%s%s (flags:%d,usecount:%d,rate:%5.2f %s)\n", - spaces, clk->name, clk->flags, clk->usecount, drate, - unit); - } else { - if (!(clk->parent == clocks_info)) - strcat(spaces, " "); - sprintf(str, "%s`- %s (flags:%d,usecount:%d,rate:%5.2f %s)\n", - spaces, clk->name, clk->flags, clk->usecount, drate, - unit); - } - if (dump) - //printf("line=%d:m%d:l%d %s", maxline - line + 2, maxline, line, str); - printf("%s", str); - else - print_one_clock(maxline - line + 2, str, 1, 0); -} - -void dump_all_parents(char *clkarg) -{ - struct clock_info *clk; - char spaces[1024]; - - strcpy(spaces, ""); - - clk = find_clock(clocks_info, clkarg); - - if (!clk) - printf("Clock NOT found!\n"); - else { -// while(clk && clk != clocks_info) { -// printf("%s\n", clk->name); -// strcat(spaces, " "); -// clk = clk->parent; -// printf("%s <-- ", spaces); -// } -// printf(" /\n"); - dump_parent(clk, 1); - } -} - struct clock_info *find_clock(struct clock_info *clk, char *clkarg) { int i; diff --git a/clocks.h b/clocks.h index a240b72..4b176d0 100644 --- a/clocks.h +++ b/clocks.h @@ -51,5 +51,4 @@ void add_clock_details_recur(struct clock_info *clk, int hrow, int selected); void destroy_clocks_info(void); void destroy_clocks_info_recur(struct clock_info *clock); void collapse_all_subclocks(struct clock_info *clock); -void dump_all_parents(char *clkarg); struct clock_info *find_clock(struct clock_info *clk, char *clkarg); diff --git a/powerdebug.c b/powerdebug.c index ecbbd9d..7fa7c82 100644 --- a/powerdebug.c +++ b/powerdebug.c @@ -17,7 +17,7 @@ #include <stdbool.h> #include "powerdebug.h"
-bool dump = false; +static bool dump = false; int highlighted_row; int selectedwindow = -1;
@@ -275,7 +275,7 @@ int mainloop(struct powerdebug_options *options) if (options->clocks || selectedwindow == CLOCK) { int ret = 0; if (firsttime[CLOCK]) { - ret = init_clock_details(); + ret = init_clock_details(dump); if (!ret) firsttime[CLOCK] = 0; strcpy(clkname_str, ""); @@ -299,11 +299,11 @@ int mainloop(struct powerdebug_options *options) enter_hit = false; } else find_parents_for_clock(clkname_str, - enter_hit); + enter_hit, dump); } if (!ret && dump) { if (options->findparent) - read_and_dump_clock_info_one(options->clkarg); + read_and_dump_clock_info_one(options->clkarg, dump); else read_and_dump_clock_info(options->verbose); } diff --git a/powerdebug.h b/powerdebug.h index e87932e..9fd18a5 100644 --- a/powerdebug.h +++ b/powerdebug.h @@ -33,7 +33,6 @@ extern struct regulator_info *regulators_info; extern int selectedwindow;
extern int numregulators; -extern bool dump;
extern int init_regulator_ds(void); extern void print_regulator_info(int verbose); @@ -41,17 +40,17 @@ extern void read_regulator_info(void); extern void print_regulator_info(int verbose);
extern void read_and_dump_clock_info(int verbose); -extern void read_and_dump_clock_info_one(char *clk); +extern void read_and_dump_clock_info_one(char *clk, bool dump); 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 void find_parents_for_clock(char *clkname, int complete); +extern void find_parents_for_clock(char *clkname, int complete, bool dump); 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 void print_string_val(char *name, char *val); -extern int init_clock_details(void); +extern int init_clock_details(bool dump); extern void print_clock_header(void); extern void print_one_clock(int line, char *str, int bold, int highlight); extern char *debugfs_locate_mpoint(void);
Signed-off-by: Daniel Lezcano daniel.lezcano@free.fr --- powerdebug.c | 29 +++++++++++++++-------------- 1 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/powerdebug.c b/powerdebug.c index 7fa7c82..2de4bd4 100644 --- a/powerdebug.c +++ b/powerdebug.c @@ -17,7 +17,6 @@ #include <stdbool.h> #include "powerdebug.h"
-static bool dump = false; int highlighted_row; int selectedwindow = -1;
@@ -79,6 +78,7 @@ struct powerdebug_options { bool regulators; bool sensors; bool clocks; + bool dump; unsigned int ticktime; char *clkarg; }; @@ -123,7 +123,7 @@ int getoptions(int argc, char *argv[], struct powerdebug_options *options) options->ticktime = atoi(optarg); break; case 'd': - dump = true; + options->dump = true; break; case 'v': options->verbose = true; @@ -139,19 +139,19 @@ int getoptions(int argc, char *argv[], struct powerdebug_options *options) } }
- if (dump && !(options->regulators || + if (options->dump && !(options->regulators || options->clocks || options->sensors)) { /* By Default lets show everything we have */ options->regulators = options->clocks = options->sensors = true; }
- if (options->findparent && (!options->clocks || !dump)) { + if (options->findparent && (!options->clocks || !options->dump)) { fprintf(stderr, "-p option passed without -c and -d." " Exiting...\n"); return -1; }
- if (!dump && selectedwindow == -1) + if (!options->dump && selectedwindow == -1) selectedwindow = CLOCK;
return 0; @@ -255,7 +255,7 @@ int mainloop(struct powerdebug_options *options) struct timeval tval; fd_set readfds;
- if (!dump) { + if (!options->dump) { if (firsttime[0]) init_curses(); create_windows(); @@ -264,7 +264,7 @@ int mainloop(struct powerdebug_options *options)
if (options->regulators || selectedwindow == REGULATOR) { read_regulator_info(); - if (!dump) { + if (!options->dump) { create_selectedwindow(); show_regulator_info(options->verbose); } @@ -275,12 +275,12 @@ int mainloop(struct powerdebug_options *options) if (options->clocks || selectedwindow == CLOCK) { int ret = 0; if (firsttime[CLOCK]) { - ret = init_clock_details(dump); + ret = init_clock_details(options->dump); if (!ret) firsttime[CLOCK] = 0; strcpy(clkname_str, ""); } - if (!ret && !dump) { + if (!ret && !options->dump) { int hrow;
create_selectedwindow(); @@ -299,25 +299,26 @@ int mainloop(struct powerdebug_options *options) enter_hit = false; } else find_parents_for_clock(clkname_str, - enter_hit, dump); + enter_hit, + options->dump); } - if (!ret && dump) { + if (!ret && options->dump) { if (options->findparent) - read_and_dump_clock_info_one(options->clkarg, dump); + read_and_dump_clock_info_one(options->clkarg, options->dump); else read_and_dump_clock_info(options->verbose); } }
if (options->sensors || selectedwindow == SENSOR) { - if (!dump) { + if (!options->dump) { create_selectedwindow(); print_sensor_header(); } else read_and_print_sensor_info(options->verbose); }
- if (dump) + if (options->dump) break;
FD_ZERO(&readfds);
Signed-off-by: Daniel Lezcano daniel.lezcano@free.fr --- clocks.c | 6 +++--- display.c | 6 +++--- powerdebug.c | 50 ++++++++++++++++++++++++++------------------------ powerdebug.h | 10 ++++------ 4 files changed, 36 insertions(+), 36 deletions(-)
diff --git a/clocks.c b/clocks.c index ac9aaf5..4b5b0b7 100644 --- a/clocks.c +++ b/clocks.c @@ -20,7 +20,7 @@ static char clk_dir_path[PATH_MAX]; static char clk_name[NAME_MAX]; static int bold[MAX_LINES];
-int init_clock_details(bool dump) +int init_clock_details(bool dump, int selectedwindow) { char *path = debugfs_locate_mpoint(); struct stat buf; @@ -29,7 +29,7 @@ int init_clock_details(bool dump) strcpy(clk_dir_path, path); else { if (!dump) { - create_selectedwindow(); + create_selectedwindow(selectedwindow); sprintf(clock_lines[0], "Unable to locate debugfs " "mount point. Mount debugfs " "and try again..\n"); @@ -47,7 +47,7 @@ int init_clock_details(bool dump) //strcpy(clk_dir_path, "/debug/clock"); // Hardcoded for testing.. if (stat(clk_dir_path, &buf)) { if (!dump) { - create_selectedwindow(); + create_selectedwindow(selectedwindow); sprintf(clock_lines[0], "Unable to find clock tree" " information at %s.\n", clk_dir_path); print_one_clock(0, clock_lines[0], 1, 0); diff --git a/display.c b/display.c index 43db4a4..8b03444 100644 --- a/display.c +++ b/display.c @@ -89,7 +89,7 @@ void init_curses(void) }
-void create_windows(void) +void create_windows(int selectedwindow) {
getmaxyx(stdscr, maxy, maxx); @@ -114,7 +114,7 @@ void create_windows(void)
}
-void create_selectedwindow(void) +void create_selectedwindow(int selectedwindow) { WINDOW *win;
@@ -140,7 +140,7 @@ void create_selectedwindow(void) refresh(); }
-void show_header(void) +void show_header(int selectedwindow) { int i, j = 0; int curr_pointer = 0; diff --git a/powerdebug.c b/powerdebug.c index 2de4bd4..9aed1bb 100644 --- a/powerdebug.c +++ b/powerdebug.c @@ -18,7 +18,6 @@ #include "powerdebug.h"
int highlighted_row; -int selectedwindow = -1;
void usage(void) { @@ -80,6 +79,7 @@ struct powerdebug_options { bool clocks; bool dump; unsigned int ticktime; + int selectedwindow; char *clkarg; };
@@ -89,6 +89,7 @@ int getoptions(int argc, char *argv[], struct powerdebug_options *options)
memset(options, 0, sizeof(*options)); options->ticktime = 10; + options->selectedwindow = -1;
while (1) { int optindex = 0; @@ -101,15 +102,15 @@ int getoptions(int argc, char *argv[], struct powerdebug_options *options) switch (c) { case 'r': options->regulators = true; - selectedwindow = REGULATOR; + options->selectedwindow = REGULATOR; break; case 's': options->sensors = true; - selectedwindow = SENSOR; + options->selectedwindow = SENSOR; break; case 'c': options->clocks = true; - selectedwindow = CLOCK; + options->selectedwindow = CLOCK; break; case 'p': options->findparent = true; @@ -151,8 +152,8 @@ int getoptions(int argc, char *argv[], struct powerdebug_options *options) return -1; }
- if (!options->dump && selectedwindow == -1) - selectedwindow = CLOCK; + if (!options->dump && options->selectedwindow == -1) + options->selectedwindow = CLOCK;
return 0; } @@ -163,24 +164,24 @@ int keystroke_callback(bool *enter_hit, bool *findparent_ncurses, { char keychar; int keystroke = getch(); - int oldselectedwin = selectedwindow; + int oldselectedwin = options->selectedwindow;
if (keystroke == EOF) exit(0);
if (keystroke == KEY_RIGHT || keystroke == 9) - selectedwindow++; + options->selectedwindow++;
if (keystroke == KEY_LEFT || keystroke == 353) - selectedwindow--; + options->selectedwindow--;
- if (selectedwindow >= TOTAL_FEATURE_WINS) - selectedwindow = 0; + if (options->selectedwindow >= TOTAL_FEATURE_WINS) + options->selectedwindow = 0;
- if (selectedwindow < 0) - selectedwindow = TOTAL_FEATURE_WINS - 1; + if (options->selectedwindow < 0) + options->selectedwindow = TOTAL_FEATURE_WINS - 1;
- if (selectedwindow == CLOCK) { + if (options->selectedwindow == CLOCK) { if (keystroke == KEY_DOWN) highlighted_row++; if (keystroke == KEY_UP && highlighted_row > 0) @@ -189,7 +190,7 @@ int keystroke_callback(bool *enter_hit, bool *findparent_ncurses, *findparent_ncurses = true;
if ((keystroke == 27 || oldselectedwin != - selectedwindow) && *findparent_ncurses) { + options->selectedwindow) && *findparent_ncurses) { *findparent_ncurses = false; clkname_str[0] = '\0'; } @@ -258,24 +259,25 @@ int mainloop(struct powerdebug_options *options) if (!options->dump) { if (firsttime[0]) init_curses(); - create_windows(); - show_header(); + create_windows(options->selectedwindow); + show_header(options->selectedwindow); }
- if (options->regulators || selectedwindow == REGULATOR) { + if (options->regulators || options->selectedwindow == REGULATOR) { read_regulator_info(); if (!options->dump) { - create_selectedwindow(); + create_selectedwindow(options->selectedwindow); show_regulator_info(options->verbose); } else print_regulator_info(options->verbose); }
- if (options->clocks || selectedwindow == CLOCK) { + if (options->clocks || options->selectedwindow == CLOCK) { int ret = 0; if (firsttime[CLOCK]) { - ret = init_clock_details(options->dump); + ret = init_clock_details(options->dump, + options->selectedwindow); if (!ret) firsttime[CLOCK] = 0; strcpy(clkname_str, ""); @@ -283,7 +285,7 @@ int mainloop(struct powerdebug_options *options) if (!ret && !options->dump) { int hrow;
- create_selectedwindow(); + create_selectedwindow(options->selectedwindow); if (!findparent_ncurses) { int command = 0;
@@ -310,9 +312,9 @@ int mainloop(struct powerdebug_options *options) } }
- if (options->sensors || selectedwindow == SENSOR) { + if (options->sensors || options->selectedwindow == SENSOR) { if (!options->dump) { - create_selectedwindow(); + create_selectedwindow(options->selectedwindow); print_sensor_header(); } else read_and_print_sensor_info(options->verbose); diff --git a/powerdebug.h b/powerdebug.h index 9fd18a5..cef5570 100644 --- a/powerdebug.h +++ b/powerdebug.h @@ -30,8 +30,6 @@ enum {CLOCK_SELECTED = 1, REFRESH_WINDOW};
extern struct regulator_info *regulators_info;
-extern int selectedwindow; - extern int numregulators;
extern int init_regulator_ds(void); @@ -50,7 +48,7 @@ extern void find_parents_for_clock(char *clkname, int complete, bool dump); 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 void print_string_val(char *name, char *val); -extern int init_clock_details(bool dump); +extern int init_clock_details(bool dump, int selectedwindow); extern void print_clock_header(void); extern void print_one_clock(int line, char *str, int bold, int highlight); extern char *debugfs_locate_mpoint(void); @@ -62,7 +60,7 @@ extern void print_sensor_header(void); extern void init_curses(void); extern void fini_curses(void); extern void killall_windows(int all); -extern void show_header(void); -extern void create_windows(void); -extern void create_selectedwindow(void); +extern void show_header(int selectedwindow); +extern void create_windows(int selectedwindow); +extern void create_selectedwindow(int selectedwindow); extern void show_regulator_info(int verbose);
Remove the Makefile to put in place the next patch where it is generated
Signed-off-by: Daniel Lezcano daniel.lezcano@free.fr --- Makefile | 26 -------------------------- 1 files changed, 0 insertions(+), 26 deletions(-) delete mode 100644 Makefile
diff --git a/Makefile b/Makefile deleted file mode 100644 index 0ac486d..0000000 --- a/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -BINDIR=/usr/sbin -MANDIR=/usr/share/man/man8 - -WARNFLAGS=-Wall -Wshadow -W -Wformat -Wimplicit-function-declaration -Wimplicit-int -CFLAGS?=-O1 -g ${WARNFLAGS} -CC?=gcc - -OBJS = powerdebug.o sensor.o clocks.o regulator.o display.o - -default: powerdebug - -powerdebug.8.gz: powerdebug.8 - gzip -c $< > $@ - -powerdebug: $(OBJS) powerdebug.h - $(CC) ${CFLAGS} $(OBJS) -lncurses -o powerdebug - -install: powerdebug powerdebug.8.gz - install -d ${DESTDIR}${BINDIR} ${DESTDIR}${MANDIR} - install -m 0755 powerdebug ${DESTDIR}${BINDIR} - install -m 0644 powerdebug.8.gz ${DESTDIR}${MANDIR} - -all: powerdebug powerdebug.8.gz - -clean: - rm -f powerdebug *.o powerdebug.8.gz
Signed-off-by: Daniel Lezcano daniel.lezcano@free.fr --- AUTHORS | 1 + ChangeLog | 1 + Makefile.am | 13 +++++++++++++ NEWS | 1 + autogen.sh | 10 ++++++++++ configure.ac | 26 ++++++++++++++++++++++++++ 6 files changed, 52 insertions(+), 0 deletions(-) create mode 100644 AUTHORS create mode 100644 ChangeLog create mode 100644 Makefile.am create mode 100644 NEWS create mode 100644 autogen.sh create mode 100644 configure.ac
diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..62deb04 --- /dev/null +++ b/AUTHORS @@ -0,0 +1 @@ +AUTHORS diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..56631ab --- /dev/null +++ b/ChangeLog @@ -0,0 +1 @@ +ChangeLog diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..55ed40d --- /dev/null +++ b/Makefile.am @@ -0,0 +1,13 @@ +pkginclude_HEADERS = + +bin_PROGRAMS = powerdebug + +LDADD = -lncurses +AM_LDFLAGS=-static + +powerdebug_SOURCES = \ + powerdebug.c \ + clocks.c \ + display.c \ + regulator.c \ + sensor.c diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..edc0071 --- /dev/null +++ b/NEWS @@ -0,0 +1 @@ +NEWS diff --git a/autogen.sh b/autogen.sh new file mode 100644 index 0000000..4657675 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +set -x + +test -d autom4te.cache && rm -rf autom4te.cache +test -d config || mkdir config +aclocal -I config || exit 1 +autoheader || exit 1 +autoconf || exit 1 +automake --add-missing --copy || exit diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..0be8887 --- /dev/null +++ b/configure.ac @@ -0,0 +1,26 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_INIT([powerdebug], [1.0.0]) + +AC_CONFIG_SRCDIR([configure.ac]) +AC_CONFIG_AUX_DIR([config]) +AM_CONFIG_HEADER([config.h]) +AM_INIT_AUTOMAKE([]) +AC_CANONICAL_HOST +AM_PROG_CC_C_O +AC_GNU_SOURCE + +AC_CHECK_HEADERS([ncurses.h], [], AC_MSG_ERROR([please install libncurses-dev.]), +[#include <ncurses.h>]) +AC_PROG_GCC_TRADITIONAL + +if test "x$GCC" = "xyes"; then + CFLAGS="$CFLAGS -Wall" +fi + +AC_CONFIG_FILES([ + Makefile +]) +AC_CONFIG_COMMANDS([default],[[]],[[]]) +AC_OUTPUT
On Wednesday 23 March 2011, Daniel Lezcano wrote:
AUTHORS | 1 + ChangeLog | 1 + Makefile.am | 13 +++++++++++++ NEWS | 1 + autogen.sh | 10 ++++++++++ configure.ac | 26 ++++++++++++++++++++++++++
Why would you do this? The changelog is completely empty, and this seems to be far more complex than the nice and clean Makefile it replaces, and it adds dependencies on a number of new tools.
Arnd
On 03/23/2011 02:44 PM, Arnd Bergmann wrote:
On Wednesday 23 March 2011, Daniel Lezcano wrote:
AUTHORS | 1 + ChangeLog | 1 + Makefile.am | 13 +++++++++++++ NEWS | 1 + autogen.sh | 10 ++++++++++ configure.ac | 26 ++++++++++++++++++++++++++
Why would you do this? The changelog is completely empty, and this seems to be far more complex than the nice and clean Makefile it replaces, and it adds dependencies on a number of new tools.
Hi Arnd,
The ChangeLog is there because the file is checked by the autconf tools. It is empty right now but I guess we can fill it later. The same for NEW and AUTHORS.
You are right about adding dependencies on a new tools, but as far as I know the projects usually use the configure tools, so in case of development they should be present on the system. The advantage of using these tools is we can easily cross compile with the --host option and we can check the presence of the needed packages like libncurses-dev.
About the nice Makefile, we have the Makefile.am which is easy and nice enough. We don't have to check the dependencies as it is automatically generated by automake.
On Wednesday 23 March 2011, Daniel Lezcano wrote:
On 03/23/2011 02:44 PM, Arnd Bergmann wrote:
On Wednesday 23 March 2011, Daniel Lezcano wrote:
AUTHORS | 1 + ChangeLog | 1 + Makefile.am | 13 +++++++++++++ NEWS | 1 + autogen.sh | 10 ++++++++++ configure.ac | 26 ++++++++++++++++++++++++++
Why would you do this? The changelog is completely empty, and this seems to be far more complex than the nice and clean Makefile it replaces, and it adds dependencies on a number of new tools.
Hi Arnd,
The ChangeLog is there because the file is checked by the autconf tools. It is empty right now but I guess we can fill it later. The same for NEW and AUTHORS.
I was referring to the patch changelog at the start of your email, not the file this adds.
You are right about adding dependencies on a new tools, but as far as I know the projects usually use the configure tools, so in case of development they should be present on the system. The advantage of using these tools is we can easily cross compile with the --host option and we can check the presence of the needed packages like libncurses-dev.
About the nice Makefile, we have the Makefile.am which is easy and nice enough. We don't have to check the dependencies as it is automatically generated by automake.
My experience with automake is that it usually makes cross-compiling harder, not easier, and more people are familiar with Makefile syntax than with Makefile.am syntax, so it's harder to debug if something goes wrong.
With the dependencies, you now add to the existing dependency on a single package (ncurses) with multiple dependencies that typically need to be there in a specific version, all for the purpose of telling the user whether the first dependency is installed or not...
Arnd
On 03/23/2011 03:55 PM, Arnd Bergmann wrote:
On Wednesday 23 March 2011, Daniel Lezcano wrote:
On 03/23/2011 02:44 PM, Arnd Bergmann wrote:
On Wednesday 23 March 2011, Daniel Lezcano wrote:
AUTHORS | 1 + ChangeLog | 1 + Makefile.am | 13 +++++++++++++ NEWS | 1 + autogen.sh | 10 ++++++++++ configure.ac | 26 ++++++++++++++++++++++++++
Why would you do this? The changelog is completely empty, and this seems to be far more complex than the nice and clean Makefile it replaces, and it adds dependencies on a number of new tools.
Hi Arnd,
The ChangeLog is there because the file is checked by the autconf tools. It is empty right now but I guess we can fill it later. The same for NEW and AUTHORS.
I was referring to the patch changelog at the start of your email, not the file this adds.
You are right about adding dependencies on a new tools, but as far as I know the projects usually use the configure tools, so in case of development they should be present on the system. The advantage of using these tools is we can easily cross compile with the --host option and we can check the presence of the needed packages like libncurses-dev.
About the nice Makefile, we have the Makefile.am which is easy and nice enough. We don't have to check the dependencies as it is automatically generated by automake.
My experience with automake is that it usually makes cross-compiling harder, not easier, and more people are familiar with Makefile syntax than with Makefile.am syntax, so it's harder to debug if something goes wrong.
About cross compiling it is with the configure script where you setup the cross compilation:
./configure --host=arm-linux-gnueabi
With the dependencies, you now add to the existing dependency on a single package (ncurses) with multiple dependencies that typically need to be there in a specific version, all for the purpose of telling the user whether the first dependency is installed or not...
Yes, you add dependencies. Is supposed powerdebug to go in a distro ? I mean these tools help for packaging with the "make dist" command. From my pov, that makes sense to rely on how a distro generates the packages.
I use the autotools with my project http://lxc.sourceforge.net since some years now, I don't have to complain. Moreover, it seems, distro maintainers were happy to have the source code packaged with these tools.
But anyway, if adding autoconf/automake for powerdebug is a problem, we can drop the two last patches. Amit ?
Thanks -- Daniel
On Wednesday 23 March 2011, Daniel Lezcano wrote:
My experience with automake is that it usually makes cross-compiling harder, not easier, and more people are familiar with Makefile syntax than with Makefile.am syntax, so it's harder to debug if something goes wrong.
About cross compiling it is with the configure script where you setup the cross compilation:
./configure --host=arm-linux-gnueabi
Just like you can do
make CC=arm-linux-gnueabi-gcc
to cross-build.
With the dependencies, you now add to the existing dependency on a single package (ncurses) with multiple dependencies that typically need to be there in a specific version, all for the purpose of telling the user whether the first dependency is installed or not...
Yes, you add dependencies. Is supposed powerdebug to go in a distro ? I mean these tools help for packaging with the "make dist" command. From my pov, that makes sense to rely on how a distro generates the packages.
I use the autotools with my project http://lxc.sourceforge.net since some years now, I don't have to complain. Moreover, it seems, distro maintainers were happy to have the source code packaged with these tools.
It makes some sense for larger projects with lots of dependencies and optional libraries, especially when the project is maintained by someone who is familiar with the autotools. Well, at least autoconf makes sense there, automake less so, and libtool (which you thankfully did not suggest using) IMHO can only ever cause pain.
But anyway, if adding autoconf/automake for powerdebug is a problem, we can drop the two last patches. Amit ?
Your other patches certainly look good to me, and I'm not going to block your autoconf patches if Amit thinks they are ok.
I'm just suggesting to keep simple things simple.
Arnd
On 11 Mar 23, Arnd Bergmann wrote:
On Wednesday 23 March 2011, Daniel Lezcano wrote:
But anyway, if adding autoconf/automake for powerdebug is a problem, we can drop the two last patches. Amit ?
Your other patches certainly look good to me, and I'm not going to block your autoconf patches if Amit thinks they are ok.
I'm just suggesting to keep simple things simple.
Arnd
Daniel,
I think we'll skip the patches for autoconf for now since I'm not really familiar with it myself.
I'll review your other changes and test them in the meanwhile.
/Amit
On 03/24/2011 11:25 AM, Amit Kucheria wrote:
On 11 Mar 23, Arnd Bergmann wrote:
On Wednesday 23 March 2011, Daniel Lezcano wrote:
But anyway, if adding autoconf/automake for powerdebug is a problem, we can drop the two last patches. Amit ?
Your other patches certainly look good to me, and I'm not going to block your autoconf patches if Amit thinks they are ok.
I'm just suggesting to keep simple things simple.
Arnd
Daniel,
I think we'll skip the patches for autoconf for now since I'm not really familiar with it myself.
I'll review your other changes and test them in the meanwhile.
Ok, thanks. I have another patchset (~20 patches) where I continue to encapsulate and hunt the global variables. I also fixed a segmentation fault when you call powerdebug --dump and the flags format for the clocks.
On 11 Mar 23, Daniel Lezcano wrote:
Create a single structure for powerdebug options.
Signed-off-by: Daniel Lezcano daniel.lezcano@free.fr
powerdebug.c | 173 +++++++++++++++++++++++++++++++++------------------------- 1 files changed, 98 insertions(+), 75 deletions(-)
Hi Daniel,
I've tested and pushed everything except patches 13/14 and 14/14 to the repo. Let's come back to autoconf once I've had more time to study it myself.
Thanks for you contribution.
I'll next push Yong's changes to make powerdebug refresh on inotify (might require some rework).
Cheers, Amit
On 03/24/2011 10:09 PM, Amit Kucheria wrote:
On 11 Mar 23, Daniel Lezcano wrote:
Create a single structure for powerdebug options.
Signed-off-by: Daniel Lezcanodaniel.lezcano@free.fr
powerdebug.c | 173 +++++++++++++++++++++++++++++++++------------------------- 1 files changed, 98 insertions(+), 75 deletions(-)
Hi Daniel,
I've tested and pushed everything except patches 13/14 and 14/14 to the repo. Let's come back to autoconf once I've had more time to study it myself.
Sure, thanks.
Thanks for you contribution.
I'll next push Yong's changes to make powerdebug refresh on inotify (might require some rework).
Argh, I have 36 cleanup/fixes patches to send :/ I am on the way of re-organizing the code in order to make it more modular and more maintainable.
Did Yong already begin the sysfs work ?
Thanks -- Daniel
Hi Daniel,
Yes. I had started the work for several days. Previously, every time when clock info is refreshed, the data structure will be reallocated as if it is the first time of building up clock info. The goal is only allocating memory once, which means less system call made by malloc and also reducing potential memory fragment. I am coding and debuging right now, hoping it comes out soon.
Yong
On Fri, Mar 25, 2011 at 5:19 AM, Daniel Lezcano daniel.lezcano@free.frwrote:
On 03/24/2011 10:09 PM, Amit Kucheria wrote:
On 11 Mar 23, Daniel Lezcano wrote:
Create a single structure for powerdebug options.
Signed-off-by: Daniel Lezcanodaniel.lezcano@free.fr
powerdebug.c | 173 +++++++++++++++++++++++++++++++++------------------------- 1 files changed, 98 insertions(+), 75 deletions(-)
Hi Daniel,
I've tested and pushed everything except patches 13/14 and 14/14 to the repo. Let's come back to autoconf once I've had more time to study it myself.
Sure, thanks.
Thanks for you contribution.
I'll next push Yong's changes to make powerdebug refresh on inotify (might require some rework).
Argh, I have 36 cleanup/fixes patches to send :/ I am on the way of re-organizing the code in order to make it more modular and more maintainable.
Did Yong already begin the sysfs work ?
Thanks -- Daniel
On Fri, Mar 25, 2011 at 4:10 AM, Yong Shen yong.shen@linaro.org wrote:
Hi Daniel, Yes. I had started the work for several days. Previously, every time when clock info is refreshed, the data structure will be reallocated as if it is the first time of building up clock info. The goal is only allocating memory once, which means less system call made by malloc and also reducing potential memory fragment. I am coding and debuging right now, hoping it comes out soon. Yong
So as to avoid the (inevitable) conflicts, may I propose that I first apply Yong's patch sent last week to add inotify support. It is not a very invasive patch.
Yong, for the mem allocation work, perhaps it is best if we wait for Daniel to send his latest series and work on top of that.
Regards, Amit