From 04613b88e884eaaa1a567a1d834c876dda99606e Mon Sep 17 00:00:00 2001 From: Steve Kondik Date: Tue, 4 Dec 2012 19:20:43 +0100 Subject: wifi: Choose correct nvram file on samsung hardware Change-Id: I9d428ae61c1ce80d97e6ea513839ed64e8f61440 --- wifi/Android.mk | 4 ++++ wifi/wifi.c | 42 ++++++++++++++++++++++++++++++++++++++---- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/wifi/Android.mk b/wifi/Android.mk index b4a6a7c..d9225bd 100644 --- a/wifi/Android.mk +++ b/wifi/Android.mk @@ -30,4 +30,8 @@ endif LOCAL_SRC_FILES += wifi/wifi.c +ifeq ($(BOARD_HAVE_SAMSUNG_WIFI),true) +LOCAL_CFLAGS += -DSAMSUNG_WIFI +endif + LOCAL_SHARED_LIBRARIES += libnetutils diff --git a/wifi/wifi.c b/wifi/wifi.c index d62b30f..5ed195a 100644 --- a/wifi/wifi.c +++ b/wifi/wifi.c @@ -129,6 +129,31 @@ static int is_primary_interface(const char *ifname) return 0; } +#ifdef SAMSUNG_WIFI +char* get_samsung_wifi_type() +{ + char buf[10]; + int fd = open("/data/.cid.info", O_RDONLY); + if (fd < 0) + return NULL; + + if (read(fd, buf, sizeof(buf)) < 0) { + close(fd); + return NULL; + } + + close(fd); + + if (strncmp(buf, "murata", 6) == 0) + return "_murata"; + + if (strncmp(buf, "semcove", 7) == 0) + return "_semcove"; + + return NULL; +} +#endif + static int insmod(const char *filename, const char *args) { void *module; @@ -229,13 +254,22 @@ int wifi_load_driver() #ifdef WIFI_DRIVER_MODULE_PATH char driver_status[PROPERTY_VALUE_MAX]; int count = 100; /* wait at most 20 seconds for completion */ + char module_arg2[256]; - if (is_wifi_driver_loaded()) { - return 0; - } +#ifdef SAMSUNG_WIFI + char* type = get_samsung_wifi_type(); + snprintf(module_arg2, sizeof(module_arg2), "%s%s", DRIVER_MODULE_ARG, type == NULL ? "" : type); - if (insmod(DRIVER_MODULE_PATH, DRIVER_MODULE_ARG) < 0) + if (insmod(DRIVER_MODULE_PATH, module_arg2) < 0) { +#else + if (insmod(DRIVER_MODULE_PATH, DRIVER_MODULE_ARG) < 0) { +#endif + +#ifdef WIFI_EXT_MODULE_NAME + rmmod(EXT_MODULE_NAME); +#endif return -1; + } if (strcmp(FIRMWARE_LOADER,"") == 0) { /* usleep(WIFI_DRIVER_LOADER_DELAY); */ -- cgit v1.1