[cpp] view plain copy
int wifi_load_driver()
{
char driver_status[PROPERTY_VALUE_MAX];
int count = 0;
char tmp_buf[512] = {0};
char *p_strstr_wlan = NULL;
char *p_strstr_p2p = NULL;
int ret = 0;
FILE *fp = NULL;
ALOGD("Start to insmod %s.ko\n", WIFI_DRIVER_MODULE_NAME);
if (insmod(DRIVER_MODULE_PATH, DRIVER_MODULE_ARG) < 0) {
ALOGE("insmod %s ko failed!", WIFI_DRIVER_MODULE_NAME);
rmmod(DRIVER_MODULE_NAME); //it may be load driver already,try remove it.
return -1;
}
do{
fp=fopen("/proc/net/wireless", "r");
if (!fp) {
ALOGE("failed to fopen file: /proc/net/wireless\n");
property_set(DRIVER_PROP_NAME, "failed");
rmmod(DRIVER_MODULE_NAME); //try remove it.
return -1;
}
ret = fread(tmp_buf, sizeof(tmp_buf), 1, fp);
if (ret==0){
ALOGD("faied to read proc/net/wireless");
}
fclose(fp);