diff options
| author | 2022-01-13 09:55:01 +0100 | |
|---|---|---|
| committer | 2022-01-25 16:19:40 +0100 | |
| commit | dbf798da2ff1733e7ee6089626d8a0eafca604f8 (patch) | |
| tree | dfa4aaef22c6d99d998be553c3499e244e5c1ae3 /drivers/staging/wfx | |
| parent | staging: wfx: remove useless #ifdef (diff) | |
| download | linux-dev-dbf798da2ff1733e7ee6089626d8a0eafca604f8.tar.xz linux-dev-dbf798da2ff1733e7ee6089626d8a0eafca604f8.zip | |
staging: wfx: use IS_ALIGNED()
It "IS_ALIGNED(ptr, 4)" is more explicit than "ptr & 3".
Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
Link: https://lore.kernel.org/r/20220113085524.1110708-9-Jerome.Pouiller@silabs.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/wfx')
| -rw-r--r-- | drivers/staging/wfx/bus_sdio.c | 9 | ||||
| -rw-r--r-- | drivers/staging/wfx/hwio.c | 5 |
2 files changed, 8 insertions, 6 deletions
diff --git a/drivers/staging/wfx/bus_sdio.c b/drivers/staging/wfx/bus_sdio.c index a670176ba06f..42aeab30bf0a 100644 --- a/drivers/staging/wfx/bus_sdio.c +++ b/drivers/staging/wfx/bus_sdio.c @@ -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) diff --git a/drivers/staging/wfx/hwio.c b/drivers/staging/wfx/hwio.c index 393bcb1e2f4e..a2a37efc51a6 100644 --- a/drivers/staging/wfx/hwio.c +++ b/drivers/staging/wfx/hwio.c @@ -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); |
