OSDN Git Service

Unload/reload wifi driver on suspend/resume marshmallow-x86 android-x86-6.0-r1 android-x86-6.0-r2 android-x86-6.0-r3
authorChih-Wei Huang <cwhuang@linux.org.tw>
Tue, 6 Sep 2016 18:44:44 +0000 (02:44 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Tue, 6 Sep 2016 18:44:44 +0000 (02:44 +0800)
Android.mk
power.c

index 7dd518b..469a4ee 100644 (file)
@@ -15,7 +15,7 @@ include $(CLEAR_VARS)
 LOCAL_MODULE := power.x86
 LOCAL_MODULE_RELATIVE_PATH := hw
 LOCAL_SRC_FILES := power.c
-LOCAL_SHARED_LIBRARIES := liblog
+LOCAL_SHARED_LIBRARIES := liblog libcutils
 LOCAL_MODULE_TAGS := optional
 
 include $(BUILD_SHARED_LIBRARY)
diff --git a/power.c b/power.c
index 845e0a2..328a2e0 100644 (file)
--- a/power.c
+++ b/power.c
 
 #include <hardware/hardware.h>
 #include <hardware/power.h>
+#include <cutils/properties.h>
+#include <cutils/probe_module.h>
+
+extern int delete_module(const char *, unsigned int);
 
 #define SYS_CPU "/sys/devices/system/cpu"
 #define CPU_ONLINE "1"
@@ -51,6 +55,24 @@ static void power_init(struct power_module *module)
 
 static void power_set_interactive(struct power_module *module, int on)
 {
+    char mod[PROPERTY_VALUE_MAX];
+    if ((!property_get("wlan.no-unload-driver", mod, NULL) || strcmp(mod, "1"))
+            && property_get("wlan.modname", mod, NULL)) {
+        if (on) {
+            if (insmod_by_dep(mod, "", NULL, 0, NULL)) {
+                ALOGE("insmod %s failed", mod);
+            } else {
+                ALOGD("reload %s OK", mod);
+            }
+        } else {
+            if (delete_module(mod, O_NONBLOCK)) {
+                ALOGE("rmmod %s failed", mod);
+            } else {
+                ALOGD("unload %s OK", mod);
+            }
+        }
+    }
+
     set_nonboot_cpu_state(on ? CPU_ONLINE : CPU_OFFLINE);
 }