summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDheeraj CVR <cvr.dheeraj@gmail.com>2014-12-21 01:45:29 +0530
committerDheeraj CVR <cvr.dheeraj@gmail.com>2014-12-21 01:45:56 +0530
commit078ebedbc78d4a897dfb68abcca575b3b873ed3c (patch)
tree61985be0206077c45dd5a1322ac40c347cd61fef
parentb541d355f9e7887d926b729f4fe510c6a2332a7e (diff)
downloadandroid_hardware_broadcom_wlan-078ebedbc78d4a897dfb68abcca575b3b873ed3c.tar.gz
android_hardware_broadcom_wlan-078ebedbc78d4a897dfb68abcca575b3b873ed3c.tar.bz2
android_hardware_broadcom_wlan-078ebedbc78d4a897dfb68abcca575b3b873ed3c.zip
BCMDHD driver on several Samsung and few Sony devices is compiled as a module rather than being built into the kernel. Hence, the wlan0 interface is removed when the WiFi is turned off and the driver is unloaded. This causes the WiFi HAL to crash when the device is booted with WiFi turned off since with the absence of wlan0 interface, the WiFi interfaces in the HAL are not initialized. As a workaround, we check if the driver is loaded and if not, we temporarily load and unload the WiFi driver inorder to query the interfaces and initialize them. This atleast prevents the system from crashing and rebooting when the device is suspended. Change-Id: Ia7c2ce79a58e9eb6711fbf5f53f1d449cc27af87
-rw-r--r--bcmdhd/wifi_hal/wifi_hal.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/bcmdhd/wifi_hal/wifi_hal.cpp b/bcmdhd/wifi_hal/wifi_hal.cpp
index a99b156..ff7a6ec 100644
--- a/bcmdhd/wifi_hal/wifi_hal.cpp
+++ b/bcmdhd/wifi_hal/wifi_hal.cpp
@@ -27,6 +27,7 @@
#include <utils/Log.h>
+#include "wifi.h"
#include "wifi_hal.h"
#include "common.h"
#include "cpp_bindings.h"
@@ -646,6 +647,22 @@ wifi_error wifi_init_interfaces(wifi_handle handle)
hal_info *info = (hal_info *)handle;
struct dirent *de;
+ int moduleflag = 0;
+ int ret = 0;
+
+ /* Check to see if the wifi driver is loaded */
+ if (!is_wifi_driver_loaded()) {
+ /* If the bcmdhd driver is built as a module,
+ * it may not be loaded at this stage. Hence
+ * we load the driver manually just for the
+ * sake of querying the interfaces.
+ */
+ ret = wifi_load_driver();
+ if (ret < 0)
+ return WIFI_ERROR_UNKNOWN;
+
+ moduleflag = 1;
+ }
DIR *d = opendir("/sys/class/net");
if (d == 0)
@@ -686,6 +703,13 @@ wifi_error wifi_init_interfaces(wifi_handle handle)
closedir(d);
+ /* Unload the wifi driver if we have loaded it previously. */
+ if (moduleflag) {
+ ret = wifi_unload_driver();
+ if (ret < 0)
+ return WIFI_ERROR_UNKNOWN;
+ }
+
info->num_interfaces = n;
return WIFI_SUCCESS;
}