Initialize tree pointers in the dump only option
The regulator, gpio, sensor and clock tree pointers were
initialized only during the display option and not during the
dump only option. This meant the dump option was not printing
any info previously. This patch fixes it by initilaizing the
tree pointers during the dump only option.
Signed-off-by: Thara Gopinath <thara.gopinath@linaro.org>
diff --git a/clocks.c b/clocks.c
index c115d8e..4b2a11c 100644
--- a/clocks.c
+++ b/clocks.c
@@ -459,8 +459,13 @@
{
int ret;
- if (read_clock_info(clock_tree))
- return -1;
+ if (!clock_tree) {
+ if (clock_info_load())
+ return -1;
+ } else {
+ if (read_clock_info(clock_tree))
+ return -1;
+ }
if (clk) {
printf("\nParents for \"%s\" Clock :\n\n", clk);
diff --git a/gpio.c b/gpio.c
index d7df0e3..9f323eb 100644
--- a/gpio.c
+++ b/gpio.c
@@ -176,17 +176,6 @@
return tree_for_each(gpio_tree, dump_gpio_cb, NULL);
}
-int gpio_dump(void)
-{
- int ret;
-
- printf("\nGpio Tree :\n");
- printf("***********\n");
- ret = dump_gpio_info();
- printf("\n\n");
-
- return ret;
-}
static char *gpio_line(struct tree *t)
{
@@ -325,6 +314,21 @@
return 0;
}
+int gpio_dump(void)
+{
+ int ret;
+
+ if (gpio_load_info())
+ return -1;
+
+ printf("\nGpio Tree :\n");
+ printf("***********\n");
+ ret = dump_gpio_info();
+ printf("\n\n");
+
+ return ret;
+}
+
static int gpio_display(bool refresh)
{
if (gpio_load_info()) {
diff --git a/regulator.c b/regulator.c
index 5fba6f1..b452f2b 100644
--- a/regulator.c
+++ b/regulator.c
@@ -111,14 +111,6 @@
return 0;
}
-int regulator_dump(void)
-{
- printf("\nRegulator Information:\n");
- printf("*********************\n\n");
-
- return tree_for_each(reg_tree, regulator_dump_cb, NULL);
-}
-
static int regulator_display_cb(struct tree *t, void *data)
{
struct regulator_info *reg = t->private;
@@ -261,6 +253,24 @@
return 0;
}
+int regulator_dump(void)
+{
+
+ if (!reg_tree) {
+ reg_tree = tree_load(SYSFS_REGULATOR, regulator_filter_cb,
+ false);
+ if (!reg_tree) {
+ printf("Failed to load regulator tree\n");
+ return -1;
+ }
+ }
+
+ printf("\nRegulator Information:\n");
+ printf("*********************\n\n");
+
+ return tree_for_each(reg_tree, regulator_dump_cb, NULL);
+}
+
static int regulator_display(bool refresh)
{
if (regulator_info_load()) {
diff --git a/sensor.c b/sensor.c
index cdc86b2..e054a7b 100644
--- a/sensor.c
+++ b/sensor.c
@@ -77,14 +77,6 @@
return 0;
}
-int sensor_dump(void)
-{
- printf("\nSensor Information:\n");
- printf("*******************\n\n");
-
- return tree_for_each(sensor_tree, sensor_dump_cb, NULL);
-}
-
static struct sensor_info *sensor_alloc(void)
{
struct sensor_info *sensor;
@@ -291,6 +283,17 @@
return 0;
}
+int sensor_dump(void)
+{
+ if (sensor_load_info())
+ return -1;
+
+ printf("\nSensor Information:\n");
+ printf("*******************\n\n");
+
+ return tree_for_each(sensor_tree, sensor_dump_cb, NULL);
+}
+
static int sensor_display(bool refresh)
{
if (sensor_load_info()) {