@@ -26,6 +26,7 @@
#include <sys/stat.h>
#include "powerdebug.h"
+#include "display.h"
#include "clocks.h"
#include "tree.h"
#include "utils.h"
@@ -306,28 +307,6 @@ int clock_toggle_expanded(void)
}
/*
- * Initialize the clock framework
- */
-int clock_init(void)
-{
- char clk_dir_path[PATH_MAX];
-
- if (locate_debugfs(clk_dir_path))
- return -1;
-
- sprintf(clk_dir_path, "%s/clock", clk_dir_path);
-
- if (access(clk_dir_path, F_OK))
- return -1;
-
- clock_tree = tree_load(clk_dir_path, NULL);
- if (!clock_tree)
- return -1;
-
- return fill_clock_tree();
-}
-
-/*
* Read the clock information and fill the tree with the information
* found in the files. Then print the result to the text based interface
* Return 0 on success, < 0 otherwise
@@ -366,3 +345,33 @@ int clock_dump(char *clk)
return ret;
}
+
+static struct display_ops clock_ops = {
+ .display = clock_display,
+ .select = clock_toggle_expanded,
+};
+
+/*
+ * Initialize the clock framework
+ */
+int clock_init(void)
+{
+ char clk_dir_path[PATH_MAX];
+
+ if (display_register(CLOCK, &clock_ops))
+ return -1;
+
+ if (locate_debugfs(clk_dir_path))
+ return -1;
+
+ sprintf(clk_dir_path, "%s/clock", clk_dir_path);
+
+ if (access(clk_dir_path, F_OK))
+ return -1;
+
+ clock_tree = tree_load(clk_dir_path, NULL);
+ if (!clock_tree)
+ return -1;
+
+ return fill_clock_tree();
+}
@@ -49,6 +49,7 @@ struct rowdata {
struct windata {
WINDOW *win;
WINDOW *pad;
+ struct display_ops *ops;
struct rowdata *rowdata;
char *name;
int nrdata;
@@ -207,6 +208,16 @@ void print_sensor_header(void)
show_header_footer(SENSOR);
}
+int display_register(int win, struct display_ops *ops)
+{
+ if (win < 0 || win >= TOTAL_FEATURE_WINS)
+ return -1;
+
+ windata[win].ops = ops;
+
+ return 0;
+}
+
int display_next_panel(void)
{
current_win++;
@@ -13,8 +13,13 @@
* - initial API and implementation
*******************************************************************************/
-extern int display_init(int wdefault);
+struct display_ops {
+ int (*display)(void);
+ int (*select)(void);
+};
+extern int display_init(int wdefault);
+extern int display_register(int win, struct display_ops *ops);
extern int display_next_panel(void);
extern int display_prev_panel(void);
extern int display_next_line(void);
@@ -26,6 +26,7 @@
#include <dirent.h>
#include <string.h>
#include <stdlib.h>
+#include "display.h"
#include "powerdebug.h"
#include "tree.h"
#include "utils.h"
@@ -209,8 +210,15 @@ static int fill_regulator_tree(void)
return tree_for_each(reg_tree, fill_regulator_cb, NULL);
}
+static struct display_ops regulator_ops = {
+ .display = regulator_display,
+};
+
int regulator_init(void)
{
+ if (display_register(REGULATOR, ®ulator_ops))
+ return -1;
+
reg_tree = tree_load(SYSFS_REGULATOR, regulator_filter_cb);
if (!reg_tree)
return -1;
@@ -23,6 +23,7 @@
#include <stdlib.h>
#include "powerdebug.h"
+#include "display.h"
#include "sensor.h"
#include "tree.h"
#include "utils.h"
@@ -249,8 +250,15 @@ int sensor_display(void)
return ret;
}
+static struct display_ops sensor_ops = {
+ .display = sensor_display,
+};
+
int sensor_init(void)
{
+ if (display_register(SENSOR, &sensor_ops))
+ return -1;
+
sensor_tree = tree_load(SYSFS_SENSOR, sensor_filter_cb);
if (!sensor_tree)
return -1;
Let's create some ops to be registered by the pm blocks to the display. Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> --- clocks.c | 53 +++++++++++++++++++++++++++++++---------------------- display.c | 11 +++++++++++ display.h | 7 ++++++- regulator.c | 8 ++++++++ sensor.c | 8 ++++++++ 5 files changed, 64 insertions(+), 23 deletions(-)