hikey: Fix power-hal logcat noise

The way powerhal modules are initialized maybe changed
or was always broken, but as it is, some of the hikey power
module entries were not being initialized properly.

This was causing lots of noise in the logs, and potentially
other problematic behavior.

This changes the initial allocation so we allocate the whole
structure and initialize it properly.

Change-Id: I7d7858c2890d03758b302b95f18bd1c35b6ef85b
Signed-off-by: John Stultz <john.stultz@linaro.org>
diff --git a/power/power_hikey.c b/power/power_hikey.c
index 8d687fe..4661702 100644
--- a/power/power_hikey.c
+++ b/power/power_hikey.c
@@ -405,21 +405,25 @@
     ALOGD("%s: enter; name=%s", __FUNCTION__, name);
 
     if (strcmp(name, POWER_HARDWARE_MODULE_ID) == 0) {
-        power_module_t *dev = (power_module_t *)calloc(1,
-                sizeof(power_module_t));
+        struct hikey_power_module *dev = (struct hikey_power_module *)calloc(1,
+                sizeof(struct hikey_power_module));
 
         if (dev) {
             /* Common hw_device_t fields */
-            dev->common.tag = HARDWARE_DEVICE_TAG;
-            dev->common.module_api_version = POWER_MODULE_API_VERSION_0_5;
-            dev->common.hal_api_version = HARDWARE_HAL_API_VERSION;
+            dev->base.common.tag = HARDWARE_DEVICE_TAG;
+            dev->base.common.module_api_version = POWER_MODULE_API_VERSION_0_5;
+            dev->base.common.hal_api_version = HARDWARE_HAL_API_VERSION;
 
-            dev->init = hikey_power_init;
-            dev->powerHint = hikey_power_hint;
-            dev->setInteractive = hikey_cpufreq_set_interactive;
-            dev->setFeature = set_feature;
+            dev->base.init = hikey_power_init;
+            dev->base.powerHint = hikey_power_hint;
+            dev->base.setInteractive = hikey_cpufreq_set_interactive;
+            dev->base.setFeature = set_feature;
 
-            *device = (hw_device_t*)dev;
+            pthread_mutex_init(&dev->lock, NULL);
+            dev->boostpulse_fd = -1;
+            dev->boostpulse_warned = 0;
+
+            *device = (hw_device_t*)&dev->base;
         } else
             retval = -ENOMEM;
     } else {
@@ -445,14 +449,5 @@
             .author = "The Android Open Source Project",
             .methods = &power_module_methods,
         },
-
-        .init = hikey_power_init,
-        .setInteractive = hikey_cpufreq_set_interactive,
-        .powerHint = hikey_power_hint,
-        .setFeature = set_feature,
     },
-
-    .lock = PTHREAD_MUTEX_INITIALIZER,
-    .boostpulse_fd = -1,
-    .boostpulse_warned = 0,
 };