@@ -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;
@@ -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,
};
Fix this bug, and read regulator and sensor datas again when "R" key pressed. Signed-off-by: Shaojie Sun <shaojie.sun@linaro.com> --- regulator.c | 43 ++++++++++++++++++++++++++++--------------- sensor.c | 17 +++++++++++++++-- 2 files changed, 43 insertions(+), 17 deletions(-)