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_tx.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_tx.c')
-rw-r--r-- | drivers/net/wireless/wl12xx/wl1271_tx.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/drivers/net/wireless/wl12xx/wl1271_tx.c b/drivers/net/wireless/wl12xx/wl1271_tx.c index 4560458a6d60..00af065c77c2 100644 --- a/drivers/net/wireless/wl12xx/wl1271_tx.c +++ b/drivers/net/wireless/wl12xx/wl1271_tx.c | |||
@@ -88,6 +88,7 @@ static int wl1271_tx_fill_hdr(struct wl1271 *wl, struct sk_buff *skb, | |||
88 | { | 88 | { |
89 | struct wl1271_tx_hw_descr *desc; | 89 | struct wl1271_tx_hw_descr *desc; |
90 | int pad; | 90 | int pad; |
91 | u16 tx_attr; | ||
91 | 92 | ||
92 | desc = (struct wl1271_tx_hw_descr *) skb->data; | 93 | desc = (struct wl1271_tx_hw_descr *) skb->data; |
93 | 94 | ||
@@ -95,16 +96,17 @@ static int wl1271_tx_fill_hdr(struct wl1271 *wl, struct sk_buff *skb, | |||
95 | if (extra) { | 96 | if (extra) { |
96 | void *framestart = skb->data + sizeof(*desc); | 97 | void *framestart = skb->data + sizeof(*desc); |
97 | u16 fc = *(u16 *)(framestart + extra); | 98 | u16 fc = *(u16 *)(framestart + extra); |
98 | int hdrlen = ieee80211_hdrlen(fc); | 99 | int hdrlen = ieee80211_hdrlen(cpu_to_le16(fc)); |
99 | memmove(framestart, framestart + extra, hdrlen); | 100 | memmove(framestart, framestart + extra, hdrlen); |
100 | } | 101 | } |
101 | 102 | ||
102 | /* configure packet life time */ | 103 | /* configure packet life time */ |
103 | desc->start_time = jiffies_to_usecs(jiffies) - wl->time_offset; | 104 | desc->start_time = cpu_to_le32(jiffies_to_usecs(jiffies) - |
104 | desc->life_time = TX_HW_MGMT_PKT_LIFETIME_TU; | 105 | wl->time_offset); |
106 | desc->life_time = cpu_to_le16(TX_HW_MGMT_PKT_LIFETIME_TU); | ||
105 | 107 | ||
106 | /* configure the tx attributes */ | 108 | /* configure the tx attributes */ |
107 | desc->tx_attr = wl->session_counter << TX_HW_ATTR_OFST_SESSION_COUNTER; | 109 | tx_attr = wl->session_counter << TX_HW_ATTR_OFST_SESSION_COUNTER; |
108 | /* FIXME: do we know the packet priority? can we identify mgmt | 110 | /* FIXME: do we know the packet priority? can we identify mgmt |
109 | packets, and use max prio for them at least? */ | 111 | packets, and use max prio for them at least? */ |
110 | desc->tid = 0; | 112 | desc->tid = 0; |
@@ -113,11 +115,13 @@ static int wl1271_tx_fill_hdr(struct wl1271 *wl, struct sk_buff *skb, | |||
113 | 115 | ||
114 | /* align the length (and store in terms of words) */ | 116 | /* align the length (and store in terms of words) */ |
115 | pad = WL1271_TX_ALIGN(skb->len); | 117 | pad = WL1271_TX_ALIGN(skb->len); |
116 | desc->length = pad >> 2; | 118 | desc->length = cpu_to_le16(pad >> 2); |
117 | 119 | ||
118 | /* calculate number of padding bytes */ | 120 | /* calculate number of padding bytes */ |
119 | pad = pad - skb->len; | 121 | pad = pad - skb->len; |
120 | desc->tx_attr |= pad << TX_HW_ATTR_OFST_LAST_WORD_PAD; | 122 | tx_attr |= pad << TX_HW_ATTR_OFST_LAST_WORD_PAD; |
123 | |||
124 | desc->tx_attr = cpu_to_le16(tx_attr); | ||
121 | 125 | ||
122 | wl1271_debug(DEBUG_TX, "tx_fill_hdr: pad: %d", pad); | 126 | wl1271_debug(DEBUG_TX, "tx_fill_hdr: pad: %d", pad); |
123 | return 0; | 127 | return 0; |
@@ -331,7 +335,7 @@ void wl1271_tx_complete(struct wl1271 *wl, u32 count) | |||
331 | wl1271_debug(DEBUG_TX, "tx_complete received, packets: %d", count); | 335 | wl1271_debug(DEBUG_TX, "tx_complete received, packets: %d", count); |
332 | 336 | ||
333 | /* read the tx results from the chipset */ | 337 | /* read the tx results from the chipset */ |
334 | wl1271_spi_read(wl, memmap->tx_result, | 338 | wl1271_spi_read(wl, le32_to_cpu(memmap->tx_result), |
335 | wl->tx_res_if, sizeof(*wl->tx_res_if), false); | 339 | wl->tx_res_if, sizeof(*wl->tx_res_if), false); |
336 | 340 | ||
337 | /* verify that the result buffer is not getting overrun */ | 341 | /* verify that the result buffer is not getting overrun */ |
@@ -353,10 +357,10 @@ void wl1271_tx_complete(struct wl1271 *wl, u32 count) | |||
353 | } | 357 | } |
354 | 358 | ||
355 | /* write host counter to chipset (to ack) */ | 359 | /* write host counter to chipset (to ack) */ |
356 | wl1271_spi_write32(wl, memmap->tx_result + | 360 | wl1271_spi_write32(wl, le32_to_cpu(memmap->tx_result) + |
357 | offsetof(struct wl1271_tx_hw_res_if, | 361 | offsetof(struct wl1271_tx_hw_res_if, |
358 | tx_result_host_counter), | 362 | tx_result_host_counter), |
359 | wl->tx_res_if->tx_result_fw_counter); | 363 | le32_to_cpu(wl->tx_res_if->tx_result_fw_counter)); |
360 | } | 364 | } |
361 | 365 | ||
362 | /* caller must hold wl->mutex */ | 366 | /* caller must hold wl->mutex */ |