diff options
author | André Fabian Silva Delgado <emulatorman@parabola.nu> | 2016-06-10 05:30:17 -0300 |
---|---|---|
committer | André Fabian Silva Delgado <emulatorman@parabola.nu> | 2016-06-10 05:30:17 -0300 |
commit | d635711daa98be86d4c7fd01499c34f566b54ccb (patch) | |
tree | aa5cc3760a27c3d57146498cb82fa549547de06c /drivers/staging/wilc1000/wilc_wlan_cfg.c | |
parent | c91265cd0efb83778f015b4d4b1129bd2cfd075e (diff) |
Linux-libre 4.6.2-gnu
Diffstat (limited to 'drivers/staging/wilc1000/wilc_wlan_cfg.c')
-rw-r--r-- | drivers/staging/wilc1000/wilc_wlan_cfg.c | 91 |
1 files changed, 44 insertions, 47 deletions
diff --git a/drivers/staging/wilc1000/wilc_wlan_cfg.c b/drivers/staging/wilc1000/wilc_wlan_cfg.c index b72c77bb3..b3425b9ce 100644 --- a/drivers/staging/wilc1000/wilc_wlan_cfg.c +++ b/drivers/staging/wilc1000/wilc_wlan_cfg.c @@ -18,10 +18,15 @@ * Global Data * ********************************************/ +enum cfg_cmd_type { + CFG_BYTE_CMD = 0, + CFG_HWORD_CMD = 1, + CFG_WORD_CMD = 2, + CFG_STR_CMD = 3, + CFG_BIN_CMD = 4 +}; -typedef struct { - wilc_debug_func dPrint; - +struct wilc_mac_cfg { int mac_status; u8 mac_address[7]; u8 ip_address[5]; @@ -31,7 +36,7 @@ typedef struct { u8 supp_rate[24]; u8 wep_key[28]; u8 i_psk[66]; - u8 hardwareProductVersion[33]; + u8 hw_product_version[33]; u8 phyversion[17]; u8 supp_username[21]; u8 supp_password[64]; @@ -40,11 +45,11 @@ typedef struct { u8 firmware_info[8]; u8 scan_result[256]; u8 scan_result1[256]; -} wilc_mac_cfg_t; +}; -static wilc_mac_cfg_t g_mac; +static struct wilc_mac_cfg g_mac; -static wilc_cfg_byte_t g_cfg_byte[] = { +static struct wilc_cfg_byte g_cfg_byte[] = { {WID_BSS_TYPE, 0}, {WID_CURRENT_TX_RATE, 0}, {WID_CURRENT_CHANNEL, 0}, @@ -87,7 +92,7 @@ static wilc_cfg_byte_t g_cfg_byte[] = { {WID_NIL, 0} }; -static wilc_cfg_hword_t g_cfg_hword[] = { +static struct wilc_cfg_hword g_cfg_hword[] = { {WID_LINK_LOSS_THRESHOLD, 0}, {WID_RTS_THRESHOLD, 0}, {WID_FRAG_THRESHOLD, 0}, @@ -108,7 +113,7 @@ static wilc_cfg_hword_t g_cfg_hword[] = { {WID_NIL, 0} }; -static wilc_cfg_word_t g_cfg_word[] = { +static struct wilc_cfg_word g_cfg_word[] = { {WID_FAILED_COUNT, 0}, {WID_RETRY_COUNT, 0}, {WID_MULTIPLE_RETRY_COUNT, 0}, @@ -131,25 +136,22 @@ static wilc_cfg_word_t g_cfg_word[] = { }; -static wilc_cfg_str_t g_cfg_str[] = { +static struct wilc_cfg_str g_cfg_str[] = { {WID_SSID, g_mac.ssid}, /* 33 + 1 bytes */ {WID_FIRMWARE_VERSION, g_mac.firmware_version}, {WID_OPERATIONAL_RATE_SET, g_mac.supp_rate}, {WID_BSSID, g_mac.bssid}, /* 6 bytes */ {WID_WEP_KEY_VALUE, g_mac.wep_key}, /* 27 bytes */ {WID_11I_PSK, g_mac.i_psk}, /* 65 bytes */ - /* {WID_11E_P_ACTION_REQ, g_mac.action_req}, */ - {WID_HARDWARE_VERSION, g_mac.hardwareProductVersion}, + {WID_HARDWARE_VERSION, g_mac.hw_product_version}, {WID_MAC_ADDR, g_mac.mac_address}, {WID_PHY_VERSION, g_mac.phyversion}, {WID_SUPP_USERNAME, g_mac.supp_username}, {WID_SUPP_PASSWORD, g_mac.supp_password}, {WID_SITE_SURVEY_RESULTS, g_mac.scan_result}, {WID_SITE_SURVEY_RESULTS, g_mac.scan_result1}, - /* {WID_RX_POWER_LEVEL, g_mac.channel_rssi}, */ {WID_ASSOC_REQ_INFO, g_mac.assoc_req}, {WID_ASSOC_RES_INFO, g_mac.assoc_rsp}, - /* {WID_11N_P_ACTION_REQ, g_mac.action_req}, */ {WID_FIRMWARE_INFO, g_mac.firmware_version}, {WID_IP_ADDRESS, g_mac.ip_address}, {WID_NIL, NULL} @@ -270,13 +272,12 @@ static int wilc_wlan_cfg_set_bin(u8 *frame, u32 offset, u16 id, u8 *b, u32 size) static void wilc_wlan_parse_response_frame(u8 *info, int size) { u32 wid, len = 0, i = 0; - static int seq; while (size > 0) { i = 0; wid = info[0] | (info[1] << 8); wid = cpu_to_le32(wid); - PRINT_INFO(GENERIC_DBG, "Processing response for %d seq %d\n", wid, seq++); + switch ((wid >> 12) & 0x7) { case WID_CHAR: do { @@ -329,10 +330,6 @@ static void wilc_wlan_parse_response_frame(u8 *info, int size) if (wid == WID_SITE_SURVEY_RESULTS) { static int toggle; - PRINT_INFO(GENERIC_DBG, "Site survey results received[%d]\n", - size); - - PRINT_INFO(GENERIC_DBG, "Site survey results value[%d]toggle[%d]\n", size, toggle); i += toggle; toggle ^= 1; } @@ -354,14 +351,14 @@ static void wilc_wlan_parse_response_frame(u8 *info, int size) static int wilc_wlan_parse_info_frame(u8 *info, int size) { - wilc_mac_cfg_t *pd = &g_mac; + struct wilc_mac_cfg *pd = &g_mac; u32 wid, len; int type = WILC_CFG_RSP_STATUS; wid = info[0] | (info[1] << 8); len = info[2]; - PRINT_INFO(GENERIC_DBG, "Status Len = %d Id= %d\n", len, wid); + if ((len == 1) && (wid == WID_STATUS)) { pd->mac_status = info[3]; type = WILC_CFG_RSP_STATUS; @@ -381,21 +378,31 @@ int wilc_wlan_cfg_set_wid(u8 *frame, u32 offset, u16 id, u8 *buf, int size) u8 type = (id >> 12) & 0xf; int ret = 0; - if (type == 0) { /* byte command */ + switch (type) { + case CFG_BYTE_CMD: if (size >= 1) ret = wilc_wlan_cfg_set_byte(frame, offset, id, *buf); - } else if (type == 1) { /* half word command */ + break; + + case CFG_HWORD_CMD: if (size >= 2) - ret = wilc_wlan_cfg_set_hword(frame, offset, id, *((u16 *)buf)); - } else if (type == 2) { /* word command */ + ret = wilc_wlan_cfg_set_hword(frame, offset, id, + *((u16 *)buf)); + break; + + case CFG_WORD_CMD: if (size >= 4) - ret = wilc_wlan_cfg_set_word(frame, offset, id, *((u32 *)buf)); - } else if (type == 3) { /* string command */ + ret = wilc_wlan_cfg_set_word(frame, offset, id, + *((u32 *)buf)); + break; + + case CFG_STR_CMD: ret = wilc_wlan_cfg_set_str(frame, offset, id, buf, size); - } else if (type == 4) { /* binary command */ + break; + + case CFG_BIN_CMD: ret = wilc_wlan_cfg_set_bin(frame, offset, id, buf, size); - } else { - g_mac.dPrint(N_ERR, "illegal id\n"); + break; } return ret; @@ -427,7 +434,7 @@ int wilc_wlan_cfg_get_wid_value(u16 wid, u8 *buffer, u32 buffer_size) } i = 0; - if (type == 0) { /* byte command */ + if (type == CFG_BYTE_CMD) { do { if (g_cfg_byte[i].id == WID_NIL) break; @@ -439,7 +446,7 @@ int wilc_wlan_cfg_get_wid_value(u16 wid, u8 *buffer, u32 buffer_size) } i++; } while (1); - } else if (type == 1) { /* half word command */ + } else if (type == CFG_HWORD_CMD) { do { if (g_cfg_hword[i].id == WID_NIL) break; @@ -451,7 +458,7 @@ int wilc_wlan_cfg_get_wid_value(u16 wid, u8 *buffer, u32 buffer_size) } i++; } while (1); - } else if (type == 2) { /* word command */ + } else if (type == CFG_WORD_CMD) { do { if (g_cfg_word[i].id == WID_NIL) break; @@ -463,7 +470,7 @@ int wilc_wlan_cfg_get_wid_value(u16 wid, u8 *buffer, u32 buffer_size) } i++; } while (1); - } else if (type == 3) { /* string command */ + } else if (type == CFG_STR_CMD) { do { if (g_cfg_str[i].id == WID_NIL) break; @@ -475,8 +482,6 @@ int wilc_wlan_cfg_get_wid_value(u16 wid, u8 *buffer, u32 buffer_size) if (g_cfg_str[i].id == WID_SITE_SURVEY_RESULTS) { static int toggle; - PRINT_INFO(GENERIC_DBG, "Site survey results value[%d]\n", - size); i += toggle; toggle ^= 1; @@ -488,8 +493,6 @@ int wilc_wlan_cfg_get_wid_value(u16 wid, u8 *buffer, u32 buffer_size) } i++; } while (1); - } else { - g_mac.dPrint(N_ERR, "[CFG]: illegal type (%08x)\n", wid); } return ret; @@ -522,7 +525,6 @@ int wilc_wlan_cfg_indicate_rx(struct wilc *wilc, u8 *frame, int size, rsp->type = wilc_wlan_parse_info_frame(frame, size); rsp->seq_no = msg_id; /*call host interface info parse as well*/ - PRINT_INFO(RX_DBG, "Info message received\n"); wilc_gnrl_async_info_received(wilc, frame - 4, size + 4); break; @@ -532,14 +534,10 @@ int wilc_wlan_cfg_indicate_rx(struct wilc *wilc, u8 *frame, int size, break; case 'S': - PRINT_INFO(RX_DBG, "Scan Notification Received\n"); wilc_scan_complete_received(wilc, frame - 4, size + 4); break; default: - PRINT_INFO(RX_DBG, "Receive unknown message type[%d-%d-%d-%d-%d-%d-%d-%d]\n", - frame[0], frame[1], frame[2], frame[3], frame[4], - frame[5], frame[6], frame[7]); rsp->type = 0; rsp->seq_no = msg_id; ret = 0; @@ -549,9 +547,8 @@ int wilc_wlan_cfg_indicate_rx(struct wilc *wilc, u8 *frame, int size, return ret; } -int wilc_wlan_cfg_init(wilc_debug_func func) +int wilc_wlan_cfg_init(void) { - memset((void *)&g_mac, 0, sizeof(wilc_mac_cfg_t)); - g_mac.dPrint = func; + memset((void *)&g_mac, 0, sizeof(struct wilc_mac_cfg)); return 1; } |