Ejemplo n.º 1
0
s32 wifi_qsap_unload_driver()
{
    s32 ret = eSUCCESS;

    if(system(SDIO_POLLING_ON)) {
        LOGE("Could not turn on the polling...");
    }

    if ( check_driver_loaded(WIFI_DRIVER_MODULE_NAME " ") ) {
        qsap_send_module_down_indication();
        if ( rmmod(WIFI_DRIVER_MODULE_NAME) ) {
            LOGE("Unable to unload the libra_softap driver\n");
            ret = eERR_UNLOAD_FAILED_SOFTAP;
            goto end;
        }
    }

    sched_yield();

    if ( check_driver_loaded(WIFI_SDIO_IF_DRIVER_MODULE_NAME " ") ) {
        if ( rmmod(WIFI_SDIO_IF_DRIVER_MODULE_NAME) ) {
            LOGE("Unable to unload the librasdioif driver\n");
            ret = eERR_UNLOAD_FAILED_SDIO;
            goto end;
        }
    }
end:
    if(system(SDIO_POLLING_OFF)) {
        LOGE("Could not turn off the polling...");
    }

    return ret;
}
Ejemplo n.º 2
0
int main(void)
{
	int ret;

	LOGD("BT MAC acquire is working......");
#if 0
	ret = check_wlan_mac();
	if (ret == 0)
		return 0;
#endif

	/* Or we try to get MAC via WiFi driver. then +1 as BT's MAC address */
	ret = insmod(DRIVER_MODULE_PATH);	
	if (ret < 0)
	{
		LOGD("Install wifi driver failed.");
		rmmod(DRIVER_MODULE_NAME);
		return -1;
	}
        
        usleep(500000);  //delay 500ms
	/* We can try to store MAC to file. */
	//store_wlan_mac();

	rmmod(DRIVER_MODULE_NAME);

	return 0;
}
int wifi_unload_driver()
{
    usleep(200000); /* allow to finish interface down */
#ifdef WIFI_DRIVER_MODULE_PATH
    if (rmmod(DRIVER_MODULE_NAME) == 0) {
        int count = 20; /* wait at most 10 seconds for completion */
        while (count-- > 0) {
            if (!is_wifi_driver_loaded())
                break;
            usleep(500000);
        }
        usleep(500000); /* allow card removal */
        if (count) {
#ifdef WIFI_EXT_MODULE_NAME
            if (rmmod(EXT_MODULE_NAME) == 0)
#endif
            return 0;
        }
        return -1;
    } else
        return -1;
#else
    property_set(DRIVER_PROP_NAME, "unloaded");
    return 0;
#endif
}
Ejemplo n.º 4
0
static int _wifi_unload_driver()
{
    char active_wlan_chip[PROPERTY_VALUE_MAX];
    int count = 20; /* wait at most 10 seconds for completion */
    char driver_status[PROPERTY_VALUE_MAX];
    int s, ret;

    property_get("wlan.driver.ath", active_wlan_chip, WIFI_WCN);

    if (rmmod(DRIVER_MODULE_NAME) == 0) {
        while (count-- > 0) {
            if (!is_wifi_driver_loaded())
                break;
            usleep(500000);
        }
        if (count) {
           if ('\0' != *DRIVER_SDIO_IF_MODULE_NAME && (0 == strcmp(active_wlan_chip, WIFI_WCN))) {
                if (!(rmmod(DRIVER_SDIO_IF_MODULE_NAME) == 0)) {
                    return -1;
                }
            }
           if ('\0' != *DRIVER_CFG80211_MODULE_NAME) {
                if (!(rmmod(DRIVER_CFG80211_MODULE_NAME) == 0)) {
                    return -1;
                }
            }
            return 0;
        }
        return -1;
    } else
        return -1;
}
Ejemplo n.º 5
0
s32 wifi_qsap_unload_wifi_sta_driver(void)
{
    s32    ret = 0;

    if(system(SDIO_POLLING_ON)) {
        LOGE("Could not turn on the polling...");
    }

    if ( check_driver_loaded(WIFI_DRIVER_MODULE_NAME " ") ) {
        qsap_send_module_down_indication();
        if ( rmmod(WIFI_DRIVER_MODULE_NAME) ) {
            LOGE("Unable to unload the station mode wifi driver...\n");
            ret = 1;
            goto end;
        }
    }

    sched_yield();

    if ( check_driver_loaded(WIFI_SDIO_IF_DRIVER_MODULE_NAME " ") ) {
        if ( rmmod(WIFI_SDIO_IF_DRIVER_MODULE_NAME) ) {
            LOGE("Unable to unload the station mode librasdioif driver\n");
            ret = 1;
            goto end;
        }
    }

end:
    if(system(SDIO_POLLING_OFF)) {
        LOGE("Could not turn off the polling...");
    }
    sched_yield();
    return 0;
}
Ejemplo n.º 6
0
int main(void)
{
	int ret;

	LOGD("WLAN MAC checker is working......");

	ret = check_wlan_mac();
	if (ret == 0)
		return 0;

	/* Or we try to get MAC via WiFi driver. */
	ret = insmod(DRIVER_MODULE_PATH);	
	if (ret < 0)
	{
		LOGD("Install wifi driver failed.");
		rmmod(DRIVER_MODULE_NAME);
		return -1;
	}

	system("busybox ifconfig wlan0 up");

	/* We can try to store MAC to file. */
	store_wlan_mac();

	rmmod(DRIVER_MODULE_NAME);

	return 0;
}
int wifi_unload_hotspot_driver()
{
#ifndef WIFI_AP_DRIVER_MODULE_PATH
    return wifi_unload_driver();
#else
    if (!is_wifi_hotspot_driver_loaded()) {
        return 0;
    }
    usleep(200000); /* allow to finish interface down */
    if (rmmod(AP_DRIVER_MODULE_NAME) == 0) {
        int count = 20; /* wait at most 10 seconds for completion */
        while (count-- > 0) {
            if (!is_wifi_hotspot_driver_loaded())
                break;
            usleep(500000);
        }
        usleep(500000); /* allow card removal */
        if (count) {
#ifdef WIFI_EXT_MODULE_NAME
            if (rmmod(EXT_MODULE_NAME) == 0)
#endif
            return 0;
        }
        return -1;
    } else
        return -1;
#endif
}
Ejemplo n.º 8
0
int
stop_rcamd(void)
{
	killall("mjpg_streamer");
	rmmod("uvcvideo");
	rmmod("input-core");
	rmmod("v4l2-common");
	rmmod("videodev");
	return 0;
}
Ejemplo n.º 9
0
int unloadWimaxDriver()
{
    LOGI("NATIVE::unloadWimaxDriver() - Unloading wimax driver...");
    char pid[PROPERTY_VALUE_MAX];
    int count = 20; /* wait at most 10 seconds for completion */
    property_set("ctl.stop", SERVICE_NAME);
    if (property_get(DRIVER_PROP_NAME, pid, NULL)) {
	LOGI("NATIVE::unloadWimaxDriver() - Killing sequansd...");
        kill(atoi(pid), SIGQUIT);
    }
    sched_yield();
    property_set(DRIVER_PROP_NAME, "");
    if (rmmod(DRIVER_MODULE_NAME) == 0) {
        while (count-- > 0) {
            if (!check_driver_loaded())
                break;
            usleep(500000);
        }
        if (count) {
            return 0;
        }
        return -1;
    } else
        return -1;
}
Ejemplo n.º 10
0
void newserv_shutdown() {
  module *mods;
  char buf[1024];

  while (modules.cursi) {
    mods=(module *)(modules.content);

    strlcpy(buf, mods[0].name->content, sizeof(buf));

    /* Unload the module unless we're running on Valgrind -
     * in which case unloading the module would invalidate
     * stacktraces Valgrind has captured so far. */
    rmmod(buf, !RUNNING_ON_VALGRIND);
  }
  
  clearmoduledeps();

  if (moddir!=NULL)
    freesstring(moddir);

  if (modsuffix!=NULL)
    freesstring(modsuffix);

  Error("core",ERR_INFO,"All modules removed.  Exiting.");
}
Ejemplo n.º 11
0
static int gsensor_load_driver(struct sensors_poll_context_t *dev)
{
    int ret = -1; 
    char buffer[20];
    int bytes = 0;
    int values = 0;
    load_driver_value = 0;
    if(detect_value[0] < ( SENSORS_NUMBER + 1)) {
             ALOGD("start to isnmod %s.ko\n",sensors[detect_value[0]-1].name);
            if (insmod(driver_path[detect_value[0]-1].name, "") < 0) {
                          ALOGD("insmod %s.ko failed!",sensors[detect_value[0]-1].name);
                          rmmod(sensors[detect_value[0]-1].name);//it may be load driver already,try remove it.
                          return 0;
                     } 
           if(!(ret = sensor_init(dev))){
                 
                 ALOGD("sensor_init error !\n"); 
                 return 0;              
           }
    }else{
         ALOGD("detect_value isn't valid!\n");
         return 0;
    }
        
    return 1;
    
}
int wifi_unload_driver()
{
    usleep(200000); /* allow to finish interface down */
#ifdef WIFI_DRIVER_MODULE_PATH
    char modname[PROPERTY_VALUE_MAX];
    if (!property_get(DRIVER_NAME_PROP, modname, NULL))
        return -1;
    if (property_get("wlan.no-unload-driver", modname, NULL)
            && strcmp(modname, "1") == 0)
        return 0;

    if (rmmod(modname) == 0) {
        int count = 20; /* wait at most 10 seconds for completion */
        while (count-- > 0) {
            if (!is_wifi_driver_loaded())
                break;
            usleep(500000);
        }
        usleep(500000); /* allow card removal */
        if (count) {
            return 0;
        }
    }
    return -1;
#else
    property_set(DRIVER_PROP_NAME, "unloaded");
    return 0;
#endif
}
Ejemplo n.º 13
0
static int insmod_modules(char * buf)
{
        char * module_name;
        char insmod_name[128];
        char ko[] = ".ko";
        memset(insmod_name,0,sizeof(insmod_name));
        
        module_name = get_module_name(buf);
#ifdef DEBUG
        ALOGD("module_name:%s\n",module_name);
#endif
        if(module_name != NULL){
                sprintf(insmod_name,"%s%s%s",INSMOD_PATH,module_name,ko);
                
#ifdef  DEBUG
                ALOGD("start to insmod %s\n",insmod_name);
#endif                
                if (insmod(insmod_name, "") < 0) {
                        ALOGD(" %s insmod failed!\n",insmod_name);
                        rmmod(module_name);//it may be load driver already,try remove it and insmod again.
                        if (insmod(insmod_name, "") < 0){
                                ALOGD("%s,Once again fail to load!",insmod_name);
                                return 0;
                        }
                } 
        }
        return 1;
}
Ejemplo n.º 14
0
int wifi_unload_driver()
{
    int count = 20; /* wait at most 10 seconds for completion */
    char pid_txt[PROPERTY_VALUE_MAX];
    int pid;
   
    if (property_get("wlan.driver.unifi_helper_pid", pid_txt, NULL)) {
        pid = atoi(pid_txt);
        kill(pid, SIGTERM);
        sched_yield();
        property_set("wlan.driver.unifi_helper_pid", NULL);
    }
    if (rmmod(DRIVER_MODULE_NAME) == 0) {
	while (count-- > 0) {
	    if (!check_driver_loaded())
		break;
    	    usleep(500000);
	}
	if (count) {
    	    return 0;
	}
	return -1;
    } else
        return -1;
}
Ejemplo n.º 15
0
Archivo: rmmod.c Proyecto: OPSF/uClinux
int main(int argc, char *argv[])
{
	/* O_EXCL so kernels can spot old rmmod versions */
	unsigned int flags = O_NONBLOCK|O_EXCL;
	int i, opt, all = 0, log = 0, verbose = 0;
	int ret, err;

	try_old_version("rmmod", argv);

	while ((opt = getopt_long(argc, argv,
			"afh?swvV", options, NULL)) != EOF) {
		switch (opt) {
		case 'a':	// --all
			all = 1;
			break;
		case 'f':	// --force
			flags |= O_TRUNC;
			break;
		case 's':	// --syslog
			openlog("rmmod", LOG_CONS, LOG_DAEMON);
			log = 1;
			break;
		case 'w':	// --wait
			flags &= ~O_NONBLOCK;
			break;
		case 'v':	// --verbose
			verbose++;
			break;
		case 'V':	// --version
			puts(PACKAGE " version " VERSION);
			return 0;

		default:
			print_usage(argv[0]);
		}
	}
	if (!argv[optind]) {
		if (all) {
			/* FIXME implement */
			exit(1);
		}
		fprintf(stderr, "no module names given\n");
		print_usage(argv[0]);
	}

	err = 0;
	/* remove each specified module */
	for (i = optind; i < argc; i++) {
		ret = rmmod(log, verbose, argv[i], flags);
		if (ret!=0)
			err = ret;
	}

	if (log)
		closelog();
	exit(err);
}
Ejemplo n.º 16
0
void stop_vpn_modules(void)
{
	rmmod("nf_nat_pptp");
	rmmod("nf_conntrack_pptp");
	rmmod("nf_nat_proto_gre");
	rmmod("nf_conntrack_proto_gre");
	rmmod("ip_nat_pptp");
	rmmod("ip_nat_proto_gre");
	rmmod("ip_conntrack_pptp");
	rmmod("ip_conntrack_proto_gre");
	dd_syslog(LOG_INFO, "vpn modules : vpn modules successfully unloaded\n");
}
int wifi_load_hotspot_driver()
{
#ifndef WIFI_AP_DRIVER_MODULE_PATH
    return wifi_load_driver();
#else
    char driver_status[PROPERTY_VALUE_MAX];
    int count = 100; /* wait at most 20 seconds for completion */
    char module_arg[PROPERTY_VALUE_MAX];

    if (is_wifi_hotspot_driver_loaded()) {
        property_set(AP_DRIVER_PROP_NAME, "ok");
        return 0;
    }

    property_set(AP_DRIVER_PROP_NAME, "loading");

#ifdef WIFI_EXT_MODULE_PATH
    if (insmod(EXT_MODULE_PATH, EXT_MODULE_ARG) < 0)
        return -1;
    usleep(200000);
#endif

    property_get(AP_DRIVER_PROP_MODULE_ARG, module_arg, AP_DRIVER_MODULE_ARG);
    if (insmod(AP_DRIVER_MODULE_PATH, module_arg) < 0) {
#ifdef WIFI_EXT_MODULE_NAME
        rmmod(EXT_MODULE_NAME);
#endif
        return -1;
    }

    if (strcmp(AP_FIRMWARE_LOADER,"") == 0) {
        /* usleep(WIFI_DRIVER_LOADER_DELAY); */
        property_set(AP_DRIVER_PROP_NAME, "ok");
    }
    else {
        property_set("ctl.start", AP_FIRMWARE_LOADER);
    }
    sched_yield();
    while (count-- > 0) {
        if (property_get(AP_DRIVER_PROP_NAME, driver_status, NULL)) {
            if (strcmp(driver_status, "ok") == 0)
                return 0;
            else if (strcmp(AP_DRIVER_PROP_NAME, "failed") == 0) {
                wifi_unload_hotspot_driver();
                return -1;
            }
        }
        usleep(200000);
    }
    property_set(AP_DRIVER_PROP_NAME, "timeout");
    wifi_unload_hotspot_driver();
    return -1;
#endif
}
Ejemplo n.º 18
0
int rmmod(char *modulename, int close) {
  int i,j;
  module *mods;
  struct module_dep *mdp;
  char modulebuf[1024];

  strlcpy(modulebuf, modulename, sizeof(modulebuf));
  delchars(modulebuf,"./\\;");
  
  i=getindex(modulebuf);
  if (i<0)
    return 1;

  if ((mdp=getmoduledep(modulebuf))) {
    for (j=0;j<mdp->numchildren;j++) {
      if (isloaded(mdp->children[j]->name->content)) {
        if (rmmod(mdp->children[j]->name->content, close)) {
          Error("core",ERR_WARNING,"Unable to remove child module %s (depends on %s)",
                 mdp->children[j]->name->content, modulebuf);
          return 1;
        }
      }
    }

    /* We may have removed other modules - reaquire the index number in case it has changed. */
    i=getindex(modulebuf);
    if (i<0)
      return 1;
  } else {
    Error("core",ERR_WARNING,"Removing module %s without dependency information",modulebuf);
  }
  
  mods=(module *)(modules.content);
    
  if (!close
#ifdef BROKEN_DLCLOSE
      || 1
#endif
     ) {
    void (*fini)();
    fini = dlsym(mods[i].handle, "__fini");
    if(!dlerror())
      fini();
  } else
    dlclose(mods[i].handle);

  freesstring(mods[i].name);
  array_delslot(&modules,i);

  Error("core",ERR_INFO,"Removed module %s.",modulebuf);
  
  return 0;
}    
Ejemplo n.º 19
0
static int rmmod_all(struct kmod_ctx *ctx, char **args, int nargs)
{
	int i, err = 0;

	for (i = 0; i < nargs; i++) {
		int r = rmmod(ctx, args[i]);
		if (r < 0)
			err = r;
	}

	return err;
}
Ejemplo n.º 20
0
static int get_gsensor(void)
{
    struct input_event event;
    int fd;
    int ret = -1;
    int zero_value = 0;
    
    memset(&detect_value,0,sizeof(detect_value));
    
	fd = open_input_device();
	if(fd < 0 ){
	     ALOGD("%s:open input device erro!\n",__func__);
	     return 0;
	}

	 while (zero_value < 20) {       
	            ret = read(fd, &event, sizeof(event));
	            if(ret < 0){
	               ALOGD("%s:can't read!\n",__func__);
	            }
	            switch (event.code) {
	                case ABS_MISC:
                			    if(event.value != 0){
                			        detect_value[detect_num++] = event.value;
                			        #ifdef DEBUG_SENSOR
                			        ALOGD("detect_value[%d]:%d",detect_num-1,detect_value[detect_num-1]);
                			        #endif
                			        }else{
                			            zero_value++;
                			        }
				                break;
				default:
				    break;
	            }	
	           if( detect_num  == 2)
	           {
	                  if(detect_value[0] == detect_value[1]) {
            	          close(fd); 	           
            	          break;
        	          }else {
        	            	 ALOGD("detect_value is erro!\n");
        	                 close(fd);
        	                 return 0;
        	          }
	           }
     }
     rmmod("gsensor"); 
     memset(&class_path,0,sizeof(class_path));
     memset(&sensor_name,0,sizeof(sensor_name));
     ret = (zero_value != 20) ? 1 : 0;
     return ret;     
}
Ejemplo n.º 21
0
s32 wifi_qsap_load_driver(void)
{
    s32    size;
    s32        ret = 0;
    s32        retry;

    /* Unload the station mode driver first */
    wifi_qsap_unload_wifi_sta_driver();

    if (system(SDIO_POLLING_ON)) {
        LOGE("Could not turn on the polling...");
    }

    if (sizeof(WIFI_SDIO_IF_DRIVER_MODULE_PATH) > 0) {
       ret = insmod(WIFI_SDIO_IF_DRIVER_MODULE_PATH, WIFI_SDIO_IF_DRIVER_MODULE_ARG, WIFI_SDIO_IF_DRIVER_MODULE_NAME " ");

       if ( ret != 0 ) {
          LOGE("init_module failed sdioif\n");
          ret = eERR_LOAD_FAILED_SDIOIF;
          goto end;
      }

      sched_yield();
    }

    ret = insmod(WIFI_DRIVER_MODULE_PATH, WIFI_DRIVER_MODULE_ARG, WIFI_DRIVER_MODULE_NAME " ");

    if ( ret != 0 ) {
        if (sizeof(WIFI_SDIO_IF_DRIVER_MODULE_PATH) > 0) {
            if ( check_driver_loaded(WIFI_SDIO_IF_DRIVER_MODULE_NAME " ") ) {
                    if ( rmmod(WIFI_SDIO_IF_DRIVER_MODULE_NAME) ) {
                        LOGE("Unable to unload the station mode librasdioif driver\n");
              }
            }
        }
        LOGE("init_module failed libra_softap\n");
        ret = eERR_LOAD_FAILED_SOFTAP;
		goto end;
    }

    sched_yield();
    
	ret = eSUCCESS;

end:
    if(system(SDIO_POLLING_OFF)) {
        LOGE("Could not turn off the polling...");
    }

    return ret;
}
Ejemplo n.º 22
0
int hotspot_load_driver()
{
    char driver_status[PROPERTY_VALUE_MAX];
    int count = 100; /* wait at most 20 seconds for completion */

    if (check_hotspot_driver_loaded()) {
        return 0;
    }

    if (!strcmp(PRELOADER,"") == 0) {
        LOGW("Starting WIFI pre-loader");
        property_set("ctl.start", PRELOADER);
    }

#ifdef WIFI_EXT_MODULE_PATH
    if (insmod(EXT_MODULE_PATH, EXT_MODULE_ARG) < 0)
        return -1;
    usleep(200000);
#endif

    if (insmod(AP_DRIVER_MODULE_PATH, AP_DRIVER_MODULE_ARG) < 0){
#ifdef WIFI_EXT_MODULE_NAME
        rmmod(EXT_MODULE_NAME);
#endif
        return -1;
    }

    if (strcmp(AP_FIRMWARE_LOADER,"") == 0) {
        usleep(WIFI_DRIVER_LOADER_DELAY);
        property_set(AP_DRIVER_PROP_NAME, "ok");
    }
    else {
        property_set("ctl.start", AP_FIRMWARE_LOADER);
        usleep(WIFI_DRIVER_LOADER_DELAY);
    }
    sched_yield();
    while (count-- > 0) {
        if (property_get(AP_DRIVER_PROP_NAME, driver_status, NULL)) {
            if (strcmp(driver_status, "ok") == 0)
                return 0;
            else if (strcmp(AP_DRIVER_PROP_NAME, "failed") == 0) {
                hotspot_unload_driver();
                return -1;
            }
        }
        usleep(200000);
    }
    property_set(AP_DRIVER_PROP_NAME, "timeout");
    hotspot_unload_driver();
    return -1;
}
Ejemplo n.º 23
0
void safereloadcallback(void *arg) {
  safereload_sched=NULL;
  
  if (!safereload_str)
    return;
  
  preparereload(safereload_str->content);
  rmmod(safereload_str->content, 1);
  insmod(safereload_str->content);
  reloadmarked();

  freesstring(safereload_str);
  safereload_str=NULL;
}
Ejemplo n.º 24
0
int wifi_unload_driver()
{
    int count = 20; /* wait at most 10 seconds for completion */

    if (rmmod(DRIVER_MODULE_NAME) == 0) {
        while (count-- > 0) {
            if (!check_driver_loaded())
                break;
            usleep(500000);
        }
        if (count) {
#ifdef WIFI_EXT_MODULE_NAME
            if (rmmod(EXT_MODULE_NAME) == 0)
#endif
                if (!strcmp(PRELOADER,"") == 0) {
                    LOGW("Stopping WIFI pre-loader");
                    property_set("ctl.stop", PRELOADER);
                }
            return 0;
        }
        return -1;
    } else
        return -1;
}
Ejemplo n.º 25
0
static int _wifi_unload_driver()
{
    int count = 20; /* wait at most 10 seconds for completion */
    char driver_status[PROPERTY_VALUE_MAX];
    int s, ret;

    if (rmmod(DRIVER_MODULE_NAME) == 0) {
        while (count-- > 0) {
            if (!is_wifi_driver_loaded())
                break;
            usleep(500000);
        }

        if (count) {
			/* unload cfg80211 kernel module */
            if (rmmod(DRIVER_SDIO_IF_MODULE_NAME) != 0) {
                return -1;
		 }

#if defined(IMX5X)
            /* unload compat kernel module */
	    if (rmmod(DRIVER_COMPAT_MODULE_NAME) != 0) {
                return -1;
		}
#endif
        }
        else {
            return -1;
        }

        return 0;
    }
    else {
        return -1;
    }
}
Ejemplo n.º 26
0
int wifi_unload_driver()
{
    int count = 20; /* wait at most 10 seconds for completion */

	LOGD("wifi unload driver.\n");

    if ( (rmmod(DRIVER_MODULE_NAME) == 0) 
#ifdef     NANO_SDIO_WIFI_USED
            && (rmmod(FIRMWARE_MODULE_NAME) == 0) 
#endif
            ) {
    	while (count-- > 0) {
    	    if (!check_driver_loaded())
    		break;
        	    usleep(500000);
    	}
    	if (count) {
        	return 0;
    	}
    	return -1;
    } else
        return -1;

}
Ejemplo n.º 27
0
int cmd_rmmod(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
{
  int ret;

  /* Usage: rmmod <modulename> */
  /* Remove the module  */

  ret = rmmod(argv[1]);
  if (ret < 0)
    {
      nsh_output(vtbl, g_fmtcmdfailed, argv[0], "rmmod", NSH_ERRNO);
      return ERROR;
    }

  return OK;
}
Ejemplo n.º 28
0
int wifi_unload_driver()
{

    
    int count = 20; /* wait at most 10 seconds for completion */

    if (rmmod(DRIVER_MODULE_NAME) == 0) {
	while (count-- > 0) {
	    if (!check_driver_loaded())
		break;
    	    usleep(500000);
	}
	if (count) {
    	    return 0;
	}
	return -1;
    } else
        return -1;
}
int main(void)
{
    char mac_param[128];

    write_int("/sys/devices/platform/msm_sdcc.3/polling", 1);
    
    getmac(mac_param);
    LOGI("Loading Libra.ko");
    if ((insmod(DRIVER_MODULE_PATH, mac_param)) < 0){
        rmmod("librasdioif");
    } else {
        usleep(WIFI_DRIVER_LOADER_DELAY);
        property_set("wlan.driver.status", "ok");       
    }

    write_int("/sys/devices/platform/msm_sdcc.3/polling", 0);

    return 0;
}
Ejemplo n.º 30
0
int main(int argc, char *argv[])
{
	int iRet = -1;
	int noextChip = -1;
	int chipId = -1;
	int count = 0;
	char chipidStr[PROPERTY_VALUE_MAX] = {0};
	int loadFmResult = -1;
	int loadAntResult = -1;
	int loadWlanResult = -1;
	int retryCounter = 1;
	int autokRet = 0;
	do{
		gLoaderFd = open(WCN_COMBO_LOADER_DEV, O_RDWR | O_NOCTTY);
		if(gLoaderFd < 0)
		{
			count ++;
			ALOGI("Can't open device node(%s) count(%d)\n", WCN_COMBO_LOADER_DEV,count);
			usleep(300000);
		}
		else
			break;
	}while(1);

	//read from system property
	iRet = property_get(WCN_COMBO_LOADER_CHIP_ID_PROP, chipidStr, NULL);
	chipId = strtoul(chipidStr, NULL, 16);

	if ((0 != iRet) && (-1 != is_chipId_vaild(chipId)))
	{
		/*valid chipid detected*/
		ALOGI("key:(%s)-value:(%s),chipId:0x%04x,iRet(%d)\n", WCN_COMBO_LOADER_CHIP_ID_PROP, chipidStr, chipId,iRet);
		if (0x6630 == chipId)
		{
			retryCounter = 10;
			/*trigger autok process, incase last autok process is interrupted by abnormal power off or battery down*/
			do {
				/*power on combo chip*/
				iRet = ioctl(gLoaderFd,COMBO_IOCTL_EXT_CHIP_PWR_ON);
				if (0 != iRet)
				{
					ALOGI("external combo chip power on failed\n");
					noextChip = 1;
				}
				else
				{
					/*detect is there is an external combo chip*/
					noextChip = ioctl(gLoaderFd,COMBO_IOCTL_EXT_CHIP_DETECT,NULL);
				}

				if(noextChip)
				{
					 // do nothing
					 ALOGI("no external combo chip detected\n");
				}
				else
				{
					ALOGI("external combo chip detected\n");

					chipId = ioctl(gLoaderFd, COMBO_IOCTL_GET_CHIP_ID, NULL);
					ALOGI("chipid (0x%x) detected\n", chipId);
				}


				if(0 == noextChip)
				{
					autokRet = ioctl(gLoaderFd,COMBO_IOCTL_DO_SDIO_AUDOK,chipId);
					if (0 != autokRet)
					{
						ALOGI("do SDIO3.0 autok failed\n");
					}
					else
					{
						ALOGI("do SDIO3.0 autok succeed\n");
					}
				}
				iRet = ioctl(gLoaderFd,COMBO_IOCTL_EXT_CHIP_PWR_OFF);
				if (0 != iRet)
				{
					ALOGI("external combo chip power off failed\n");
				}
				else
				{
					ALOGI("external combo chip power off succeed\n");
				}
				if ((0 == noextChip) && (-1 == chipId))
				{
					/*extenral chip detected, but no valid chipId detected, retry*/
					retryCounter--;
					ALOGI("chipId detect failed, retrying, left retryCounter:%d\n", retryCounter);
					usleep(500000);
				}
				else
					break;
			}while (0 < retryCounter);
			chipId = 0x6630;
		}
	}
	else
	{
		/*trigger external combo chip detect and chip identification process*/
		do {
			/*power on combo chip*/
			iRet = ioctl(gLoaderFd,COMBO_IOCTL_EXT_CHIP_PWR_ON);
			if (0 != iRet)
			{
				ALOGI("external combo chip power on failed\n");
				noextChip = 1;
			}
			else
			{
				/*detect is there is an external combo chip*/
				noextChip = ioctl(gLoaderFd,COMBO_IOCTL_EXT_CHIP_DETECT,NULL);
			}

			if(noextChip)// use soc itself
			{
				ALOGI("no external combo chip detected, get current soc chipid\n");
				chipId = ioctl(gLoaderFd, COMBO_IOCTL_GET_SOC_CHIP_ID, NULL);
				ALOGI("soc chipid (0x%x) detected\n", chipId);
			}
			else
			{
				ALOGI("external combo chip detected\n");

				chipId = ioctl(gLoaderFd, COMBO_IOCTL_GET_CHIP_ID, NULL);
				ALOGI("chipid (0x%x) detected\n", chipId);
			}

			sprintf (chipidStr, "0x%04x", chipId);
			iRet = property_set(WCN_COMBO_LOADER_CHIP_ID_PROP,chipidStr);
			if (0 != iRet)
			{
				ALOGI("set property(%s) to %s failed,iRet:%d, errno:%d\n", WCN_COMBO_LOADER_CHIP_ID_PROP, chipidStr, iRet, errno);
			}
			else
			{
				ALOGI("set property(%s) to %s succeed.\n", WCN_COMBO_LOADER_CHIP_ID_PROP, chipidStr);
			}
			if(0 == noextChip)
			{
				autokRet = ioctl(gLoaderFd,COMBO_IOCTL_DO_SDIO_AUDOK,chipId);
				if (0 != autokRet)
				{
					ALOGI("do SDIO3.0 autok failed\n");
				}
				else
				{
					ALOGI("do SDIO3.0 autok succeed\n");
				}
			}
			iRet = ioctl(gLoaderFd,COMBO_IOCTL_EXT_CHIP_PWR_OFF);
			if (0 != iRet)
			{
				ALOGI("external combo chip power off failed\n");
			}
			else
			{
				ALOGI("external combo chip power off succeed\n");
			}
			if ((0 == noextChip) && (-1 == chipId))
			{
			    /*extenral chip detected, but no valid chipId detected, retry*/
			    retryCounter--;
			    usleep(500000);
			    ALOGI("chipId detect failed, retrying, left retryCounter:%d\n", retryCounter);
			}
			else
			    break;
		}while (0 < retryCounter);
	}

	/*set chipid to kernel*/
	ioctl(gLoaderFd,COMBO_IOCTL_SET_CHIP_ID,chipId);

	if (g_remove_ko_flag)
	{
		if((0x0321 == chipId) || (0x0335 == chipId) || (0x0337 == chipId))
		{
			chipId = 0x6735;
		}
		do_kernel_module_init(gLoaderFd, chipId);
		if(gLoaderFd >= 0)
		{
			close(gLoaderFd);
			gLoaderFd = -1;
		}

	}
	else
	{
		if(gLoaderFd >= 0)
		{
			close(gLoaderFd);
			gLoaderFd = -1;
		}
		ALOGI("rmmod mtk_wmt_detect\n");
		rmmod("mtk_wmt_detect");

		/*INSERT TARGET MODULE TO KERNEL*/

		iRet = insert_wmt_modules(chipId, 0, -1);
		/*this process should never fail*/
		if(iRet)
		{
			ALOGI("insert wmt modules fail(%d):(%d)\n",iRet,__LINE__);
			/*goto done;*/
		}


		loadFmResult = load_fm_module(chipId);
		if(loadFmResult)
		{
			ALOGI("load FM modules fail(%d):(%d)\n",iRet,__LINE__);
			/*continue, we cannot let this process interrupted by subsystem module load fail*/
			/*goto done;*/
		}

		loadAntResult = load_ant_module(chipId);
		if(loadAntResult)
		{
			ALOGI("load ANT modules fail(%d):(%d)\n",iRet,__LINE__);
			/*continue, we cannot let this process interrupted by subsystem module load fail*/
			/*goto done;*/
		}

		loadWlanResult = load_wifi_module(chipId);
		if(loadWlanResult)
		{
			ALOGI("load WIFI modules fail(%d):(%d)\n",iRet,__LINE__);
			/*continue, we cannot let this process interrupted by subsystem module load fail*/
			/*goto done;*/
		}
	}



	if((chown("/proc/driver/wmt_dbg",AID_SHELL,AID_SYSTEM) == -1) || (chown("/proc/driver/wmt_aee",AID_SHELL,AID_SYSTEM) == -1))
	{
		ALOGI("chown wmt_dbg or wmt_aee fail:%s\n",strerror(errno));
	}

	if(chown("/proc/wmt_tm/wmt_tm",0,1000) == -1)
	{
		ALOGI("chown wmt_tm fail:%s\n",strerror(errno));
	}
	if (0/*0x6630 == chipId*/)
	{
		retryCounter = 0;
		int i_ret = -1;
		do {
			i_ret = loader_wmt_pwr_ctrl(1);
			if (0 == i_ret)
				break;
			else
			{
				loader_wmt_pwr_ctrl(0);
				ALOGI("power on %x failed, retrying, retry counter:%d\n", chipId, retryCounter);
				usleep(1000000);
			}
			retryCounter++;
		} while (retryCounter < 20);
	}
#if 0
	while (loadWlanResult || loadFmResult)
	{
		if(loadFmResult)
		{
			static int retryCounter = 0;
			retryCounter++;
			ALOGI("retry loading fm module, retryCounter:%d\n", retryCounter);
			loadFmResult = load_fm_module(chipId);
		}

		if(loadWlanResult)
		{
			static int retryCounter = 0;
			retryCounter++;
			ALOGI("retry loading wlan module, retryCounter:%d\n", retryCounter);
			loadWlanResult = load_wifi_module(chipId);
		}
		usleep(1000000);
	}
#endif

	return iRet;
}