summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaddest Chang <maddest.chang@mediatek.com>2015-07-10 19:39:05 +0800
committerIliyan Malchev <malchev@google.com>2015-07-15 00:09:01 -0700
commitda1c7fa2901ad0d6158412d35d3c2b67f4c54518 (patch)
tree5d8322a9947d72bb74cb17d1e9c3a31a16aefba1
parentc96943046060b3aa1e0cd2fb3974dfa3aeacb7cc (diff)
downloadhardware_libhardware_legacy-da1c7fa2901ad0d6158412d35d3c2b67f4c54518.zip
hardware_libhardware_legacy-da1c7fa2901ad0d6158412d35d3c2b67f4c54518.tar.gz
hardware_libhardware_legacy-da1c7fa2901ad0d6158412d35d3c2b67f4c54518.tar.bz2
make wifi_load_driver blocking
Modify wifi_load_driver behavior synchronize startHal with the initialization of the wlan driver. This makes sure that on certain solutions, startHal will does not fail due to no wlan0 net device not being found. Bug:19888853 Change-Id: Ic6ec2211431c478e52eb516c40ec23c2e8945fbb Signed-off-by: Maddest Chang <maddest.chang@mediatek.com> Signed-off-by: Iliyan Malchev <malchev@google.com>
-rw-r--r--wifi/Android.mk10
-rw-r--r--wifi/wifi.c38
2 files changed, 48 insertions, 0 deletions
diff --git a/wifi/Android.mk b/wifi/Android.mk
index 99a4b0e..ed59b40 100644
--- a/wifi/Android.mk
+++ b/wifi/Android.mk
@@ -25,6 +25,16 @@ ifdef WIFI_DRIVER_FW_PATH_PARAM
LOCAL_CFLAGS += -DWIFI_DRIVER_FW_PATH_PARAM=\"$(WIFI_DRIVER_FW_PATH_PARAM)\"
endif
+ifdef WIFI_DRIVER_STATE_CTRL_PARAM
+LOCAL_CFLAGS += -DWIFI_DRIVER_STATE_CTRL_PARAM=\"$(WIFI_DRIVER_STATE_CTRL_PARAM)\"
+endif
+ifdef WIFI_DRIVER_STATE_ON
+LOCAL_CFLAGS += -DWIFI_DRIVER_STATE_ON=\"$(WIFI_DRIVER_STATE_ON)\"
+endif
+ifdef WIFI_DRIVER_STATE_OFF
+LOCAL_CFLAGS += -DWIFI_DRIVER_STATE_OFF=\"$(WIFI_DRIVER_STATE_OFF)\"
+endif
+
LOCAL_SRC_FILES += wifi/wifi.c
ifdef WPA_SUPPLICANT_VERSION
diff --git a/wifi/wifi.c b/wifi/wifi.c
index 4999f55..880f6fc 100644
--- a/wifi/wifi.c
+++ b/wifi/wifi.c
@@ -190,6 +190,30 @@ const char *get_dhcp_error_string() {
return dhcp_lasterror();
}
+#ifdef WIFI_DRIVER_STATE_CTRL_PARAM
+int wifi_change_driver_state(const char *state)
+{
+ int len;
+ int fd;
+ int ret = 0;
+
+ if (!state)
+ return -1;
+ fd = TEMP_FAILURE_RETRY(open(WIFI_DRIVER_STATE_CTRL_PARAM, O_WRONLY));
+ if (fd < 0) {
+ ALOGE("Failed to open driver state control param (%s)", strerror(errno));
+ return -1;
+ }
+ len = strlen(state) + 1;
+ if (TEMP_FAILURE_RETRY(write(fd, state, len)) != len) {
+ ALOGE("Failed to write driver state control param (%s)", strerror(errno));
+ ret = -1;
+ }
+ close(fd);
+ return ret;
+}
+#endif
+
int is_wifi_driver_loaded() {
char driver_status[PROPERTY_VALUE_MAX];
#ifdef WIFI_DRIVER_MODULE_PATH
@@ -263,6 +287,14 @@ int wifi_load_driver()
wifi_unload_driver();
return -1;
#else
+#ifdef WIFI_DRIVER_STATE_CTRL_PARAM
+ if (is_wifi_driver_loaded()) {
+ return 0;
+ }
+
+ if (wifi_change_driver_state(WIFI_DRIVER_STATE_ON) < 0)
+ return -1;
+#endif
property_set(DRIVER_PROP_NAME, "ok");
return 0;
#endif
@@ -287,6 +319,12 @@ int wifi_unload_driver()
} else
return -1;
#else
+#ifdef WIFI_DRIVER_STATE_CTRL_PARAM
+ if (is_wifi_driver_loaded()) {
+ if (wifi_change_driver_state(WIFI_DRIVER_STATE_OFF) < 0)
+ return -1;
+ }
+#endif
property_set(DRIVER_PROP_NAME, "unloaded");
return 0;
#endif