summaryrefslogtreecommitdiff
path: root/drivers/crypto/sunxi-ss/sun4i-ss-hash.c
diff options
context:
space:
mode:
authorAntoine Ténart <antoine.tenart@free-electrons.com>2017-06-01 21:39:00 +0200
committerHerbert Xu <herbert@gondor.apana.org.au>2017-06-19 14:19:51 +0800
commitd78867a94ea74b8d2dafdbf370e0707f37a58f4a (patch)
tree4ec34da8d502d737a49c011a203f5638597d9047 /drivers/crypto/sunxi-ss/sun4i-ss-hash.c
parent303391d69b6ae7dff30f7886b717e39f47067d6d (diff)
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 <antoine.tenart@free-electrons.com> Tested-by: Corentin Labbe <clabbe.montjoie@gmail.com> Acked-by: Corentin Labbe <clabbe.montjoie@gmail.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/sunxi-ss/sun4i-ss-hash.c')
-rw-r--r--drivers/crypto/sunxi-ss/sun4i-ss-hash.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-hash.c b/drivers/crypto/sunxi-ss/sun4i-ss-hash.c
index 0c2efc88bc0a..685de5b6ab17 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 */