aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmit Arora <amit.arora@linaro.org>2010-12-02 15:59:37 +0530
committerAmit Arora <amit.arora@linaro.org>2010-12-02 15:59:37 +0530
commita06a7303746a2a014f8a8b2c8eea7271c924601b (patch)
tree1dcc3723d6e6210683a84e0700e0d71d1f3059f2
parent175527852cbe004893bc6f0cb59f4e9702db85ba (diff)
downloadpowerdebug-a06a7303746a2a014f8a8b2c8eea7271c924601b.tar.gz
Re-read clock tree on "refresh"
-rw-r--r--clocks.c15
-rw-r--r--powerdebug.c30
-rw-r--r--powerdebug.h1
3 files changed, 37 insertions, 9 deletions
diff --git a/clocks.c b/clocks.c
index 81da6c3..b6f1162 100644
--- a/clocks.c
+++ b/clocks.c
@@ -102,16 +102,23 @@ void find_parents_for_clock(char *clkname, int complete)
int read_and_print_clock_info(int verbose, int hrow, int selected)
{
print_one_clock(0, "Reading Clock Tree ...", 1, 1);
- if (!old_clock_line_no)
+
+ if (!old_clock_line_no || selected == REFRESH_WINDOW) {
+ destroy_clocks_info();
read_clock_info(clk_dir_path);
+ }
if (!clocks_info->num_children) {
fprintf(stderr, "powerdebug: No clocks found. Exiting..\n");
exit(1);
}
+ if (selected == CLOCK_SELECTED)
+ selected = 1;
+ else
+ selected = 0;
+
print_clock_info(verbose, hrow, selected);
- //destroy_clocks_info();
hrow = (hrow < old_clock_line_no) ? hrow : old_clock_line_no - 1;
return hrow;
@@ -221,6 +228,9 @@ void destroy_clocks_info(void)
{
int i;
+ if (!clocks_info)
+ return;
+
if (clocks_info->num_children) {
for (i = (clocks_info->num_children - 1); i >= 0 ; i--) {
destroy_clocks_info_recur(clocks_info->children[i]);
@@ -230,6 +240,7 @@ void destroy_clocks_info(void)
}
}
}
+ clocks_info->num_children = 0;
free(clocks_info);
clocks_info = NULL;
}
diff --git a/powerdebug.c b/powerdebug.c
index 5ebb01e..3be47e1 100644
--- a/powerdebug.c
+++ b/powerdebug.c
@@ -54,7 +54,7 @@ int main(int argc, char **argv)
{
int c, i;
int firsttime[TOTAL_FEATURE_WINS];
- int enter_hit = 0, verbose = 0, findparent_ncurses = 0;
+ 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];
@@ -64,8 +64,8 @@ int main(int argc, char **argv)
/*
* Options:
* -r, --regulator : regulator
- * -s, --sensor : sensors
- * -c, --clock : clocks
+ * -s, --sensor : sensors
+ * -c, --clock : clocks
* -p, --findparents : clockname whose parents have to be found
* -t, --time : ticktime
* -d, --dump : dump
@@ -135,11 +135,18 @@ int main(int argc, char **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, "Dump mode (-d) supported only with -c, -r "
+ "or -s ..\n");
+ usage(argv);
+ }
if (findparent && (!clocks || !dump)) {
fprintf(stderr, "-p option passed without -c and -d."
@@ -147,7 +154,7 @@ int main(int argc, char **argv)
usage(argv);
}
- if (!dump)
+ if (!dump && selectedwindow == -1)
selectedwindow = REGULATOR;
init_regulator_ds();
@@ -188,10 +195,16 @@ int main(int argc, char **argv)
create_selectedwindow();
if (!findparent_ncurses) {
+ int command = 0;
+
+ if (enter_hit)
+ command = CLOCK_SELECTED;
+ if (refreshwin)
+ command = REFRESH_WINDOW;
hrow = read_and_print_clock_info(
verbose,
highlighted_row,
- enter_hit);
+ command);
highlighted_row = hrow;
enter_hit = 0;
} else
@@ -293,8 +306,11 @@ int main(int argc, char **argv)
if (keychar == 'Q' && !findparent_ncurses)
exit(0);
- if (keychar == 'R')
+ if (keychar == 'R') {
+ refreshwin = 1;
ticktime = 3;
+ } else
+ refreshwin = 0;
}
}
exit(0);
diff --git a/powerdebug.h b/powerdebug.h
index e2f7d65..bbd90fd 100644
--- a/powerdebug.h
+++ b/powerdebug.h
@@ -27,6 +27,7 @@
#define TOTAL_FEATURE_WINS 3 /* Regulator, Clock and Sensor (for now) */
enum {REGULATOR, CLOCK, SENSOR};
+enum {CLOCK_SELECTED = 1, REFRESH_WINDOW};
extern struct regulator_info *regulators_info;