aboutsummaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2016-01-23 00:51:01 -0500
committerHerbert Xu <herbert@gondor.apana.org.au>2016-01-25 09:42:12 -0500
commitf2aefdab5dff83d3c801449051be1ba72c7e933a (patch)
tree167102bb66295086a223e47d4d4fc7a6ad3de3eb /crypto
parent1aaa753d918c48c603195a468766e6a2b32b87f9 (diff)
crypto: api - Add crypto_type_has_alg helper
This patch adds the helper crypto_type_has_alg which is meant to replace crypto_has_alg for new-style crypto types. Rather than hard-coding type/mask information they're now retrieved from the crypto_type object. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/algapi.c15
-rw-r--r--crypto/internal.h3
2 files changed, 18 insertions, 0 deletions
diff --git a/crypto/algapi.c b/crypto/algapi.c
index 7be76aa31579..731255a6104f 100644
--- a/crypto/algapi.c
+++ b/crypto/algapi.c
@@ -987,6 +987,21 @@ unsigned int crypto_alg_extsize(struct crypto_alg *alg)
987} 987}
988EXPORT_SYMBOL_GPL(crypto_alg_extsize); 988EXPORT_SYMBOL_GPL(crypto_alg_extsize);
989 989
990int crypto_type_has_alg(const char *name, const struct crypto_type *frontend,
991 u32 type, u32 mask)
992{
993 int ret = 0;
994 struct crypto_alg *alg = crypto_find_alg(name, frontend, type, mask);
995
996 if (!IS_ERR(alg)) {
997 crypto_mod_put(alg);
998 ret = 1;
999 }
1000
1001 return ret;
1002}
1003EXPORT_SYMBOL_GPL(crypto_type_has_alg);
1004
990static int __init crypto_algapi_init(void) 1005static int __init crypto_algapi_init(void)
991{ 1006{
992 crypto_init_proc(); 1007 crypto_init_proc();
diff --git a/crypto/internal.h b/crypto/internal.h
index 00e42a3ed814..7eefcdb00227 100644
--- a/crypto/internal.h
+++ b/crypto/internal.h
@@ -104,6 +104,9 @@ int crypto_probing_notify(unsigned long val, void *v);
104 104
105unsigned int crypto_alg_extsize(struct crypto_alg *alg); 105unsigned int crypto_alg_extsize(struct crypto_alg *alg);
106 106
107int crypto_type_has_alg(const char *name, const struct crypto_type *frontend,
108 u32 type, u32 mask);
109
107static inline struct crypto_alg *crypto_alg_get(struct crypto_alg *alg) 110static inline struct crypto_alg *crypto_alg_get(struct crypto_alg *alg)
108{ 111{
109 atomic_inc(&alg->cra_refcnt); 112 atomic_inc(&alg->cra_refcnt);