diff options
author | Daniel Lezcano <daniel.lezcano@free.fr> | 2011-03-26 22:05:55 +0100 |
---|---|---|
committer | Amit Kucheria <amit.kucheria@linaro.org> | 2011-04-04 02:19:08 +0300 |
commit | b846541aa071a3675041a6af570e7afb7c3a05db (patch) | |
tree | 70f6b696348de85d9453759f37ac81c28b771a64 /regulator.c | |
parent | 7d62f9fa388ef867352e5b84113e4449f9032e68 (diff) |
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>
Diffstat (limited to 'regulator.c')
-rw-r--r-- | regulator.c | 13 |
1 files changed, 6 insertions, 7 deletions
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: |