make 'selectedwindow' variable static
Signed-off-by: Daniel Lezcano <daniel.lezcano@free.fr>
Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
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_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 @@
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 @@
//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 create_windows(void)
+void create_windows(int selectedwindow)
{
getmaxyx(stdscr, maxy, maxx);
@@ -114,7 +114,7 @@
}
-void create_selectedwindow(void)
+void create_selectedwindow(int selectedwindow)
{
WINDOW *win;
@@ -140,7 +140,7 @@
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 26f7767..b92826b 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 @@
bool clocks;
bool dump;
unsigned int ticktime;
+ int selectedwindow;
char *clkarg;
};
@@ -89,6 +89,7 @@
memset(options, 0, sizeof(*options));
options->ticktime = 10;
+ options->selectedwindow = -1;
while (1) {
int optindex = 0;
@@ -101,15 +102,15 @@
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 @@
return -1;
}
- if (!options->dump && selectedwindow == -1)
- selectedwindow = CLOCK;
+ if (!options->dump && options->selectedwindow == -1)
+ options->selectedwindow = CLOCK;
return 0;
}
@@ -163,24 +164,24 @@
{
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 @@
*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 @@
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 @@
if (!ret && !options->dump) {
int hrow;
- create_selectedwindow();
+ create_selectedwindow(options->selectedwindow);
if (!findparent_ncurses) {
int command = 0;
@@ -310,9 +312,9 @@
}
}
- 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 @@
extern struct regulator_info *regulators_info;
-extern int selectedwindow;
-
extern int numregulators;
extern int init_regulator_ds(void);
@@ -50,7 +48,7 @@
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 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);