staging: wilc1000: make use of ALIGN macro
authorAjay Singh <ajay.kathat@microchip.com>
Fri, 14 Feb 2020 11:52:18 +0000 (11:52 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 14 Feb 2020 16:20:11 +0000 (08:20 -0800)
Make use of 'ALIGN' macro to align the size data value.

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
Link: https://lore.kernel.org/r/20200214172250.13026-5-ajay.kathat@microchip.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/wilc1000/sdio.c
drivers/staging/wilc1000/wlan.c

index 66706efc5711c6ac21bb5c0d4af3d877e937e7c2..212affc4b9c1ed38f6e6e1921046981875ad7662 100644 (file)
@@ -415,28 +415,12 @@ static int wilc_sdio_write(struct wilc *wilc, u32 addr, u8 *buf, u32 size)
 
        cmd.read_write = 1;
        if (addr > 0) {
-               /**
-                *      has to be word aligned...
-                **/
-               if (size & 0x3) {
-                       size += 4;
-                       size &= ~0x3;
-               }
-
                /**
                 *      func 0 access
                 **/
                cmd.function = 0;
                cmd.address = 0x10f;
        } else {
-               /**
-                *      has to be word aligned...
-                **/
-               if (size & 0x3) {
-                       size += 4;
-                       size &= ~0x3;
-               }
-
                /**
                 *      func 1 access
                 **/
@@ -444,6 +428,7 @@ static int wilc_sdio_write(struct wilc *wilc, u32 addr, u8 *buf, u32 size)
                cmd.address = 0;
        }
 
+       size = ALIGN(size, 4);
        nblk = size / block_size;
        nleft = size % block_size;
 
@@ -551,28 +536,12 @@ static int wilc_sdio_read(struct wilc *wilc, u32 addr, u8 *buf, u32 size)
 
        cmd.read_write = 0;
        if (addr > 0) {
-               /**
-                *      has to be word aligned...
-                **/
-               if (size & 0x3) {
-                       size += 4;
-                       size &= ~0x3;
-               }
-
                /**
                 *      func 0 access
                 **/
                cmd.function = 0;
                cmd.address = 0x10f;
        } else {
-               /**
-                *      has to be word aligned...
-                **/
-               if (size & 0x3) {
-                       size += 4;
-                       size &= ~0x3;
-               }
-
                /**
                 *      func 1 access
                 **/
@@ -580,6 +549,7 @@ static int wilc_sdio_read(struct wilc *wilc, u32 addr, u8 *buf, u32 size)
                cmd.address = 0;
        }
 
+       size = ALIGN(size, 4);
        nblk = size / block_size;
        nleft = size % block_size;
 
index 9dfabd1af4e78ee9b1c41299a373db42265c8053..db4ef175ccee876af22a2573b58c4182c7c42141 100644 (file)
@@ -508,9 +508,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count)
                        vmm_sz = HOST_HDR_OFFSET;
 
                vmm_sz += tqe->buffer_size;
-
-               if (vmm_sz & 0x3)
-                       vmm_sz = (vmm_sz + 4) & ~0x3;
+               vmm_sz = ALIGN(vmm_sz, 4);
 
                if ((sum + vmm_sz) > WILC_TX_BUFF_SIZE)
                        break;