browse /sys/class/regulator with a generic name

All the files found in the /sys/class/regulator directory should
be regulators. Don't assume their name begin with 'regulator'.

Signed-off-by: Daniel Lezcano <daniel.lezcano@free.fr>
Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
diff --git a/regulator.c b/regulator.c
index 255a56d..342a1a7 100644
--- a/regulator.c
+++ b/regulator.c
@@ -15,20 +15,30 @@
 
 #include "regulator.h"
 
+#define SYSFS_REGULATOR "/sys/class/regulator"
+
 int regulator_init(void)
 {
 	DIR *regdir;
 	struct dirent *item;
 
-	regdir = opendir("/sys/class/regulator");
-	if (!regdir)
-		return(1);
+	regdir = opendir(SYSFS_REGULATOR);
+	if (!regdir) {
+		fprintf(stderr, "failed to open '%s': %m\n", SYSFS_REGULATOR);
+		return -1;
+	}
+
 	while ((item = readdir(regdir))) {
-		if (strncmp(item->d_name, "regulator", 9))
+
+		if (!strcmp(item->d_name, "."))
+			continue;
+
+		if (!strcmp(item->d_name, ".."))
 			continue;
 
 		numregulators++;
 	}
+
 	closedir(regdir);
 
 	regulators_info = (struct regulator_info *)malloc(numregulators*