aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShaojie Sun <shaojie.sun@linaro.com>2013-08-20 20:35:15 +0800
committerShaojie Sun <shaojie.sun@linaro.com>2013-08-20 20:49:31 +0800
commitc1462e7ea1644e0bf942b265d0a3d4e7ab678fab (patch)
tree8149b9f23cf2b1468ed1e89af1083adba7a2749e
parent24dcaa26a9903b35a3f6377c67de93f47e1f14ae (diff)
downloadpowerdebug-c1462e7ea1644e0bf942b265d0a3d4e7ab678fab.tar.gz
Pressing "R" to refresh does not update regulator and sensor values
Fix this bug, and read regulator and sensor datas again when "R" key pressed. Signed-off-by: Shaojie Sun <shaojie.sun@linaro.com>
-rw-r--r--regulator.c43
-rw-r--r--sensor.c17
2 files changed, 43 insertions, 17 deletions
diff --git a/regulator.c b/regulator.c
index 68c686f..9cd89fd 100644
--- a/regulator.c
+++ b/regulator.c
@@ -160,21 +160,6 @@ static int regulator_print_header(void)
}
-static int regulator_display(bool refresh)
-{
- int ret, line = 0;
-
- display_reset_cursor(REGULATOR);
-
- regulator_print_header();
-
- ret = tree_for_each(reg_tree, regulator_display_cb, &line);
-
- display_refresh_pad(REGULATOR);
-
- return ret;
-}
-
static int regulator_filter_cb(const char *name)
{
/* let's ignore some directories in order to avoid to be
@@ -213,6 +198,34 @@ static inline int read_regulator_cb(struct tree *t, void *data)
return 0;
}
+static int read_regulator_info(struct tree *tree)
+{
+ return tree_for_each(tree, read_regulator_cb, NULL);
+}
+
+static int regulator_print_info(struct tree *tree)
+{
+ int ret, line = 0;
+
+ display_reset_cursor(REGULATOR);
+
+ regulator_print_header();
+
+ ret = tree_for_each(tree, regulator_display_cb, &line);
+
+ display_refresh_pad(REGULATOR);
+
+ return ret;
+}
+
+static int regulator_display(bool refresh)
+{
+ if (refresh && read_regulator_info(reg_tree))
+ return -1;
+
+ return regulator_print_info(reg_tree);
+}
+
static int fill_regulator_cb(struct tree *t, void *data)
{
struct regulator_info *reg;
diff --git a/sensor.c b/sensor.c
index bd8c354..0645d25 100644
--- a/sensor.c
+++ b/sensor.c
@@ -161,6 +161,11 @@ static int read_sensor_cb(struct tree *tree, void *data)
return 0;
}
+static int read_sensor_info(struct tree *tree)
+{
+ return tree_for_each(tree, read_sensor_cb, NULL);
+}
+
static int fill_sensor_cb(struct tree *t, void *data)
{
struct sensor_info *sensor;
@@ -250,7 +255,7 @@ static int sensor_print_header(void)
return ret;
}
-static int sensor_display(bool refresh)
+static int sensor_print_info(struct tree *tree)
{
int ret, line = 0;
@@ -258,13 +263,21 @@ static int sensor_display(bool refresh)
sensor_print_header();
- ret = tree_for_each(sensor_tree, sensor_display_cb, &line);
+ ret = tree_for_each(tree, sensor_display_cb, &line);
display_refresh_pad(SENSOR);
return ret;
}
+static int sensor_display(bool refresh)
+{
+ if (refresh && read_sensor_info(sensor_tree))
+ return -1;
+
+ return sensor_print_info(sensor_tree);
+}
+
static struct display_ops sensor_ops = {
.display = sensor_display,
};