aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Lezcano <daniel.lezcano@linaro.org>2011-06-21 00:57:08 +0200
committerDaniel Lezcano <daniel.lezcano@linaro.org>2011-06-21 00:57:08 +0200
commitd577aaaffc5398ae59558e888071e8214c6cd852 (patch)
tree50640984286b92b2f359f7e665d68aabd6468aca
parent73b400238f53a18c4d35b7ba9a7de7dd26755035 (diff)
downloadpowerdebugV2-d577aaaffc5398ae59558e888071e8214c6cd852.tar.gz
Optimize the code
With this patch the content of the debugfs file is readen only when the 'refresh' button is hit and at the init of powerdebug. Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
-rw-r--r--clocks.c13
-rw-r--r--display.c13
-rw-r--r--display.h3
-rw-r--r--regulator.c2
-rw-r--r--sensor.c2
5 files changed, 16 insertions, 17 deletions
diff --git a/clocks.c b/clocks.c
index 6943b70..0bd0a0e 100644
--- a/clocks.c
+++ b/clocks.c
@@ -262,6 +262,10 @@ static int _clock_print_info_cb(struct tree *t, void *data)
static int clock_print_info_cb(struct tree *t, void *data)
{
+ /* we skip the root node of the tree */
+ if (!t->parent)
+ return 0;
+
/* show the clock when *all* its parent is expanded */
if (tree_for_each_parent(t->parent, is_collapsed, NULL))
return 0;
@@ -315,9 +319,9 @@ static int clock_select(void)
* found in the files. Then print the result to the text based interface
* Return 0 on success, < 0 otherwise
*/
-static int clock_display(void)
+static int clock_display(bool refresh)
{
- if (read_clock_info(clock_tree))
+ if (refresh && read_clock_info(clock_tree))
return -1;
return clock_print_info(clock_tree);
@@ -334,13 +338,10 @@ static int clock_find(const char *name)
for (i = 0; i < nr; i++) {
- ret = read_clock_info(ptree[i]);
- if (ret)
- break;
-
ret = _clock_print_info_cb(ptree[i], &line);
if (ret)
break;
+
}
display_refresh_pad(CLOCK);
diff --git a/display.c b/display.c
index 38596b0..23a4172 100644
--- a/display.c
+++ b/display.c
@@ -111,14 +111,14 @@ static int display_show_footer(int win, char *string)
return 0;
}
-int display_refresh(int win)
+static int display_refresh(int win, bool read)
{
/* we are trying to refresh a window which is not showed */
if (win != current_win)
return 0;
if (windata[win].ops && windata[win].ops->display)
- return windata[win].ops->display();
+ return windata[win].ops->display(read);
return 0;
}
@@ -391,13 +391,12 @@ static int display_keystroke(int fd, void *data)
case 'r':
case 'R':
- /* refresh will be done after */
- break;
+ return display_refresh(current_win, true);
default:
return 0;
}
- display_refresh(current_win);
+ display_refresh(current_win, false);
return 0;
}
@@ -416,7 +415,7 @@ static int display_switch_to_main(int fd)
if (display_show_footer(current_win, NULL))
return -1;
- return display_refresh(current_win);
+ return display_refresh(current_win, false);
}
static int display_find_keystroke(int fd, void *data)
@@ -547,7 +546,7 @@ int display_init(int wdefault)
if (display_show_footer(wdefault, NULL))
return -1;
- return display_refresh(wdefault);
+ return display_refresh(wdefault, true);
}
int display_column_name(const char *line)
diff --git a/display.h b/display.h
index 7fa5361..9e4e21a 100644
--- a/display.h
+++ b/display.h
@@ -16,7 +16,7 @@
enum { CLOCK, REGULATOR, SENSOR };
struct display_ops {
- int (*display)(void);
+ int (*display)(bool refresh);
int (*select)(void);
int (*find)(const char *);
int (*selectf)(void);
@@ -31,5 +31,4 @@ extern void *display_get_row_data(int window);
extern int display_init(int wdefault);
extern int display_register(int win, struct display_ops *ops);
-extern int display_refresh(int win);
extern int display_column_name(const char *line);
diff --git a/regulator.c b/regulator.c
index 97ab15b..849f906 100644
--- a/regulator.c
+++ b/regulator.c
@@ -156,7 +156,7 @@ static int regulator_print_header(void)
}
-static int regulator_display(void)
+static int regulator_display(bool refresh)
{
int ret, line = 0;
diff --git a/sensor.c b/sensor.c
index 2a8f4bb..d63510e 100644
--- a/sensor.c
+++ b/sensor.c
@@ -250,7 +250,7 @@ static int sensor_print_header(void)
return ret;
}
-static int sensor_display(void)
+static int sensor_display(bool refresh)
{
int ret, line = 0;