aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Lezcano <daniel.lezcano@linaro.org>2016-02-18 15:40:12 +0000
committerDaniel Lezcano <daniel.lezcano@linaro.org>2016-02-18 15:40:12 +0000
commit188ff0f8369802e4ee53d005b25e8f686ee2243e (patch)
tree979784afb34721e827303b5b007663b07efb8df9
parent83b28d0ed342a549e62cac1c2f51d69063c0c868 (diff)
Prevent to init a subsystem if it is not selected.
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
-rw-r--r--powerdebug.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/powerdebug.c b/powerdebug.c
index 555beea..bc8fc92 100644
--- a/powerdebug.c
+++ b/powerdebug.c
@@ -208,13 +208,12 @@ static struct powerdebug_options *powerdebug_init(void)
{
struct powerdebug_options *options;
+ signal(SIGWINCH, sigwinch_handler);
+
options = malloc(sizeof(*options));
if (!options)
return NULL;
- memset(options, 0, sizeof(*options));
- signal(SIGWINCH, sigwinch_handler);
-
return options;
}
@@ -249,22 +248,22 @@ int main(int argc, char **argv)
return 1;
}
- if (regulator_init()) {
+ if ((options->flags & REGULATOR_OPTION) && regulator_init()) {
printf("failed to initialize regulator\n");
options->flags &= ~REGULATOR_OPTION;
}
- if (clock_init()) {
+ if ((options->flags & CLOCK_OPTION) && clock_init()) {
printf("failed to initialize clock details (check debugfs)\n");
options->flags &= ~CLOCK_OPTION;
}
- if (sensor_init()) {
+ if ((options->flags & SENSOR_OPTION) && sensor_init()) {
printf("failed to initialize sensors\n");
options->flags &= SENSOR_OPTION;
}
- if (gpio_init()) {
+ if ((options->flags & GPIO_OPTION) && gpio_init()) {
printf("failed to initialize gpios\n");
options->flags &= GPIO_OPTION;
}