The module name and path can be obtained by the properties
wlan.modname and wlan.modpath.
#define WIFI_DRIVER_LOADER_DELAY 1000000
static const char IFACE_DIR[] = "/data/system/wpa_supplicant";
#define WIFI_DRIVER_LOADER_DELAY 1000000
static const char IFACE_DIR[] = "/data/system/wpa_supplicant";
-static const char DRIVER_MODULE_NAME[] = WIFI_DRIVER_MODULE_NAME;
-static const char DRIVER_MODULE_TAG[] = WIFI_DRIVER_MODULE_NAME " ";
-static const char DRIVER_MODULE_PATH[] = WIFI_DRIVER_MODULE_PATH;
static const char DRIVER_MODULE_ARG[] = WIFI_DRIVER_MODULE_ARG;
static const char FIRMWARE_LOADER[] = WIFI_FIRMWARE_LOADER;
static const char DRIVER_PROP_NAME[] = "wlan.driver.status";
static const char DRIVER_MODULE_ARG[] = WIFI_DRIVER_MODULE_ARG;
static const char FIRMWARE_LOADER[] = WIFI_FIRMWARE_LOADER;
static const char DRIVER_PROP_NAME[] = "wlan.driver.status";
+static const char DRIVER_NAME_PROP[] = "wlan.modname";
+static const char DRIVER_PATH_PROP[] = "wlan.modpath";
static const char SUPPLICANT_NAME[] = "wpa_supplicant";
static const char SUPP_PROP_NAME[] = "init.svc.wpa_supplicant";
static const char SUPP_CONFIG_TEMPLATE[]= "/system/etc/wifi/wpa_supplicant.conf";
static const char SUPPLICANT_NAME[] = "wpa_supplicant";
static const char SUPP_PROP_NAME[] = "init.svc.wpa_supplicant";
static const char SUPP_CONFIG_TEMPLATE[]= "/system/etc/wifi/wpa_supplicant.conf";
}
static int check_driver_loaded() {
}
static int check_driver_loaded() {
- char driver_status[PROPERTY_VALUE_MAX];
+ char modname[PROPERTY_VALUE_MAX];
+ char line[PROPERTY_VALUE_MAX];
- char line[sizeof(DRIVER_MODULE_TAG)+10];
+ int cnt = property_get(DRIVER_NAME_PROP, modname, WIFI_DRIVER_MODULE_NAME);
+
+ if (cnt > 0)
+ modname[cnt++] = ' ';
+ else
+ goto unloaded;
- if (!property_get(DRIVER_PROP_NAME, driver_status, NULL)
- || strcmp(driver_status, "ok") != 0) {
- return 0; /* driver not loaded */
- }
/*
* If the property says the driver is loaded, check to
* make sure that the property setting isn't just left
/*
* If the property says the driver is loaded, check to
* make sure that the property setting isn't just left
*/
if ((proc = fopen(MODULE_FILE, "r")) == NULL) {
LOGW("Could not open %s: %s", MODULE_FILE, strerror(errno));
*/
if ((proc = fopen(MODULE_FILE, "r")) == NULL) {
LOGW("Could not open %s: %s", MODULE_FILE, strerror(errno));
- property_set(DRIVER_PROP_NAME, "unloaded");
- return 0;
while ((fgets(line, sizeof(line), proc)) != NULL) {
while ((fgets(line, sizeof(line), proc)) != NULL) {
- if (strncmp(line, DRIVER_MODULE_TAG, strlen(DRIVER_MODULE_TAG)) == 0) {
+ if (strncmp(line, modname, cnt) == 0) {
fclose(proc);
return 1;
}
}
fclose(proc);
fclose(proc);
return 1;
}
}
fclose(proc);
property_set(DRIVER_PROP_NAME, "unloaded");
return 0;
}
property_set(DRIVER_PROP_NAME, "unloaded");
return 0;
}
- if (insmod(DRIVER_MODULE_PATH, DRIVER_MODULE_ARG) < 0)
+ if (!property_get(DRIVER_PATH_PROP, driver_status, WIFI_DRIVER_MODULE_PATH))
+ return -1;
+
+ if (insmod(driver_status, DRIVER_MODULE_ARG) < 0)
return -1;
if (strcmp(FIRMWARE_LOADER,"") == 0) {
return -1;
if (strcmp(FIRMWARE_LOADER,"") == 0) {
int wifi_unload_driver()
{
int count = 20; /* wait at most 10 seconds for completion */
int wifi_unload_driver()
{
int count = 20; /* wait at most 10 seconds for completion */
+ char modname[PROPERTY_VALUE_MAX];
+
+ if (!property_get(DRIVER_NAME_PROP, modname, WIFI_DRIVER_MODULE_NAME))
+ return -1;
- if (rmmod(DRIVER_MODULE_NAME) == 0) {
+ if (rmmod(modname) == 0) {
while (count-- > 0) {
if (!check_driver_loaded())
break;
while (count-- > 0) {
if (!check_driver_loaded())
break;
- return -1;
- } else
- return -1;
}
int ensure_config_file_exists()
}
int ensure_config_file_exists()