aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmit Arora <amit.arora@linaro.org>2010-08-05 14:04:50 +0530
committerAmit Arora <amit.arora@linaro.org>2010-08-05 14:04:50 +0530
commit85fd495dc0bd29c9a1272034c9099d943044495e (patch)
tree6813d5dd355f7861f3bcf8b86e87e7fd60dceb31
parent1c03789d37dd14e582ba57b003ddda282446a86c (diff)
Some cleanups
-rw-r--r--output.c24
-rw-r--r--powerdebug.c26
-rw-r--r--powerdebug.h3
3 files changed, 25 insertions, 28 deletions
diff --git a/output.c b/output.c
index 6d4de01..efcbbe4 100644
--- a/output.c
+++ b/output.c
@@ -39,23 +39,31 @@ void print_regulator_info(int verbose)
printf("\topmode=%s\n", regulators_info[i].opmode);
if (regulators_info[i].microvolts)
- printf("\tmicrovolts=%d\n", regulators_info[i].microvolts);
+ printf("\tmicrovolts=%d\n",
+ regulators_info[i].microvolts);
if (regulators_info[i].min_microvolts)
- printf("\tmin_microvolts=%d\n", regulators_info[i].min_microvolts);
+ printf("\tmin_microvolts=%d\n",
+ regulators_info[i].min_microvolts);
if (regulators_info[i].max_microvolts)
- printf("\tmax_microvolts=%d\n", regulators_info[i].max_microvolts);
+ printf("\tmax_microvolts=%d\n",
+ regulators_info[i].max_microvolts);
if (regulators_info[i].microamps)
- printf("\tmicroamps=%d\n", regulators_info[i].microamps);
+ printf("\tmicroamps=%d\n",
+ regulators_info[i].microamps);
if (regulators_info[i].min_microamps)
- printf("\tmin_microamps=%d\n", regulators_info[i].min_microamps);
+ printf("\tmin_microamps=%d\n",
+ regulators_info[i].min_microamps);
if (regulators_info[i].max_microamps)
- printf("\tmax_microamps=%d\n", regulators_info[i].max_microamps);
+ printf("\tmax_microamps=%d\n",
+ regulators_info[i].max_microamps);
if (regulators_info[i].requested_microamps)
- printf("\trequested_microamps=%d\n", regulators_info[i].requested_microamps);
+ printf("\trequested_microamps=%d\n",
+ regulators_info[i].requested_microamps);
if (regulators_info[i].num_users)
- printf("\tnum_users=%d\n", regulators_info[i].num_users);
+ printf("\tnum_users=%d\n",
+ regulators_info[i].num_users);
printf("\n");
}
diff --git a/powerdebug.c b/powerdebug.c
index d5571ef..aad8349 100644
--- a/powerdebug.c
+++ b/powerdebug.c
@@ -24,7 +24,8 @@ int init_regulator_ds(void)
regulators_info = (struct regulator_info *)malloc(numregulators*
sizeof(struct regulator_info));
if (!regulators_info) {
- fprintf(stderr, "init_regulator_ds: Not enough memory to read information for %d regulators!\n",
+ fprintf(stderr, "init_regulator_ds: Not enough memory to ");
+ fprintf(stderr, "read information for %d regulators!\n",
numregulators);
return(1);
}
@@ -133,19 +134,17 @@ int read_regulator_info(int verbose)
if (strncmp(item->d_name, "regulator", 9))
continue;
- len = sprintf(filename, "/sys/class/regulator/%s",item->d_name);
+ len = sprintf(filename, "/sys/class/regulator/%s",
+ item->d_name);
dir = opendir(filename);
- if (!dir) {
- //ret = 1;
- //goto exit2;
+ if (!dir)
continue;
- }
count++;
if (count > numregulators) {
ret = 1;
- goto exit1;
+ goto exit;
}
strcpy(regulators_info[count-1].name, item->d_name);
@@ -154,7 +153,6 @@ int read_regulator_info(int verbose)
continue;
sprintf(filename + len, "/%s", ritem->d_name);
- // printf("Inside %s directory. Opening file %s!\n", item->d_name, ritem->d_name);
file = fopen(filename, "r");
if (!file)
@@ -163,12 +161,8 @@ int read_regulator_info(int verbose)
memset(line, 0, 1024);
fptr = fgets(line, 1024, file);
fclose(file);
- if (!fptr) {
- //ret = 1;
- //goto exit1;
+ if (!fptr)
continue;
- }
- // printf("Read file %s, data=%s, count = %d\n", filename, fptr, count);
if (!strcmp(ritem->d_name, "name"))
strcpy(regulators_info[count-1].name, fptr);
@@ -205,12 +199,11 @@ int read_regulator_info(int verbose)
if (!strcmp(ritem->d_name, "num_users"))
regulators_info[count-1].num_users = atoi(fptr);
}
-exit1:
+exit:
closedir(dir);
if (ret)
break;
}
-//exit2:
closedir(regdir);
return ret;
@@ -290,6 +283,5 @@ int main(int argc, char **argv)
read_and_print_sensor_info(verbose);
}
- return 0;
-
+ exit(0);
}
diff --git a/powerdebug.h b/powerdebug.h
index df8877d..a18ca5b 100644
--- a/powerdebug.h
+++ b/powerdebug.h
@@ -8,8 +8,6 @@
#define VERSION "1.0"
-//#define PATH_MAX 1024
-//#define NAME_MAX 128
#define VALUE_MAX 16
struct regulator_info {
@@ -35,4 +33,3 @@ extern void version(void);
extern void print_regulator_info(int verbose);
extern void get_sensor_info(char *path, char *name, char *sensor, int verbose);
-