@@ -12,6 +12,7 @@
#include <linux/interrupt.h>
#include <linux/of_irq.h>
#include <linux/irq.h>
+#include <linux/align.h>
#include "bus.h"
#include "wfx.h"
@@ -40,8 +41,8 @@ static int wfx_sdio_copy_from_io(void *priv, unsigned int reg_id,
int ret;
WARN(reg_id > 7, "chip only has 7 registers");
- WARN(((uintptr_t)dst) & 3, "unaligned buffer size");
- WARN(count & 3, "unaligned buffer address");
+ WARN(!IS_ALIGNED((uintptr_t)dst, 4), "unaligned buffer address");
+ WARN(!IS_ALIGNED(count, 4), "unaligned buffer size");
/* Use queue mode buffers */
if (reg_id == WFX_REG_IN_OUT_QUEUE)
@@ -61,8 +62,8 @@ static int wfx_sdio_copy_to_io(void *priv, unsigned int reg_id,
int ret;
WARN(reg_id > 7, "chip only has 7 registers");
- WARN(((uintptr_t)src) & 3, "unaligned buffer size");
- WARN(count & 3, "unaligned buffer address");
+ WARN(!IS_ALIGNED((uintptr_t)src, 4), "unaligned buffer address");
+ WARN(!IS_ALIGNED(count, 4), "unaligned buffer size");
/* Use queue mode buffers */
if (reg_id == WFX_REG_IN_OUT_QUEUE)
@@ -8,6 +8,7 @@
#include <linux/kernel.h>
#include <linux/delay.h>
#include <linux/slab.h>
+#include <linux/align.h>
#include "hwio.h"
#include "wfx.h"
@@ -221,7 +222,7 @@ int wfx_data_read(struct wfx_dev *wdev, void *buf, size_t len)
{
int ret;
- WARN((long)buf & 3, "%s: unaligned buffer", __func__);
+ WARN(!IS_ALIGNED((uintptr_t)buf, 4), "unaligned buffer");
wdev->hwbus_ops->lock(wdev->hwbus_priv);
ret = wdev->hwbus_ops->copy_from_io(wdev->hwbus_priv,
WFX_REG_IN_OUT_QUEUE, buf, len);
@@ -237,7 +238,7 @@ int wfx_data_write(struct wfx_dev *wdev, const void *buf, size_t len)
{
int ret;
- WARN((long)buf & 3, "%s: unaligned buffer", __func__);
+ WARN(!IS_ALIGNED((uintptr_t)buf, 4), "unaligned buffer");
wdev->hwbus_ops->lock(wdev->hwbus_priv);
ret = wdev->hwbus_ops->copy_to_io(wdev->hwbus_priv,
WFX_REG_IN_OUT_QUEUE, buf, len);