aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Lezcano <daniel.lezcano@free.fr>2011-03-26 22:06:19 +0100
committerAmit Kucheria <amit.kucheria@linaro.org>2011-04-04 03:19:05 +0300
commitf0e0665c69f430b0c42e5dc6b8a6b7e5957da030 (patch)
tree094f1d8e3cbb88a984767623f799352f0def40de
parent934fc09f9c04fca837f15bd9e58219919942ab7c (diff)
simplify clock_init function
Signed-off-by: Daniel Lezcano <daniel.lezcano@free.fr> Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
-rw-r--r--clocks.c39
-rw-r--r--clocks.h2
-rw-r--r--powerdebug.c12
-rw-r--r--powerdebug.h1
4 files changed, 12 insertions, 42 deletions
diff --git a/clocks.c b/clocks.c
index 9577267..c83055f 100644
--- a/clocks.c
+++ b/clocks.c
@@ -47,45 +47,14 @@ static int locate_debugfs(char *clk_path)
return ret;
}
-int init_clock_details(bool dump, int selectedwindow)
+int clock_init(void)
{
- struct stat buf;
-
- if (locate_debugfs(clk_dir_path)) {
- if (!dump) {
- create_selectedwindow(selectedwindow);
- sprintf(clock_lines[0], "Unable to locate debugfs "
- "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");
- return -1;
- }
- }
+ if (locate_debugfs(clk_dir_path))
+ return -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)) {
- if (!dump) {
- 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);
- old_clock_line_no = 1;
- return(1);
- } else {
- fprintf(stderr, "powerdebug: Unable to find clock tree"
- " information at %s.\n", clk_dir_path);
- return -1;
- }
- }
- return 0;
+ return access(clk_dir_path, F_OK);
}
static int file_read_from_format(char *file, int *value, const char *format)
diff --git a/clocks.h b/clocks.h
index dd9216a..cc17e86 100644
--- a/clocks.h
+++ b/clocks.h
@@ -40,6 +40,8 @@ char clock_lines[MAX_LINES][128];
int clock_line_no;
int old_clock_line_no;
+extern int clock_init(void);
+
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);
diff --git a/powerdebug.c b/powerdebug.c
index f67312c..9874f5a 100644
--- a/powerdebug.c
+++ b/powerdebug.c
@@ -17,6 +17,7 @@
#include <stdbool.h>
#include "regulator.h"
#include "display.h"
+#include "clocks.h"
#include "powerdebug.h"
static int highlighted_row;
@@ -315,7 +316,6 @@ static int powerdebug_dump(struct powerdebug_options *options,
}
if (options->clocks) {
- init_clock_details(options->dump, options->selectedwindow);
if (options->clkname)
read_and_dump_clock_info_one(options->clkname,
@@ -366,6 +366,11 @@ int main(int argc, char **argv)
return 1;
}
+ if (clock_init()) {
+ printf("failed to initialize clock details (check debugfs)\n");
+ options->clocks = false;
+ }
+
/* we just dump the informations */
if (options->dump) {
if (powerdebug_dump(options, regulators_info, numregulators))
@@ -378,11 +383,6 @@ int main(int argc, char **argv)
return 1;
}
- if (init_clock_details(options->dump, options->selectedwindow)) {
- printf("failed initialize clock details\n");
- options->clocks = false;
- }
-
if (mainloop(options, regulators_info, numregulators))
return 1;
diff --git a/powerdebug.h b/powerdebug.h
index d8a40a9..a122b7f 100644
--- a/powerdebug.h
+++ b/powerdebug.h
@@ -39,7 +39,6 @@ extern void find_parents_for_clock(char *clkname, int complete);
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, int selectedwindow);
extern void print_clock_header(void);
extern void print_one_clock(int line, char *str, int bold, int highlight);