]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
crypto: gcm - move to generic async completion
authorGilad Ben-Yossef <gilad@benyossef.com>
Wed, 18 Oct 2017 07:00:42 +0000 (08:00 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 3 Nov 2017 14:11:19 +0000 (22:11 +0800)
gcm is starting an async. crypto op and waiting for it complete.
Move it over to generic code doing the same.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/gcm.c

index 80cf6cfe082b69d1dbe449629943287e55c40229..8589681fb9f6d3b522894af6d9bc048a17d93cd2 100644 (file)
@@ -17,7 +17,6 @@
 #include <crypto/gcm.h>
 #include <crypto/hash.h>
 #include "internal.h"
-#include <linux/completion.h>
 #include <linux/err.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
@@ -79,11 +78,6 @@ struct crypto_gcm_req_priv_ctx {
        } u;
 };
 
-struct crypto_gcm_setkey_result {
-       int err;
-       struct completion completion;
-};
-
 static struct {
        u8 buf[16];
        struct scatterlist sg;
@@ -99,17 +93,6 @@ static inline struct crypto_gcm_req_priv_ctx *crypto_gcm_reqctx(
        return (void *)PTR_ALIGN((u8 *)aead_request_ctx(req), align + 1);
 }
 
-static void crypto_gcm_setkey_done(struct crypto_async_request *req, int err)
-{
-       struct crypto_gcm_setkey_result *result = req->data;
-
-       if (err == -EINPROGRESS)
-               return;
-
-       result->err = err;
-       complete(&result->completion);
-}
-
 static int crypto_gcm_setkey(struct crypto_aead *aead, const u8 *key,
                             unsigned int keylen)
 {
@@ -120,7 +103,7 @@ static int crypto_gcm_setkey(struct crypto_aead *aead, const u8 *key,
                be128 hash;
                u8 iv[16];
 
-               struct crypto_gcm_setkey_result result;
+               struct crypto_wait wait;
 
                struct scatterlist sg[1];
                struct skcipher_request req;
@@ -141,21 +124,18 @@ static int crypto_gcm_setkey(struct crypto_aead *aead, const u8 *key,
        if (!data)
                return -ENOMEM;
 
-       init_completion(&data->result.completion);
+       crypto_init_wait(&data->wait);
        sg_init_one(data->sg, &data->hash, sizeof(data->hash));
        skcipher_request_set_tfm(&data->req, ctr);
        skcipher_request_set_callback(&data->req, CRYPTO_TFM_REQ_MAY_SLEEP |
                                                  CRYPTO_TFM_REQ_MAY_BACKLOG,
-                                     crypto_gcm_setkey_done,
-                                     &data->result);
+                                     crypto_req_done,
+                                     &data->wait);
        skcipher_request_set_crypt(&data->req, data->sg, data->sg,
                                   sizeof(data->hash), data->iv);
 
-       err = crypto_skcipher_encrypt(&data->req);
-       if (err == -EINPROGRESS || err == -EBUSY) {
-               wait_for_completion(&data->result.completion);
-               err = data->result.err;
-       }
+       err = crypto_wait_req(crypto_skcipher_encrypt(&data->req),
+                                                       &data->wait);
 
        if (err)
                goto out;