diff options
author | Luciano Coelho <luciano.coelho@nokia.com> | 2009-10-15 03:33:29 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-10-27 16:48:19 -0400 |
commit | d0f63b202146f3281800ee44823740c8bbf38f11 (patch) | |
tree | e6cfd9e31039674135c5727cc192b3d4270a457d /drivers/net/wireless/wl12xx/wl1271_cmd.c | |
parent | 0b5b72da1b21fe61926318dd842f6dd7c8862e9f (diff) |
wl1271: fix endianess issues
We were not handling endianess correctly. The wl1271 chip runs on
little-endian values. This patch makes sure that all the communication with
the wl1271 firmware is done in little-endian by using cpu_to_le* and
le*_to_cpu where appropriate.
Also, all the struct definitions for data exchanged with the firmware has
been changed to use __le16/32 types instead of u16/32.
This fixes a few sparse warnings, such as these:
drivers/net/wireless/wl12xx/wl1271_cmd.c:554:42: warning: incorrect type in assignment (different base types)
drivers/net/wireless/wl12xx/wl1271_cmd.c:555:42: warning: incorrect type in assignment (different base types)
drivers/net/wireless/wl12xx/wl1271_cmd.c:577:58: warning: incorrect type in assignment (different base types)
drivers/net/wireless/wl12xx/wl1271_cmd.c:579:58: warning: incorrect type in assignment (different base types)
drivers/net/wireless/wl12xx/wl1271_cmd.c:676:18: warning: incorrect type in assignment (different base types)
drivers/net/wireless/wl12xx/wl1271_cmd.c:787:22: warning: incorrect type in assignment (different base types)
drivers/net/wireless/wl12xx/wl1271_cmd.c:789:21: warning: incorrect type in assignment (different base types)
drivers/net/wireless/wl12xx/wl1271_tx.c:98:47: warning: incorrect type in argument 1 (different base types)
drivers/net/wireless/wl12xx/wl1271_acx.c:932:32: warning: incorrect type in assignment (different base types)
drivers/net/wireless/wl12xx/wl1271_boot.c:191:32: warning: incorrect type in argument 1 (different base types)
drivers/net/wireless/wl12xx/wl1271_boot.c:197:38: warning: incorrect type in argument 1 (different base types)
drivers/net/wireless/wl12xx/wl1271_boot.c:199:37: warning: incorrect type in argument 1 (different base types)
drivers/net/wireless/wl12xx/wl1271_init.c:255:40: warning: incorrect type in assignment (different base types)
drivers/net/wireless/wl12xx/wl1271_init.c:275:53: warning: incorrect type in assignment (different base types)
Reported-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Luciano Coelho <luciano.coelho@nokia.com>
Reviewed-by: Juuso Oikarinen <juuso.oikarinen@nokia.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/wl12xx/wl1271_cmd.c')
-rw-r--r-- | drivers/net/wireless/wl12xx/wl1271_cmd.c | 74 |
1 files changed, 38 insertions, 36 deletions
diff --git a/drivers/net/wireless/wl12xx/wl1271_cmd.c b/drivers/net/wireless/wl12xx/wl1271_cmd.c index 195eee70e36e..0666328ce9ab 100644 --- a/drivers/net/wireless/wl12xx/wl1271_cmd.c +++ b/drivers/net/wireless/wl12xx/wl1271_cmd.c | |||
@@ -50,7 +50,7 @@ int wl1271_cmd_send(struct wl1271 *wl, u16 id, void *buf, size_t len) | |||
50 | int ret = 0; | 50 | int ret = 0; |
51 | 51 | ||
52 | cmd = buf; | 52 | cmd = buf; |
53 | cmd->id = id; | 53 | cmd->id = cpu_to_le16(id); |
54 | cmd->status = 0; | 54 | cmd->status = 0; |
55 | 55 | ||
56 | WARN_ON(len % 4 != 0); | 56 | WARN_ON(len % 4 != 0); |
@@ -217,8 +217,8 @@ int wl1271_cmd_join(struct wl1271 *wl) | |||
217 | for (i = 0; i < ETH_ALEN; i++) | 217 | for (i = 0; i < ETH_ALEN; i++) |
218 | bssid[i] = wl->bssid[ETH_ALEN - i - 1]; | 218 | bssid[i] = wl->bssid[ETH_ALEN - i - 1]; |
219 | 219 | ||
220 | join->rx_config_options = wl->rx_config; | 220 | join->rx_config_options = cpu_to_le32(wl->rx_config); |
221 | join->rx_filter_options = wl->rx_filter; | 221 | join->rx_filter_options = cpu_to_le32(wl->rx_filter); |
222 | join->bss_type = wl->bss_type; | 222 | join->bss_type = wl->bss_type; |
223 | 223 | ||
224 | /* | 224 | /* |
@@ -227,21 +227,22 @@ int wl1271_cmd_join(struct wl1271 *wl) | |||
227 | * association. The filter logic needs to be implemented properly | 227 | * association. The filter logic needs to be implemented properly |
228 | * and once that is done, this hack can be removed. | 228 | * and once that is done, this hack can be removed. |
229 | */ | 229 | */ |
230 | join->rx_config_options = 0; | 230 | join->rx_config_options = cpu_to_le32(0); |
231 | join->rx_filter_options = WL1271_DEFAULT_RX_FILTER; | 231 | join->rx_filter_options = cpu_to_le32(WL1271_DEFAULT_RX_FILTER); |
232 | 232 | ||
233 | if (wl->band == IEEE80211_BAND_2GHZ) | 233 | if (wl->band == IEEE80211_BAND_2GHZ) |
234 | join->basic_rate_set = | 234 | join->basic_rate_set = cpu_to_le32(CONF_HW_BIT_RATE_1MBPS | |
235 | CONF_HW_BIT_RATE_1MBPS | CONF_HW_BIT_RATE_2MBPS | | 235 | CONF_HW_BIT_RATE_2MBPS | |
236 | CONF_HW_BIT_RATE_5_5MBPS | CONF_HW_BIT_RATE_11MBPS; | 236 | CONF_HW_BIT_RATE_5_5MBPS | |
237 | CONF_HW_BIT_RATE_11MBPS); | ||
237 | else { | 238 | else { |
238 | join->bss_type |= WL1271_JOIN_CMD_BSS_TYPE_5GHZ; | 239 | join->bss_type |= WL1271_JOIN_CMD_BSS_TYPE_5GHZ; |
239 | join->basic_rate_set = | 240 | join->basic_rate_set = cpu_to_le32(CONF_HW_BIT_RATE_6MBPS | |
240 | CONF_HW_BIT_RATE_6MBPS | CONF_HW_BIT_RATE_12MBPS | | 241 | CONF_HW_BIT_RATE_12MBPS | |
241 | CONF_HW_BIT_RATE_24MBPS; | 242 | CONF_HW_BIT_RATE_24MBPS); |
242 | } | 243 | } |
243 | 244 | ||
244 | join->beacon_interval = WL1271_DEFAULT_BEACON_INT; | 245 | join->beacon_interval = cpu_to_le16(WL1271_DEFAULT_BEACON_INT); |
245 | join->dtim_interval = WL1271_DEFAULT_DTIM_PERIOD; | 246 | join->dtim_interval = WL1271_DEFAULT_DTIM_PERIOD; |
246 | 247 | ||
247 | join->channel = wl->channel; | 248 | join->channel = wl->channel; |
@@ -305,6 +306,7 @@ int wl1271_cmd_test(struct wl1271 *wl, void *buf, size_t buf_len, u8 answer) | |||
305 | 306 | ||
306 | if (answer) { | 307 | if (answer) { |
307 | struct wl1271_command *cmd_answer; | 308 | struct wl1271_command *cmd_answer; |
309 | u16 status; | ||
308 | 310 | ||
309 | /* | 311 | /* |
310 | * The test command got in, we can read the answer. | 312 | * The test command got in, we can read the answer. |
@@ -314,10 +316,10 @@ int wl1271_cmd_test(struct wl1271 *wl, void *buf, size_t buf_len, u8 answer) | |||
314 | wl1271_spi_read(wl, wl->cmd_box_addr, buf, buf_len, false); | 316 | wl1271_spi_read(wl, wl->cmd_box_addr, buf, buf_len, false); |
315 | 317 | ||
316 | cmd_answer = buf; | 318 | cmd_answer = buf; |
319 | status = le16_to_cpu(cmd_answer->header.status); | ||
317 | 320 | ||
318 | if (cmd_answer->header.status != CMD_STATUS_SUCCESS) | 321 | if (status != CMD_STATUS_SUCCESS) |
319 | wl1271_error("TEST command answer error: %d", | 322 | wl1271_error("TEST command answer error: %d", status); |
320 | cmd_answer->header.status); | ||
321 | } | 323 | } |
322 | 324 | ||
323 | return 0; | 325 | return 0; |
@@ -338,10 +340,10 @@ int wl1271_cmd_interrogate(struct wl1271 *wl, u16 id, void *buf, size_t len) | |||
338 | 340 | ||
339 | wl1271_debug(DEBUG_CMD, "cmd interrogate"); | 341 | wl1271_debug(DEBUG_CMD, "cmd interrogate"); |
340 | 342 | ||
341 | acx->id = id; | 343 | acx->id = cpu_to_le16(id); |
342 | 344 | ||
343 | /* payload length, does not include any headers */ | 345 | /* payload length, does not include any headers */ |
344 | acx->len = len - sizeof(*acx); | 346 | acx->len = cpu_to_le16(len - sizeof(*acx)); |
345 | 347 | ||
346 | ret = wl1271_cmd_send(wl, CMD_INTERROGATE, acx, sizeof(*acx)); | 348 | ret = wl1271_cmd_send(wl, CMD_INTERROGATE, acx, sizeof(*acx)); |
347 | if (ret < 0) { | 349 | if (ret < 0) { |
@@ -353,9 +355,9 @@ int wl1271_cmd_interrogate(struct wl1271 *wl, u16 id, void *buf, size_t len) | |||
353 | wl1271_spi_read(wl, wl->cmd_box_addr, buf, len, false); | 355 | wl1271_spi_read(wl, wl->cmd_box_addr, buf, len, false); |
354 | 356 | ||
355 | acx = buf; | 357 | acx = buf; |
356 | if (acx->cmd.status != CMD_STATUS_SUCCESS) | 358 | if (le16_to_cpu(acx->cmd.status) != CMD_STATUS_SUCCESS) |
357 | wl1271_error("INTERROGATE command error: %d", | 359 | wl1271_error("INTERROGATE command error: %d", |
358 | acx->cmd.status); | 360 | le16_to_cpu(acx->cmd.status)); |
359 | 361 | ||
360 | out: | 362 | out: |
361 | return ret; | 363 | return ret; |
@@ -376,10 +378,10 @@ int wl1271_cmd_configure(struct wl1271 *wl, u16 id, void *buf, size_t len) | |||
376 | 378 | ||
377 | wl1271_debug(DEBUG_CMD, "cmd configure"); | 379 | wl1271_debug(DEBUG_CMD, "cmd configure"); |
378 | 380 | ||
379 | acx->id = id; | 381 | acx->id = cpu_to_le16(id); |
380 | 382 | ||
381 | /* payload length, does not include any headers */ | 383 | /* payload length, does not include any headers */ |
382 | acx->len = len - sizeof(*acx); | 384 | acx->len = cpu_to_le16(len - sizeof(*acx)); |
383 | 385 | ||
384 | ret = wl1271_cmd_send(wl, CMD_CONFIGURE, acx, len); | 386 | ret = wl1271_cmd_send(wl, CMD_CONFIGURE, acx, len); |
385 | if (ret < 0) { | 387 | if (ret < 0) { |
@@ -463,7 +465,7 @@ int wl1271_cmd_ps_mode(struct wl1271 *wl, u8 ps_mode) | |||
463 | ps_params->send_null_data = 1; | 465 | ps_params->send_null_data = 1; |
464 | ps_params->retries = 5; | 466 | ps_params->retries = 5; |
465 | ps_params->hang_over_period = 128; | 467 | ps_params->hang_over_period = 128; |
466 | ps_params->null_data_rate = 1; /* 1 Mbps */ | 468 | ps_params->null_data_rate = cpu_to_le32(1); /* 1 Mbps */ |
467 | 469 | ||
468 | ret = wl1271_cmd_send(wl, CMD_SET_PS_MODE, ps_params, | 470 | ret = wl1271_cmd_send(wl, CMD_SET_PS_MODE, ps_params, |
469 | sizeof(*ps_params)); | 471 | sizeof(*ps_params)); |
@@ -494,8 +496,8 @@ int wl1271_cmd_read_memory(struct wl1271 *wl, u32 addr, void *answer, | |||
494 | WARN_ON(len > MAX_READ_SIZE); | 496 | WARN_ON(len > MAX_READ_SIZE); |
495 | len = min_t(size_t, len, MAX_READ_SIZE); | 497 | len = min_t(size_t, len, MAX_READ_SIZE); |
496 | 498 | ||
497 | cmd->addr = addr; | 499 | cmd->addr = cpu_to_le32(addr); |
498 | cmd->size = len; | 500 | cmd->size = cpu_to_le32(len); |
499 | 501 | ||
500 | ret = wl1271_cmd_send(wl, CMD_READ_MEMORY, cmd, sizeof(*cmd)); | 502 | ret = wl1271_cmd_send(wl, CMD_READ_MEMORY, cmd, sizeof(*cmd)); |
501 | if (ret < 0) { | 503 | if (ret < 0) { |
@@ -506,9 +508,9 @@ int wl1271_cmd_read_memory(struct wl1271 *wl, u32 addr, void *answer, | |||
506 | /* the read command got in, we can now read the answer */ | 508 | /* the read command got in, we can now read the answer */ |
507 | wl1271_spi_read(wl, wl->cmd_box_addr, cmd, sizeof(*cmd), false); | 509 | wl1271_spi_read(wl, wl->cmd_box_addr, cmd, sizeof(*cmd), false); |
508 | 510 | ||
509 | if (cmd->header.status != CMD_STATUS_SUCCESS) | 511 | if (le16_to_cpu(cmd->header.status) != CMD_STATUS_SUCCESS) |
510 | wl1271_error("error in read command result: %d", | 512 | wl1271_error("error in read command result: %d", |
511 | cmd->header.status); | 513 | le16_to_cpu(cmd->header.status)); |
512 | 514 | ||
513 | memcpy(answer, cmd->value, len); | 515 | memcpy(answer, cmd->value, len); |
514 | 516 | ||
@@ -559,7 +561,7 @@ int wl1271_cmd_scan(struct wl1271 *wl, u8 *ssid, size_t len, | |||
559 | scan_options |= WL1271_SCAN_OPT_PASSIVE; | 561 | scan_options |= WL1271_SCAN_OPT_PASSIVE; |
560 | if (high_prio) | 562 | if (high_prio) |
561 | scan_options |= WL1271_SCAN_OPT_PRIORITY_HIGH; | 563 | scan_options |= WL1271_SCAN_OPT_PRIORITY_HIGH; |
562 | params->params.scan_options = scan_options; | 564 | params->params.scan_options = cpu_to_le16(scan_options); |
563 | 565 | ||
564 | params->params.num_probe_requests = probe_requests; | 566 | params->params.num_probe_requests = probe_requests; |
565 | /* Let the fw autodetect suitable tx_rate for probes */ | 567 | /* Let the fw autodetect suitable tx_rate for probes */ |
@@ -643,9 +645,9 @@ int wl1271_cmd_scan(struct wl1271 *wl, u8 *ssid, size_t len, | |||
643 | wl1271_spi_read(wl, wl->cmd_box_addr, params, sizeof(*params), | 645 | wl1271_spi_read(wl, wl->cmd_box_addr, params, sizeof(*params), |
644 | false); | 646 | false); |
645 | 647 | ||
646 | if (params->header.status != CMD_STATUS_SUCCESS) { | 648 | if (le16_to_cpu(params->header.status) != CMD_STATUS_SUCCESS) { |
647 | wl1271_error("Scan command error: %d", | 649 | wl1271_error("Scan command error: %d", |
648 | params->header.status); | 650 | le16_to_cpu(params->header.status)); |
649 | wl->scanning = false; | 651 | wl->scanning = false; |
650 | ret = -EIO; | 652 | ret = -EIO; |
651 | goto out; | 653 | goto out; |
@@ -675,7 +677,7 @@ int wl1271_cmd_template_set(struct wl1271 *wl, u16 template_id, | |||
675 | 677 | ||
676 | cmd->len = cpu_to_le16(buf_len); | 678 | cmd->len = cpu_to_le16(buf_len); |
677 | cmd->template_type = template_id; | 679 | cmd->template_type = template_id; |
678 | cmd->enabled_rates = wl->conf.tx.rc_conf.enabled_rates; | 680 | cmd->enabled_rates = cpu_to_le32(wl->conf.tx.rc_conf.enabled_rates); |
679 | cmd->short_retry_limit = wl->conf.tx.rc_conf.short_retry_limit; | 681 | cmd->short_retry_limit = wl->conf.tx.rc_conf.short_retry_limit; |
680 | cmd->long_retry_limit = wl->conf.tx.rc_conf.long_retry_limit; | 682 | cmd->long_retry_limit = wl->conf.tx.rc_conf.long_retry_limit; |
681 | 683 | ||
@@ -858,7 +860,7 @@ int wl1271_cmd_set_default_wep_key(struct wl1271 *wl, u8 id) | |||
858 | } | 860 | } |
859 | 861 | ||
860 | cmd->id = id; | 862 | cmd->id = id; |
861 | cmd->key_action = KEY_SET_ID; | 863 | cmd->key_action = cpu_to_le16(KEY_SET_ID); |
862 | cmd->key_type = KEY_WEP; | 864 | cmd->key_type = KEY_WEP; |
863 | 865 | ||
864 | ret = wl1271_cmd_send(wl, CMD_SET_KEYS, cmd, sizeof(*cmd)); | 866 | ret = wl1271_cmd_send(wl, CMD_SET_KEYS, cmd, sizeof(*cmd)); |
@@ -889,12 +891,12 @@ int wl1271_cmd_set_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type, | |||
889 | if (key_type != KEY_WEP) | 891 | if (key_type != KEY_WEP) |
890 | memcpy(cmd->addr, addr, ETH_ALEN); | 892 | memcpy(cmd->addr, addr, ETH_ALEN); |
891 | 893 | ||
892 | cmd->key_action = action; | 894 | cmd->key_action = cpu_to_le16(action); |
893 | cmd->key_size = key_size; | 895 | cmd->key_size = key_size; |
894 | cmd->key_type = key_type; | 896 | cmd->key_type = key_type; |
895 | 897 | ||
896 | cmd->ac_seq_num16[0] = tx_seq_16; | 898 | cmd->ac_seq_num16[0] = cpu_to_le16(tx_seq_16); |
897 | cmd->ac_seq_num32[0] = tx_seq_32; | 899 | cmd->ac_seq_num32[0] = cpu_to_le32(tx_seq_32); |
898 | 900 | ||
899 | /* we have only one SSID profile */ | 901 | /* we have only one SSID profile */ |
900 | cmd->ssid_profile = 0; | 902 | cmd->ssid_profile = 0; |
@@ -943,8 +945,8 @@ int wl1271_cmd_disconnect(struct wl1271 *wl) | |||
943 | goto out; | 945 | goto out; |
944 | } | 946 | } |
945 | 947 | ||
946 | cmd->rx_config_options = wl->rx_config; | 948 | cmd->rx_config_options = cpu_to_le32(wl->rx_config); |
947 | cmd->rx_filter_options = wl->rx_filter; | 949 | cmd->rx_filter_options = cpu_to_le32(wl->rx_filter); |
948 | /* disconnect reason is not used in immediate disconnections */ | 950 | /* disconnect reason is not used in immediate disconnections */ |
949 | cmd->type = DISCONNECT_IMMEDIATE; | 951 | cmd->type = DISCONNECT_IMMEDIATE; |
950 | 952 | ||