Signed-off-by: Daniel Lezcano daniel.lezcano@linaro.org --- clocks.c | 5 ++++- gpio.c | 5 ++++- powerdebug.c | 19 ++++--------------- powerdebug.h | 20 ++++++++++++++++---- regulator.c | 5 ++++- sensor.c | 5 ++++- 6 files changed, 36 insertions(+), 23 deletions(-)
diff --git a/clocks.c b/clocks.c index c751ec1..b57de3d 100644 --- a/clocks.c +++ b/clocks.c @@ -447,10 +447,13 @@ static struct display_ops clock_ops = { /* * Initialize the clock framework */ -int clock_init(void) +int clock_init(struct powerdebug_options *options) { char clk_dir_path[MAX+1][PATH_MAX];
+ if (!(options->flags & CLOCK_OPTION)) + return 0; + if (locate_debugfs(clk_dir_path[CCF]) || locate_debugfs(clk_dir_path[OCF])) return -1;
diff --git a/gpio.c b/gpio.c index 8fd3e5c..36dedd1 100644 --- a/gpio.c +++ b/gpio.c @@ -375,10 +375,13 @@ out: /* * Initialize the gpio framework */ -int gpio_init(void) +int gpio_init(struct powerdebug_options *options) { int ret = 0;
+ if (!(options->flags & GPIO_OPTION)) + return 0; + ret = display_register(GPIO, &gpio_ops); if (ret) printf("error: gpio display register failed"); diff --git a/powerdebug.c b/powerdebug.c index 0f5c98a..b626b05 100644 --- a/powerdebug.c +++ b/powerdebug.c @@ -33,17 +33,6 @@
extern void sigwinch_handler(int);
-#define REGULATOR_OPTION 0x01 -#define SENSOR_OPTION 0x02 -#define CLOCK_OPTION 0x04 -#define GPIO_OPTION 0x08 - -#define VERBOSE_OPTION 0x10 -#define DUMP_OPTION 0x20 - -#define DEFAULT_OPTION (REGULATOR_OPTION | SENSOR_OPTION | \ - CLOCK_OPTION | GPIO_OPTION) - void usage(void) { printf("Usage: powerdebug [OPTIONS]\n"); @@ -243,22 +232,22 @@ int main(int argc, char **argv) return 1; }
- if ((options->flags & REGULATOR_OPTION) && regulator_init()) { + if (regulator_init(options)) { printf("failed to initialize regulator\n"); options->flags &= ~REGULATOR_OPTION; }
- if ((options->flags & CLOCK_OPTION) && clock_init()) { + if (clock_init(options)) { printf("failed to initialize clock details (check debugfs)\n"); options->flags &= ~CLOCK_OPTION; }
- if ((options->flags & SENSOR_OPTION) && sensor_init()) { + if (sensor_init(options)) { printf("failed to initialize sensors\n"); options->flags &= SENSOR_OPTION; }
- if ((options->flags & GPIO_OPTION) && gpio_init()) { + if (gpio_init(options)) { printf("failed to initialize gpios\n"); options->flags &= GPIO_OPTION; } diff --git a/powerdebug.h b/powerdebug.h index 33463a0..2df0a27 100644 --- a/powerdebug.h +++ b/powerdebug.h @@ -21,6 +21,17 @@
#define VERSION "0.7.3"
+#define REGULATOR_OPTION 0x01 +#define SENSOR_OPTION 0x02 +#define CLOCK_OPTION 0x04 +#define GPIO_OPTION 0x08 + +#define VERBOSE_OPTION 0x10 +#define DUMP_OPTION 0x20 + +#define DEFAULT_OPTION (REGULATOR_OPTION | SENSOR_OPTION | \ + CLOCK_OPTION | GPIO_OPTION) + struct powerdebug_options { int flags; unsigned int ticktime; @@ -28,14 +39,15 @@ struct powerdebug_options { char *clkname; };
-extern int clock_init(void); +extern int clock_init(struct powerdebug_options *options); extern int clock_dump(char *clk);
-extern int regulator_init(void); +extern int regulator_init(struct powerdebug_options *options); extern int regulator_dump(void);
-extern int gpio_init(void); +extern int gpio_init(struct powerdebug_options *options); extern int gpio_dump(void);
+extern int sensor_init(struct powerdebug_options *options); extern int sensor_dump(void); -extern int sensor_init(void); + diff --git a/regulator.c b/regulator.c index b38ddab..549a744 100644 --- a/regulator.c +++ b/regulator.c @@ -265,10 +265,13 @@ static struct display_ops regulator_ops = { .display = regulator_display, };
-int regulator_init(void) +int regulator_init(struct powerdebug_options *options) { int ret = 0;
+ if (!(options->flags & REGULATOR_OPTION)) + return 0; + ret = display_register(REGULATOR, ®ulator_ops); if (ret) printf("error: regulator display register failed"); diff --git a/sensor.c b/sensor.c index 008b662..3b37bc6 100644 --- a/sensor.c +++ b/sensor.c @@ -295,10 +295,13 @@ static struct display_ops sensor_ops = { .display = sensor_display, };
-int sensor_init(void) +int sensor_init(struct powerdebug_options *options) { int ret = 0;
+ if (!(options->flags & SENSOR_OPTION)) + return 0; + ret = display_register(SENSOR, &sensor_ops); if (ret) printf("error: sensor display register failed");