Prevent to init a subsystem if it is not selected.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
diff --git a/powerdebug.c b/powerdebug.c
index 555beea..bc8fc92 100644
--- a/powerdebug.c
+++ b/powerdebug.c
@@ -208,13 +208,12 @@
 {
 	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 @@
 		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;
 	}