crypto: api - Change crypto_unregister_instance argument type
authorHerbert Xu <herbert@gondor.apana.org.au>
Thu, 2 Apr 2015 14:39:40 +0000 (22:39 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 3 Apr 2015 09:53:32 +0000 (17:53 +0800)
This patch makes crypto_unregister_instance take a crypto_instance
instead of a crypto_alg.  This allows us to remove a duplicate
CRYPTO_ALG_INSTANCE check in crypto_unregister_instance.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/algapi.c
crypto/crypto_user.c
include/crypto/algapi.h

index 0f1976eceb27b6da83951c2ab2e1334eb08bcbfd..f1d0307b1d083f3e374dbb2db4bce45a0f483948 100644 (file)
@@ -551,17 +551,13 @@ err:
 }
 EXPORT_SYMBOL_GPL(crypto_register_instance);
 
-int crypto_unregister_instance(struct crypto_alg *alg)
+int crypto_unregister_instance(struct crypto_instance *inst)
 {
-       struct crypto_instance *inst = (void *)alg;
        LIST_HEAD(list);
 
-       if (!(alg->cra_flags & CRYPTO_ALG_INSTANCE))
-               return -EINVAL;
-
        down_write(&crypto_alg_sem);
 
-       crypto_remove_spawns(alg, &list, NULL);
+       crypto_remove_spawns(&inst->alg, &list, NULL);
        crypto_remove_instance(inst, &list);
 
        up_write(&crypto_alg_sem);
index c5148a35ae0a38c696f22eaba3c0b860ab8df1c9..eab2497238307a5ad116ee45fcc581b85696d935 100644 (file)
@@ -316,7 +316,7 @@ static int crypto_del_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
        if (atomic_read(&alg->cra_refcnt) != 1)
                return -EBUSY;
 
-       return crypto_unregister_instance(alg);
+       return crypto_unregister_instance((struct crypto_instance *)alg);
 }
 
 static struct crypto_alg *crypto_user_skcipher_alg(const char *name, u32 type,
index 623a59c1ff5a6ef45d4cebe4ae8c0b7462aaff76..0ecb7688af71aa28496404ddbcdbfafdcb45ce6e 100644 (file)
@@ -137,7 +137,7 @@ struct crypto_template *crypto_lookup_template(const char *name);
 
 int crypto_register_instance(struct crypto_template *tmpl,
                             struct crypto_instance *inst);
-int crypto_unregister_instance(struct crypto_alg *alg);
+int crypto_unregister_instance(struct crypto_instance *inst);
 
 int crypto_init_spawn(struct crypto_spawn *spawn, struct crypto_alg *alg,
                      struct crypto_instance *inst, u32 mask);