forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 ee930fffee469d076998274a2ca55e13dc1efb67
kernel/drivers/crypto/mediatek/mtk-sha.c
....@@ -1,13 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Cryptographic API.
34 *
45 * Driver for EIP97 SHA1/SHA2(HMAC) acceleration.
56 *
67 * Copyright (c) 2016 Ryder Lee <ryder.lee@mediatek.com>
7
- *
8
- * This program is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License version 2 as
10
- * published by the Free Software Foundation.
118 *
129 * Some ideas are from atmel-sha.c and omap-sham.c drivers.
1310 */
....@@ -110,7 +107,7 @@
110107 u8 id;
111108 u8 buf[SHA_BUF_SIZE] __aligned(sizeof(u32));
112109
113
- struct mtk_sha_hmac_ctx base[0];
110
+ struct mtk_sha_hmac_ctx base[];
114111 };
115112
116113 struct mtk_sha_drv {
....@@ -242,7 +239,7 @@
242239 static void mtk_sha_fill_padding(struct mtk_sha_reqctx *ctx, u32 len)
243240 {
244241 u32 index, padlen;
245
- u64 bits[2];
242
+ __be64 bits[2];
246243 u64 size = ctx->digcnt;
247244
248245 size += ctx->bufcnt;
....@@ -365,7 +362,6 @@
365362 SHASH_DESC_ON_STACK(shash, bctx->shash);
366363
367364 shash->tfm = bctx->shash;
368
- shash->flags = 0; /* not CRYPTO_TFM_REQ_MAY_SLEEP */
369365
370366 return crypto_shash_init(shash) ?:
371367 crypto_shash_update(shash, bctx->opad, ctx->bs) ?:
....@@ -782,7 +778,9 @@
782778 ctx->flags |= SHA_FLAGS_FINUP;
783779
784780 err1 = mtk_sha_update(req);
785
- if (err1 == -EINPROGRESS || err1 == -EBUSY)
781
+ if (err1 == -EINPROGRESS ||
782
+ (err1 == -EBUSY && (ahash_request_flags(req) &
783
+ CRYPTO_TFM_REQ_MAY_BACKLOG)))
786784 return err1;
787785 /*
788786 * final() has to be always called to cleanup resources
....@@ -807,14 +805,9 @@
807805 size_t ds = crypto_shash_digestsize(bctx->shash);
808806 int err, i;
809807
810
- SHASH_DESC_ON_STACK(shash, bctx->shash);
811
-
812
- shash->tfm = bctx->shash;
813
- shash->flags = crypto_shash_get_flags(bctx->shash) &
814
- CRYPTO_TFM_REQ_MAY_SLEEP;
815
-
816808 if (keylen > bs) {
817
- err = crypto_shash_digest(shash, key, keylen, bctx->ipad);
809
+ err = crypto_shash_tfm_digest(bctx->shash, key, keylen,
810
+ bctx->ipad);
818811 if (err)
819812 return err;
820813 keylen = ds;