aboutsummaryrefslogtreecommitdiff
path: root/powerdebug.c
diff options
context:
space:
mode:
Diffstat (limited to 'powerdebug.c')
-rw-r--r--powerdebug.c45
1 files changed, 24 insertions, 21 deletions
diff --git a/powerdebug.c b/powerdebug.c
index 9874f5a..230155b 100644
--- a/powerdebug.c
+++ b/powerdebug.c
@@ -330,6 +330,20 @@ static int powerdebug_dump(struct powerdebug_options *options,
return 0;
}
+static int powerdebug_display(struct powerdebug_options *options,
+ struct regulator_info *reg_info, int nr_reg)
+{
+ if (display_init()) {
+ printf("failed to initialize display\n");
+ return -1;
+ }
+
+ if (mainloop(options, reg_info, nr_reg))
+ return -1;
+
+ return 0;
+}
+
static struct powerdebug_options *powerdebug_init(void)
{
struct powerdebug_options *options;
@@ -347,7 +361,7 @@ int main(int argc, char **argv)
{
struct powerdebug_options *options;
struct regulator_info *regulators_info;
- int numregulators;
+ int numregulators, ret;
options = powerdebug_init();
if (!options) {
@@ -355,14 +369,14 @@ int main(int argc, char **argv)
return 1;
}
- regulators_info = regulator_init(&numregulators);
- if (!regulators_info) {
- printf("not enough memory to allocate regulators info\n");
+ if (getoptions(argc, argv, options)) {
+ usage();
return 1;
}
- if (getoptions(argc, argv, options)) {
- usage();
+ regulators_info = regulator_init(&numregulators);
+ if (!regulators_info) {
+ printf("not enough memory to allocate regulators info\n");
return 1;
}
@@ -371,20 +385,9 @@ int main(int argc, char **argv)
options->clocks = false;
}
- /* we just dump the informations */
- if (options->dump) {
- if (powerdebug_dump(options, regulators_info, numregulators))
- return 1;
- return 0;
- }
-
- if (display_init()) {
- printf("failed to initialize display\n");
- return 1;
- }
+ ret = options->dump ?
+ powerdebug_dump(options, regulators_info, numregulators) :
+ powerdebug_display(options, regulators_info, numregulators);
- if (mainloop(options, regulators_info, numregulators))
- return 1;
-
- return 0;
+ return ret < 0;
}