Remove the selectedwindow options.
There is no logic behind the default window selection. The last
option parsed set the default window. Instead of having a specific
boolean set, use the first bit found in the flags for selecting the
the windows.
eg. powerdebug -s -g
=> flags = SENSOR_OPTION | GPIO_OPTION;
=> flags = 0x2 | 0x8 = 0x0a
=> flags = b01010000
=> fsl(flags) = 2
=> default window = 1 << fsl(flags) - 1
=> default window = 1 << 2 - 1
=> default window = 1 << 1
=> default window = 2 = SENSOR_OPTION
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
diff --git a/powerdebug.c b/powerdebug.c
index b626b05..b0d2ade 100644
--- a/powerdebug.c
+++ b/powerdebug.c
@@ -93,7 +93,6 @@
memset(options, 0, sizeof(*options));
options->ticktime = 10;
- options->selectedwindow = -1;
while (1) {
int optindex = 0;
@@ -106,19 +105,15 @@
switch (c) {
case 'r':
options->flags |= REGULATOR_OPTION;
- options->selectedwindow = REGULATOR;
break;
case 's':
options->flags |= SENSOR_OPTION;
- options->selectedwindow = SENSOR;
break;
case 'c':
options->flags |= CLOCK_OPTION;
- options->selectedwindow = CLOCK;
break;
case 'g':
options->flags |= GPIO_OPTION;
- options->selectedwindow = GPIO;
break;
case 'd':
options->flags |= DUMP_OPTION;
@@ -152,9 +147,6 @@
if (!(options->flags & DEFAULT_OPTION))
options->flags |= DEFAULT_OPTION;
- if (options->selectedwindow == -1)
- options->selectedwindow = CLOCK;
-
return 0;
}
@@ -177,7 +169,7 @@
static int powerdebug_display(struct powerdebug_options *options)
{
- if (display_init(options->selectedwindow)) {
+ if (display_init(options)) {
printf("failed to initialize display\n");
return -1;
}