power_hikey: Use container_of macro instead of just casting
am: e150ab3632

Change-Id: I5e09be2cab0ccb48284da213e3449c93672668fc
diff --git a/power/power_hikey.c b/power/power_hikey.c
index a06a0d3..9b28e73 100644
--- a/power/power_hikey.c
+++ b/power/power_hikey.c
@@ -55,6 +55,11 @@
 static char *max_cpu_freq = NORMAL_MAX_FREQ;
 static char *low_power_max_cpu_freq = LOW_POWER_MAX_FREQ;
 
+
+#define container_of(addr, struct_name, field_name) \
+    ((struct_name *)((char *)(addr) - offsetof(struct_name, field_name)))
+
+
 static void sysfs_write(const char *path, char *s)
 {
     char buf[80];
@@ -77,7 +82,7 @@
 }
 
 /*[interactive cpufreq gov funcs]*********************************************/
-static void interactive_power_init(struct power_module __unused *module)
+static void interactive_power_init(struct hikey_power_module __unused *hikey)
 {
     int32_t is_svelte = property_get_int32(SVELTE_PROP, 0);
 
@@ -156,14 +161,16 @@
 
 static void hikey_power_init(struct power_module __unused *module)
 {
-    interactive_power_init(module);
+    struct hikey_power_module *hikey = container_of(module,
+                                              struct hikey_power_module, base);
+    interactive_power_init(hikey);
 }
 
 static void hikey_power_hint(struct power_module *module, power_hint_t hint,
                                 void *data)
 {
-    struct hikey_power_module *hikey =
-            (struct hikey_power_module *) module;
+    struct hikey_power_module *hikey = container_of(module,
+                                              struct hikey_power_module, base);
 
     pthread_mutex_lock(&hikey->lock);
     switch (hint) {
@@ -191,8 +198,8 @@
 
 static void set_feature(struct power_module *module, feature_t feature, int state)
 {
-    struct hikey_power_module *hikey =
-            (struct hikey_power_module *) module;
+    struct hikey_power_module *hikey = container_of(module,
+                                              struct hikey_power_module, base);
     switch (feature) {
     default:
         ALOGW("Error setting the feature, it doesn't exist %d\n", feature);