Browse Source

crypto: api - Add crypto_requires_off helper

This patch adds crypto_requires_off which is an extension of
crypto_requires_sync for similar bits such as NEED_FALLBACK.

Cc: stable@vger.kernel.org #4.10
Suggested-by: Marcelo Cerri <marcelo.cerri@canonical.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Herbert Xu 8 years ago
parent
commit
016df0abc5
1 changed files with 6 additions and 1 deletions
  1. 6 1
      include/crypto/algapi.h

+ 6 - 1
include/crypto/algapi.h

@@ -360,13 +360,18 @@ static inline struct crypto_alg *crypto_get_attr_alg(struct rtattr **tb,
 	return crypto_attr_alg(tb[1], type, mask);
 	return crypto_attr_alg(tb[1], type, mask);
 }
 }
 
 
+static inline int crypto_requires_off(u32 type, u32 mask, u32 off)
+{
+	return (type ^ off) & mask & off;
+}
+
 /*
 /*
  * Returns CRYPTO_ALG_ASYNC if type/mask requires the use of sync algorithms.
  * Returns CRYPTO_ALG_ASYNC if type/mask requires the use of sync algorithms.
  * Otherwise returns zero.
  * Otherwise returns zero.
  */
  */
 static inline int crypto_requires_sync(u32 type, u32 mask)
 static inline int crypto_requires_sync(u32 type, u32 mask)
 {
 {
-	return (type ^ CRYPTO_ALG_ASYNC) & mask & CRYPTO_ALG_ASYNC;
+	return crypto_requires_off(type, mask, CRYPTO_ALG_ASYNC);
 }
 }
 
 
 noinline unsigned long __crypto_memneq(const void *a, const void *b, size_t size);
 noinline unsigned long __crypto_memneq(const void *a, const void *b, size_t size);