The regulator_read_info function does no longer rely on the regulators_info global variable.
Signed-off-by: Daniel Lezcano <daniel.lezc...@free.fr> --- powerdebug.c | 2 +- regulator.c | 13 ++++++------- regulator.h | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/powerdebug.c b/powerdebug.c index 5f23e0c..a8e98c9 100644 --- a/powerdebug.c +++ b/powerdebug.c @@ -261,7 +261,7 @@ int mainloop(struct powerdebug_options *options) } if (options->regulators || options->selectedwindow == REGULATOR) { - regulator_read_info(); + regulator_read_info(regulators_info); if (!options->dump) { create_selectedwindow(options->selectedwindow); show_regulator_info(options->verbose); diff --git a/regulator.c b/regulator.c index fc40f27..0371961 100644 --- a/regulator.c +++ b/regulator.c @@ -107,7 +107,7 @@ void regulator_print_info(struct regulator_info *reg_info, int verbose) if (!numregulators && verbose) { printf("Could not find regulator information!"); - printf(" Looks like /sys/class/regulator is empty.\n\n"); + printf(" Looks like %s is empty.\n\n", SYSFS_REGULATOR); } printf("\n\n"); @@ -148,7 +148,7 @@ static void read_info_from_dirent(struct regulator_info *reg_info, reg_info[idx].num_users = atoi(str); } -int regulator_read_info(void) +int regulator_read_info(struct regulator_info *reg_info) { FILE *file = NULL; DIR *regdir, *dir; @@ -156,7 +156,7 @@ int regulator_read_info(void) char line[1024], filename[1024], *fptr; struct dirent *item, *ritem; - regdir = opendir("/sys/class/regulator"); + regdir = opendir(SYSFS_REGULATOR); if (!regdir) return(1); while ((item = readdir(regdir))) { @@ -166,8 +166,7 @@ int regulator_read_info(void) if (strncmp(item->d_name, "regulator", 9)) continue; - len = sprintf(filename, "/sys/class/regulator/%s", - item->d_name); + len = sprintf(filename, "%s/%s", SYSFS_REGULATOR, item->d_name); dir = opendir(filename); if (!dir) @@ -179,7 +178,7 @@ int regulator_read_info(void) goto exit; } - strcpy(regulators_info[count-1].name, item->d_name); + strcpy(reg_info[count-1].name, item->d_name); while ((ritem = readdir(dir))) { if (strlen(ritem->d_name) < 3) continue; @@ -194,7 +193,7 @@ int regulator_read_info(void) if (!fptr) continue; - read_info_from_dirent(regulators_info, ritem, + read_info_from_dirent(reg_info, ritem, fptr, count - 1); } exit: diff --git a/regulator.h b/regulator.h index a753299..115780e 100644 --- a/regulator.h +++ b/regulator.h @@ -41,5 +41,5 @@ struct regulator_info { } *regulators_info; extern struct regulator_info *regulator_init(int *nr_regulators); -extern int regulator_read_info(void); +extern int regulator_read_info(struct regulator_info *reg_info); extern void regulator_print_info(struct regulator_info *reg_info, int verbose); -- 1.7.1 _______________________________________________ linaro-dev mailing list linaro-dev@lists.linaro.org http://lists.linaro.org/mailman/listinfo/linaro-dev