aboutsummaryrefslogtreecommitdiff
path: root/drivers/net/wireless/cw1200/wsm.c
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2013-06-20 23:03:12 -0400
committerJohn W. Linville <linville@tuxdriver.com>2013-06-24 14:44:24 -0400
commit7258416c517c79b2ebb30b61d8c6807a04dc6b25 (patch)
tree6c547d02cdbc49bbc2ce8d3824d83cd14c71a15b /drivers/net/wireless/cw1200/wsm.c
parent5d9e3bc21c57d600b706a31454d5cf2f68c24f53 (diff)
cw1200: Fix up a large pile of sparse warnings
Most of these relate to endianness problems, and are purely cosmetic. But a couple of them were legit -- listen interval parsing and some of the rate selection code would malfunction on BE systems. There's still one cosmetic warning remaining, in the (admittedly) ugly code in cw1200_spi.c. It's there because the hardware needs 16-bit SPI transfers, but many SPI controllers only operate 8 bits at a time. If there's a cleaner way of handling this, I'm all ears. Signed-off-by: Solomon Peachy <pizza@shaftnet.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/cw1200/wsm.c')
-rw-r--r--drivers/net/wireless/cw1200/wsm.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/drivers/net/wireless/cw1200/wsm.c b/drivers/net/wireless/cw1200/wsm.c
index d95094fdcc5..cbb74d7a9be 100644
--- a/drivers/net/wireless/cw1200/wsm.c
+++ b/drivers/net/wireless/cw1200/wsm.c
@@ -42,19 +42,19 @@
(buf)->data += size; \
} while (0)
-#define __WSM_GET(buf, type, cvt) \
+#define __WSM_GET(buf, type, type2, cvt) \
({ \
type val; \
if ((buf)->data + sizeof(type) > (buf)->end) \
goto underflow; \
- val = cvt(*(type *)(buf)->data); \
+ val = cvt(*(type2 *)(buf)->data); \
(buf)->data += sizeof(type); \
val; \
})
-#define WSM_GET8(buf) __WSM_GET(buf, u8, (u8))
-#define WSM_GET16(buf) __WSM_GET(buf, u16, __le16_to_cpu)
-#define WSM_GET32(buf) __WSM_GET(buf, u32, __le32_to_cpu)
+#define WSM_GET8(buf) __WSM_GET(buf, u8, u8, (u8))
+#define WSM_GET16(buf) __WSM_GET(buf, u16, __le16, __le16_to_cpu)
+#define WSM_GET32(buf) __WSM_GET(buf, u32, __le32, __le32_to_cpu)
#define WSM_PUT(buf, ptr, size) \
do { \
@@ -65,18 +65,18 @@
(buf)->data += size; \
} while (0)
-#define __WSM_PUT(buf, val, type, cvt) \
+#define __WSM_PUT(buf, val, type, type2, cvt) \
do { \
if ((buf)->data + sizeof(type) > (buf)->end) \
if (wsm_buf_reserve((buf), sizeof(type))) \
goto nomem; \
- *(type *)(buf)->data = cvt(val); \
+ *(type2 *)(buf)->data = cvt(val); \
(buf)->data += sizeof(type); \
} while (0)
-#define WSM_PUT8(buf, val) __WSM_PUT(buf, val, u8, (u8))
-#define WSM_PUT16(buf, val) __WSM_PUT(buf, val, u16, __cpu_to_le16)
-#define WSM_PUT32(buf, val) __WSM_PUT(buf, val, u32, __cpu_to_le32)
+#define WSM_PUT8(buf, val) __WSM_PUT(buf, val, u8, u8, (u8))
+#define WSM_PUT16(buf, val) __WSM_PUT(buf, val, u16, __le16, __cpu_to_le16)
+#define WSM_PUT32(buf, val) __WSM_PUT(buf, val, u32, __le32, __cpu_to_le32)
static void wsm_buf_reset(struct wsm_buf *buf);
static int wsm_buf_reserve(struct wsm_buf *buf, size_t extra_size);
@@ -931,8 +931,8 @@ static int wsm_event_indication(struct cw1200_common *priv, struct wsm_buf *buf)
if (!event)
return -ENOMEM;
- event->evt.id = __le32_to_cpu(WSM_GET32(buf));
- event->evt.data = __le32_to_cpu(WSM_GET32(buf));
+ event->evt.id = WSM_GET32(buf);
+ event->evt.data = WSM_GET32(buf);
pr_debug("[WSM] Event: %d(%d)\n",
event->evt.id, event->evt.data);
@@ -1311,7 +1311,7 @@ int wsm_handle_rx(struct cw1200_common *priv, u16 id,
wsm_buf.begin = (u8 *)&wsm[0];
wsm_buf.data = (u8 *)&wsm[1];
- wsm_buf.end = &wsm_buf.begin[__le32_to_cpu(wsm->len)];
+ wsm_buf.end = &wsm_buf.begin[__le16_to_cpu(wsm->len)];
pr_debug("[WSM] <<< 0x%.4X (%td)\n", id,
wsm_buf.end - wsm_buf.begin);
@@ -1550,7 +1550,7 @@ static bool wsm_handle_tx_data(struct cw1200_common *priv,
*/
pr_debug("[WSM] Convert probe request to scan.\n");
wsm_lock_tx_async(priv);
- priv->pending_frame_id = __le32_to_cpu(wsm->packet_id);
+ priv->pending_frame_id = wsm->packet_id;
if (queue_delayed_work(priv->workqueue,
&priv->scan.probe_work, 0) <= 0)
wsm_unlock_tx(priv);
@@ -1558,15 +1558,14 @@ static bool wsm_handle_tx_data(struct cw1200_common *priv,
break;
case do_drop:
pr_debug("[WSM] Drop frame (0x%.4X).\n", fctl);
- BUG_ON(cw1200_queue_remove(queue,
- __le32_to_cpu(wsm->packet_id)));
+ BUG_ON(cw1200_queue_remove(queue, wsm->packet_id));
handled = true;
break;
case do_wep:
pr_debug("[WSM] Issue set_default_wep_key.\n");
wsm_lock_tx_async(priv);
priv->wep_default_key_id = tx_info->control.hw_key->keyidx;
- priv->pending_frame_id = __le32_to_cpu(wsm->packet_id);
+ priv->pending_frame_id = wsm->packet_id;
if (queue_work(priv->workqueue, &priv->wep_key_work) <= 0)
wsm_unlock_tx(priv);
handled = true;