summaryrefslogtreecommitdiffstats
path: root/libwifi_hal
diff options
context:
space:
mode:
authorChristopher Wiley <wiley@google.com>2016-09-09 13:39:40 -0700
committerChristopher Wiley <wiley@google.com>2016-09-09 15:56:36 -0700
commitaf52902e4746aab2bd667ac9bdeb1bbb3e46b539 (patch)
treeed9f00ac30d6ce2e042d4877559d14eed164cc65 /libwifi_hal
parentf41e52f5ad89310d867a00c12f2cf146703ad574 (diff)
downloadandroid_frameworks_opt_net_wifi-af52902e4746aab2bd667ac9bdeb1bbb3e46b539.tar.gz
android_frameworks_opt_net_wifi-af52902e4746aab2bd667ac9bdeb1bbb3e46b539.tar.bz2
android_frameworks_opt_net_wifi-af52902e4746aab2bd667ac9bdeb1bbb3e46b539.zip
Run clang-format against libwifi_hal .cpp files
Ran clang-format -style=google -i \ wifi_hal_common.cpp \ wifi_hal_fallback.cpp Test: Compiles Change-Id: I5bebc0dfd44ef4a77c3c120f952912c73d9b032a
Diffstat (limited to 'libwifi_hal')
-rw-r--r--libwifi_hal/wifi_hal_common.cpp284
-rw-r--r--libwifi_hal/wifi_hal_fallback.cpp2
2 files changed, 136 insertions, 150 deletions
diff --git a/libwifi_hal/wifi_hal_common.cpp b/libwifi_hal/wifi_hal_common.cpp
index f207eb786..459fdf515 100644
--- a/libwifi_hal/wifi_hal_common.cpp
+++ b/libwifi_hal/wifi_hal_common.cpp
@@ -30,208 +30,194 @@ extern "C" int init_module(void *, unsigned long, const char *);
extern "C" int delete_module(const char *, unsigned int);
#ifndef WIFI_DRIVER_FW_PATH_STA
-#define WIFI_DRIVER_FW_PATH_STA NULL
+#define WIFI_DRIVER_FW_PATH_STA NULL
#endif
#ifndef WIFI_DRIVER_FW_PATH_AP
-#define WIFI_DRIVER_FW_PATH_AP NULL
+#define WIFI_DRIVER_FW_PATH_AP NULL
#endif
#ifndef WIFI_DRIVER_FW_PATH_P2P
-#define WIFI_DRIVER_FW_PATH_P2P NULL
+#define WIFI_DRIVER_FW_PATH_P2P NULL
#endif
#ifndef WIFI_DRIVER_MODULE_ARG
-#define WIFI_DRIVER_MODULE_ARG ""
+#define WIFI_DRIVER_MODULE_ARG ""
#endif
-static const char DRIVER_PROP_NAME[] = "wlan.driver.status";
+static const char DRIVER_PROP_NAME[] = "wlan.driver.status";
#ifdef WIFI_DRIVER_MODULE_PATH
-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 MODULE_FILE[] = "/proc/modules";
+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 MODULE_FILE[] = "/proc/modules";
#endif
-static int insmod(const char *filename, const char *args)
-{
- void *module;
- unsigned int size;
- int ret;
+static int insmod(const char *filename, const char *args) {
+ void *module;
+ unsigned int size;
+ int ret;
- module = load_file(filename, &size);
- if (!module)
- return -1;
+ module = load_file(filename, &size);
+ if (!module) return -1;
- ret = init_module(module, size, args);
+ ret = init_module(module, size, args);
- free(module);
+ free(module);
- return ret;
+ return ret;
}
-static int rmmod(const char *modname)
-{
- int ret = -1;
- int maxtry = 10;
-
- while (maxtry-- > 0) {
- ret = delete_module(modname, O_NONBLOCK | O_EXCL);
- if (ret < 0 && errno == EAGAIN)
- usleep(500000);
- else
- break;
- }
-
- if (ret != 0)
- ALOGD("Unable to unload driver module \"%s\": %s\n",
- modname, strerror(errno));
- return ret;
+static int rmmod(const char *modname) {
+ int ret = -1;
+ int maxtry = 10;
+
+ while (maxtry-- > 0) {
+ ret = delete_module(modname, O_NONBLOCK | O_EXCL);
+ if (ret < 0 && errno == EAGAIN)
+ usleep(500000);
+ else
+ break;
+ }
+
+ if (ret != 0)
+ ALOGD("Unable to unload driver module \"%s\": %s\n", modname,
+ strerror(errno));
+ return ret;
}
#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;
+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];
+ char driver_status[PROPERTY_VALUE_MAX];
#ifdef WIFI_DRIVER_MODULE_PATH
- FILE *proc;
- char line[sizeof(DRIVER_MODULE_TAG)+10];
+ FILE *proc;
+ char line[sizeof(DRIVER_MODULE_TAG) + 10];
#endif
- if (!property_get(DRIVER_PROP_NAME, driver_status, NULL)
- || strcmp(driver_status, "ok") != 0) {
- return 0; /* driver not loaded */
- }
+ if (!property_get(DRIVER_PROP_NAME, driver_status, NULL) ||
+ strcmp(driver_status, "ok") != 0) {
+ return 0; /* driver not loaded */
+ }
#ifdef WIFI_DRIVER_MODULE_PATH
- /*
- * If the property says the driver is loaded, check to
- * make sure that the property setting isn't just left
- * over from a previous manual shutdown or a runtime
- * crash.
- */
- if ((proc = fopen(MODULE_FILE, "r")) == NULL) {
- ALOGW("Could not open %s: %s", MODULE_FILE, strerror(errno));
- property_set(DRIVER_PROP_NAME, "unloaded");
- return 0;
- }
- while ((fgets(line, sizeof(line), proc)) != NULL) {
- if (strncmp(line, DRIVER_MODULE_TAG, strlen(DRIVER_MODULE_TAG)) == 0) {
- fclose(proc);
- return 1;
- }
- }
- fclose(proc);
+ /*
+ * If the property says the driver is loaded, check to
+ * make sure that the property setting isn't just left
+ * over from a previous manual shutdown or a runtime
+ * crash.
+ */
+ if ((proc = fopen(MODULE_FILE, "r")) == NULL) {
+ ALOGW("Could not open %s: %s", MODULE_FILE, strerror(errno));
property_set(DRIVER_PROP_NAME, "unloaded");
return 0;
+ }
+ while ((fgets(line, sizeof(line), proc)) != NULL) {
+ if (strncmp(line, DRIVER_MODULE_TAG, strlen(DRIVER_MODULE_TAG)) == 0) {
+ fclose(proc);
+ return 1;
+ }
+ }
+ fclose(proc);
+ property_set(DRIVER_PROP_NAME, "unloaded");
+ return 0;
#else
- return 1;
+ return 1;
#endif
}
-int wifi_load_driver()
-{
+int wifi_load_driver() {
#ifdef WIFI_DRIVER_MODULE_PATH
- if (is_wifi_driver_loaded()) {
- return 0;
- }
+ if (is_wifi_driver_loaded()) {
+ return 0;
+ }
- if (insmod(DRIVER_MODULE_PATH, DRIVER_MODULE_ARG) < 0)
- return -1;
+ if (insmod(DRIVER_MODULE_PATH, DRIVER_MODULE_ARG) < 0) return -1;
#elif defined WIFI_DRIVER_STATE_CTRL_PARAM
- if (is_wifi_driver_loaded()) {
- return 0;
- }
+ if (is_wifi_driver_loaded()) {
+ return 0;
+ }
- if (wifi_change_driver_state(WIFI_DRIVER_STATE_ON) < 0)
- return -1;
+ if (wifi_change_driver_state(WIFI_DRIVER_STATE_ON) < 0) return -1;
#endif
- property_set(DRIVER_PROP_NAME, "ok");
- return 0;
+ property_set(DRIVER_PROP_NAME, "ok");
+ return 0;
}
-int wifi_unload_driver()
-{
- usleep(200000); /* allow to finish interface down */
+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) {
- return 0;
- }
- return -1;
- } else
- return -1;
+ 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) {
+ return 0;
+ }
+ return -1;
+ } 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;
- }
+ 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;
+ property_set(DRIVER_PROP_NAME, "unloaded");
+ return 0;
#endif
}
-const char *wifi_get_fw_path(int fw_type)
-{
- switch (fw_type) {
+const char *wifi_get_fw_path(int fw_type) {
+ switch (fw_type) {
case WIFI_GET_FW_PATH_STA:
- return WIFI_DRIVER_FW_PATH_STA;
+ return WIFI_DRIVER_FW_PATH_STA;
case WIFI_GET_FW_PATH_AP:
- return WIFI_DRIVER_FW_PATH_AP;
+ return WIFI_DRIVER_FW_PATH_AP;
case WIFI_GET_FW_PATH_P2P:
- return WIFI_DRIVER_FW_PATH_P2P;
- }
- return NULL;
+ return WIFI_DRIVER_FW_PATH_P2P;
+ }
+ return NULL;
}
-int wifi_change_fw_path(const char *fwpath)
-{
- int len;
- int fd;
- int ret = 0;
-
- if (!fwpath)
- return ret;
- fd = TEMP_FAILURE_RETRY(open(WIFI_DRIVER_FW_PATH_PARAM, O_WRONLY));
- if (fd < 0) {
- ALOGE("Failed to open wlan fw path param (%s)", strerror(errno));
- return -1;
- }
- len = strlen(fwpath) + 1;
- if (TEMP_FAILURE_RETRY(write(fd, fwpath, len)) != len) {
- ALOGE("Failed to write wlan fw path param (%s)", strerror(errno));
- ret = -1;
- }
- close(fd);
- return ret;
+int wifi_change_fw_path(const char *fwpath) {
+ int len;
+ int fd;
+ int ret = 0;
+
+ if (!fwpath) return ret;
+ fd = TEMP_FAILURE_RETRY(open(WIFI_DRIVER_FW_PATH_PARAM, O_WRONLY));
+ if (fd < 0) {
+ ALOGE("Failed to open wlan fw path param (%s)", strerror(errno));
+ return -1;
+ }
+ len = strlen(fwpath) + 1;
+ if (TEMP_FAILURE_RETRY(write(fd, fwpath, len)) != len) {
+ ALOGE("Failed to write wlan fw path param (%s)", strerror(errno));
+ ret = -1;
+ }
+ close(fd);
+ return ret;
}
diff --git a/libwifi_hal/wifi_hal_fallback.cpp b/libwifi_hal/wifi_hal_fallback.cpp
index 64259a11d..fd0fff4f3 100644
--- a/libwifi_hal/wifi_hal_fallback.cpp
+++ b/libwifi_hal/wifi_hal_fallback.cpp
@@ -17,5 +17,5 @@
#include "hardware_legacy/wifi_hal.h"
wifi_error init_wifi_vendor_hal_func_table(wifi_hal_fn *fn) {
- return WIFI_ERROR_NOT_SUPPORTED;
+ return WIFI_ERROR_NOT_SUPPORTED;
}