From: Sujith Manoharan Date: Sun, 28 Apr 2013 21:01:35 +0530 Subject: [ath9k-devel] [PATCH 17/20] ath10k: Use IS_ALIGNED macro to check alignment In-Reply-To: <1367163098-22787-1-git-send-email-sujith@msujith.org> References: <1367163098-22787-1-git-send-email-sujith@msujith.org> Message-ID: <1367163098-22787-17-git-send-email-sujith@msujith.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: ath9k-devel@lists.ath9k.org From: Sujith Manoharan Signed-off-by: Sujith Manoharan --- drivers/net/wireless/ath/ath10k/htc.c | 4 +++- drivers/net/wireless/ath/ath10k/htt_rx.c | 2 +- drivers/net/wireless/ath/ath10k/htt_tx.c | 4 ++-- drivers/net/wireless/ath/ath10k/pci.c | 3 ++- drivers/net/wireless/ath/ath10k/wmi.c | 3 ++- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/htc.c b/drivers/net/wireless/ath/ath10k/htc.c index fd07d34..1e4c075 100644 --- a/drivers/net/wireless/ath/ath10k/htc.c +++ b/drivers/net/wireless/ath/ath10k/htc.c @@ -936,7 +936,9 @@ struct sk_buff *ath10k_htc_alloc_skb(int size) skb_reserve(skb, sizeof(struct ath10k_htc_hdr)); /* FW/HTC requires 4-byte aligned streams */ - WARN_ONCE((unsigned long)skb->data & 0x3, "unaligned skb"); + if (!IS_ALIGNED((unsigned long)skb->data, 4)) + ath10k_warn("Unaligned HTC tx skb\n"); + return skb; } diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c index 6e09581..cc385e7 100644 --- a/drivers/net/wireless/ath/ath10k/htt_rx.c +++ b/drivers/net/wireless/ath/ath10k/htt_rx.c @@ -1159,7 +1159,7 @@ void ath10k_htt_t2h_msg_handler(struct ath10k *ar, struct sk_buff *skb) struct htt_resp *resp = (struct htt_resp *)skb->data; /* confirm alignment */ - if ((((unsigned long)skb->data) & 0x3) != 0) + if (!IS_ALIGNED((unsigned long)skb->data, 4)) ath10k_warn("unaligned htt message, expect trouble\n"); ath10k_dbg(ATH10K_DBG_HTT, "HTT RX, msg_type: 0x%0X\n", diff --git a/drivers/net/wireless/ath/ath10k/htt_tx.c b/drivers/net/wireless/ath/ath10k/htt_tx.c index 7a10503..881d390 100644 --- a/drivers/net/wireless/ath/ath10k/htt_tx.c +++ b/drivers/net/wireless/ath/ath10k/htt_tx.c @@ -153,7 +153,7 @@ int ath10k_htt_send_rx_ring_cfg_ll(struct ath10k_htt *htt) * the HW expects the buffer to be an integral number of 4-byte * "words" */ - BUILD_BUG_ON((HTT_RX_BUF_SIZE & 0x3) != 0); + BUILD_BUG_ON(!IS_ALIGNED(HTT_RX_BUF_SIZE, 4)); BUILD_BUG_ON((HTT_RX_BUF_SIZE & HTT_MAX_CACHE_LINE_SIZE_MASK) != 0); len = sizeof(cmd->hdr) + sizeof(cmd->rx_setup.hdr) @@ -435,7 +435,7 @@ int ath10k_htt_tx(struct ath10k_htt *htt, struct sk_buff *msdu) goto err; } - if ((unsigned long)txdesc->data & 0x3) { + if (!IS_ALIGNED((unsigned long)txdesc->data, 4)) { ath10k_warn("htt alignment check failed. dropping packet.\n"); res = -EIO; goto err; diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c index a7d321c..209b310 100644 --- a/drivers/net/wireless/ath/ath10k/pci.c +++ b/drivers/net/wireless/ath/ath10k/pci.c @@ -120,7 +120,8 @@ static int ath10k_pci_diag_read_mem(struct ath10k *ar, u32 address, void *data, * this fn */ if (address < DRAM_BASE_ADDRESS) { - if ((address & 0x3) || ((dma_addr_t)data & 0x3)) + if (!IS_ALIGNED(address, 4) || + !IS_ALIGNED((unsigned long)data, 4)) return -EIO; while ((nbytes >= 4) && ((ret = ath10k_pci_diag_read_access( diff --git a/drivers/net/wireless/ath/ath10k/wmi.c b/drivers/net/wireless/ath/ath10k/wmi.c index 577a63e..248a886 100644 --- a/drivers/net/wireless/ath/ath10k/wmi.c +++ b/drivers/net/wireless/ath/ath10k/wmi.c @@ -65,7 +65,8 @@ static struct sk_buff *ath10k_wmi_alloc_skb(u32 len) return NULL; skb_reserve(skb, WMI_SKB_HEADROOM); - WARN_ONCE((unsigned long)skb->data & 0x3, "unaligned skb"); + if (!IS_ALIGNED((unsigned long)skb->data, 4)) + ath10k_warn("Unaligned WMI skb\n"); skb_put(skb, round_len); memset(skb->data, 0, round_len); -- 1.8.2.2