diff options
Diffstat (limited to 'drivers/net/wireless/cw1200/wsm.c')
-rw-r--r-- | drivers/net/wireless/cw1200/wsm.c | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/drivers/net/wireless/cw1200/wsm.c b/drivers/net/wireless/cw1200/wsm.c index d95094fdcc50..cbb74d7a9be5 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; |