am da1c7fa2
: make wifi_load_driver blocking
* commit 'da1c7fa2901ad0d6158412d35d3c2b67f4c54518': make wifi_load_driver blocking
This commit is contained in:
commit
7c20e6875d
2 changed files with 48 additions and 0 deletions
|
@ -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
|
||||
|
|
38
wifi/wifi.c
38
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
|
||||
|
|
Loading…
Reference in a new issue