From: Antoine Ténart Date: Thu, 1 Jun 2017 19:39:00 +0000 (+0200) Subject: crypto: sun4i-ss - use GENMASK to generate masks X-Git-Tag: v4.14-rc1~453^2~52 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d78867a94ea74b8d2dafdbf370e0707f37a58f4a;p=platform%2Fkernel%2Flinux-rpi.git crypto: sun4i-ss - use GENMASK to generate masks Use the GENMASK helper instead of custom calculations to generate masks, It also helps the readability. Signed-off-by: Antoine Tenart Tested-by: Corentin Labbe Acked-by: Corentin Labbe Signed-off-by: Herbert Xu --- diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-hash.c b/drivers/crypto/sunxi-ss/sun4i-ss-hash.c index 0c2efc8..685de5b 100644 --- a/drivers/crypto/sunxi-ss/sun4i-ss-hash.c +++ b/drivers/crypto/sunxi-ss/sun4i-ss-hash.c @@ -384,11 +384,14 @@ hash_final: writesl(ss->base + SS_RXFIFO, op->buf, nwait); op->byte_count += 4 * nwait; } + nbw = op->len - 4 * nwait; - wb = *(u32 *)(op->buf + nwait * 4); - wb &= (0xFFFFFFFF >> (4 - nbw) * 8); + if (nbw) { + wb = *(u32 *)(op->buf + nwait * 4); + wb &= GENMASK((nbw * 8) - 1, 0); - op->byte_count += nbw; + op->byte_count += nbw; + } } /* write the remaining bytes of the nbw buffer */