aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Lezcano <daniel.lezcano@free.fr>2011-03-26 22:06:20 +0100
committerAmit Kucheria <amit.kucheria@linaro.org>2011-04-04 03:22:46 +0300
commitef32319dfd87a7c1cc16d6598b90d8cc54242951 (patch)
treec3ea17f513e8868f3f70425df5e5615aa9a89b76
parentf0e0665c69f430b0c42e5dc6b8a6b7e5957da030 (diff)
Remove pointless function definitions
By moving the functions in the right order in the file, we can get ride of their definitions and we can set them static. Signed-off-by: Daniel Lezcano <daniel.lezcano@free.fr> Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
-rw-r--r--clocks.c195
-rw-r--r--clocks.h18
2 files changed, 101 insertions, 112 deletions
diff --git a/clocks.c b/clocks.c
index c83055f..b556644 100644
--- a/clocks.c
+++ b/clocks.c
@@ -15,12 +15,18 @@
#include <stdio.h>
#include <mntent.h>
+#include <sys/stat.h>
#include "powerdebug.h"
#include "clocks.h"
+#define MAX_LINES 120
+
static char clk_dir_path[PATH_MAX];
static int bold[MAX_LINES];
+static char clock_lines[MAX_LINES][128];
+static int clock_line_no;
+static int old_clock_line_no;
static int locate_debugfs(char *clk_path)
{
@@ -124,6 +130,29 @@ static void dump_parent(struct clock_info *clk, int line, bool dump)
print_one_clock(maxline - line + 2, str, 1, 0);
}
+static struct clock_info *find_clock(struct clock_info *clk, char *clkarg)
+{
+ int i;
+ struct clock_info *ret = clk;
+
+ if (!strcmp(clk->name, clkarg))
+ return ret;
+
+ if (clk->children) {
+ for (i = 0; i < clk->num_children; i++) {
+ if (!strcmp(clk->children[i]->name, clkarg))
+ return clk->children[i];
+ }
+ for (i = 0; i < clk->num_children; i++) {
+ ret = find_clock(clk->children[i], clkarg);
+ if (ret)
+ return ret;
+ }
+ }
+
+ return NULL;
+}
+
static void dump_all_parents(char *clkarg, bool dump)
{
struct clock_info *clk;
@@ -165,6 +194,45 @@ void find_parents_for_clock(char *clkname, int complete)
dump_all_parents(clkname, false);
}
+static void destroy_clocks_info_recur(struct clock_info *clock)
+{
+ int i;
+
+ if (clock && clock->num_children) {
+ for (i = (clock->num_children - 1); i >= 0; i--) {
+ fflush(stdin);
+ destroy_clocks_info_recur(clock->children[i]);
+ if (!i) {
+ free(clock->children);
+ clock->children = NULL;
+ clock->num_children = 0;
+ }
+ }
+ }
+}
+
+static 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]);
+ if (!i) {
+ free(clocks_info->children);
+ clocks_info->children = NULL;
+ }
+ }
+ }
+ clocks_info->num_children = 0;
+ free(clocks_info);
+ clocks_info = NULL;
+}
+
+
int read_and_print_clock_info(int verbose, int hrow, int selected)
{
print_one_clock(0, "Reading Clock Tree ...", 1, 1);
@@ -190,7 +258,7 @@ int read_and_print_clock_info(int verbose, int hrow, int selected)
return hrow;
}
-int calc_delta_screen_size(int hrow)
+static int calc_delta_screen_size(int hrow)
{
if (hrow >= (maxy - 3))
return hrow - (maxy - 4);
@@ -198,36 +266,7 @@ int calc_delta_screen_size(int hrow)
return 0;
}
-void print_clock_info(int verbose, int hrow, int selected)
-{
- int i, count = 0, delta;
-
- (void)verbose;
-
- print_clock_header();
-
- for (i = 0; i < clocks_info->num_children; i++)
- add_clock_details_recur(clocks_info->children[i],
- hrow, selected);
-
- delta = calc_delta_screen_size(hrow);
-
- while (clock_lines[count + delta] &&
- strcmp(clock_lines[count + delta], "")) {
- if (count < delta) {
- count++;
- continue;
- }
- print_one_clock(count - delta, clock_lines[count + delta],
- bold[count + delta], (hrow == (count + delta)));
- count++;
- }
-
- old_clock_line_no = clock_line_no;
- clock_line_no = 0;
-}
-
-void prepare_name_str(char *namestr, struct clock_info *clock)
+static void prepare_name_str(char *namestr, struct clock_info *clock)
{
int i;
@@ -238,7 +277,18 @@ void prepare_name_str(char *namestr, struct clock_info *clock)
strcat(namestr, clock->name);
}
-void add_clock_details_recur(struct clock_info *clock, int hrow, int selected)
+static void collapse_all_subclocks(struct clock_info *clock)
+{
+ int i;
+
+ clock->expanded = 0;
+ if (clock->num_children)
+ for (i = 0; i < clock->num_children; i++)
+ collapse_all_subclocks(clock->children[i]);
+}
+
+static void add_clock_details_recur(struct clock_info *clock,
+ int hrow, int selected)
{
int i;
char *unit = " Hz";
@@ -280,52 +330,33 @@ void add_clock_details_recur(struct clock_info *clock, int hrow, int selected)
strcpy(clock_lines[clock_line_no], "");
}
-void collapse_all_subclocks(struct clock_info *clock)
+void print_clock_info(int verbose, int hrow, int selected)
{
- int i;
-
- clock->expanded = 0;
- if (clock->num_children)
- for (i = 0; i < clock->num_children; i++)
- collapse_all_subclocks(clock->children[i]);
-}
+ int i, count = 0, delta;
-void destroy_clocks_info(void)
-{
- int i;
+ (void)verbose;
- if (!clocks_info)
- return;
+ print_clock_header();
- if (clocks_info->num_children) {
- for (i = (clocks_info->num_children - 1); i >= 0 ; i--) {
- destroy_clocks_info_recur(clocks_info->children[i]);
- if (!i) {
- free(clocks_info->children);
- clocks_info->children = NULL;
- }
- }
- }
- clocks_info->num_children = 0;
- free(clocks_info);
- clocks_info = NULL;
-}
+ for (i = 0; i < clocks_info->num_children; i++)
+ add_clock_details_recur(clocks_info->children[i],
+ hrow, selected);
-void destroy_clocks_info_recur(struct clock_info *clock)
-{
- int i;
+ delta = calc_delta_screen_size(hrow);
- if (clock && clock->num_children) {
- for (i = (clock->num_children - 1); i >= 0; i--) {
- fflush(stdin);
- destroy_clocks_info_recur(clock->children[i]);
- if (!i) {
- free(clock->children);
- clock->children = NULL;
- clock->num_children = 0;
- }
+ while (clock_lines[count + delta] &&
+ strcmp(clock_lines[count + delta], "")) {
+ if (count < delta) {
+ count++;
+ continue;
}
+ print_one_clock(count - delta, clock_lines[count + delta],
+ bold[count + delta], (hrow == (count + delta)));
+ count++;
}
+
+ old_clock_line_no = clock_line_no;
+ clock_line_no = 0;
}
void read_and_dump_clock_info_one(char *clk, bool dump)
@@ -462,30 +493,6 @@ void insert_children(struct clock_info **parent, struct clock_info *clk)
(*parent)->num_children++;
}
-struct clock_info *find_clock(struct clock_info *clk, char *clkarg)
-{
- int i;
- struct clock_info *ret = clk;
-
- if (!strcmp(clk->name, clkarg))
- return ret;
-
- if (clk->children) {
- for (i = 0; i < clk->num_children; i++) {
- if (!strcmp(clk->children[i]->name, clkarg))
- return clk->children[i];
- }
- for (i = 0; i < clk->num_children; i++) {
- ret = find_clock(clk->children[i], clkarg);
- if (ret)
- return ret;
- }
- }
-
- return NULL;
-}
-
-
void dump_clock_info(struct clock_info *clk, int level, int bmp)
{
int i, j;
diff --git a/clocks.h b/clocks.h
index cc17e86..9ad9804 100644
--- a/clocks.h
+++ b/clocks.h
@@ -13,16 +13,8 @@
* - initial API and implementation
*******************************************************************************/
-#include <sys/stat.h>
-#include <sys/vfs.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <linux/magic.h>
-
extern int maxy;
-#define MAX_LINES 120
-
struct clock_info {
char name[NAME_MAX];
int flags;
@@ -36,14 +28,4 @@ struct clock_info {
struct clock_info **children;
} *clocks_info;
-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);
-void collapse_all_subclocks(struct clock_info *clock);
-struct clock_info *find_clock(struct clock_info *clk, char *clkarg);