ASoC: wm_adsp: Improve round to next 4-byte boundary
authorCharles Keepax <ckeepax@opensource.wolfsonmicro.com>
Mon, 16 Feb 2015 15:25:49 +0000 (15:25 +0000)
committerMark Brown <broonie@kernel.org>
Sat, 21 Feb 2015 09:35:19 +0000 (18:35 +0900)
Whilst the existing code does correctly round to the next 4-byte boundary
it does so rather inefficiently. This patch changes the rounding to be
simpler and more efficient.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/wm_adsp.c

index 14414ea23b555bba53d154bc05f3c0b183f374b5..e625cedb0fa96263f3340eb7582bac87c1ff513c 100644 (file)
@@ -1184,7 +1184,6 @@ static int wm_adsp_load_coeff(struct wm_adsp *dsp)
        int ret, pos, blocks, type, offset, reg;
        char *file;
        struct wm_adsp_buf *buf;
-       int tmp;
 
        file = kzalloc(PAGE_SIZE, GFP_KERNEL);
        if (file == NULL)
@@ -1334,12 +1333,7 @@ static int wm_adsp_load_coeff(struct wm_adsp *dsp)
                        }
                }
 
-               tmp = le32_to_cpu(blk->len) % 4;
-               if (tmp)
-                       pos += le32_to_cpu(blk->len) + (4 - tmp) + sizeof(*blk);
-               else
-                       pos += le32_to_cpu(blk->len) + sizeof(*blk);
-
+               pos += (le32_to_cpu(blk->len) + sizeof(*blk) + 3) & ~0x03;
                blocks++;
        }