pass regulators_info parameter to regulator_read_info

The regulator_read_info function does no longer rely on the regulators_info
global variable.

Signed-off-by: Daniel Lezcano <daniel.lezcano@free.fr>
Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
diff --git a/powerdebug.c b/powerdebug.c
index 5f23e0c..a8e98c9 100644
--- a/powerdebug.c
+++ b/powerdebug.c
@@ -261,7 +261,7 @@
 		}
 
 		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 @@
 
 	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 @@
 		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 @@
 	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 @@
 		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 @@
 			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 @@
 			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 @@
 } *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);