Browse Source

crypto: scomp - allow registration of multiple scomps

Add crypto_register_scomps and crypto_unregister_scomps to allow
the registration of multiple implementations with one call.

Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Giovanni Cabiddu 8 years ago
parent
commit
3de4f5e1a5
2 changed files with 32 additions and 0 deletions
  1. 29 0
      crypto/scompress.c
  2. 3 0
      include/crypto/internal/scompress.h

+ 29 - 0
crypto/scompress.c

@@ -353,5 +353,34 @@ int crypto_unregister_scomp(struct scomp_alg *alg)
 }
 }
 EXPORT_SYMBOL_GPL(crypto_unregister_scomp);
 EXPORT_SYMBOL_GPL(crypto_unregister_scomp);
 
 
+int crypto_register_scomps(struct scomp_alg *algs, int count)
+{
+	int i, ret;
+
+	for (i = 0; i < count; i++) {
+		ret = crypto_register_scomp(&algs[i]);
+		if (ret)
+			goto err;
+	}
+
+	return 0;
+
+err:
+	for (--i; i >= 0; --i)
+		crypto_unregister_scomp(&algs[i]);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(crypto_register_scomps);
+
+void crypto_unregister_scomps(struct scomp_alg *algs, int count)
+{
+	int i;
+
+	for (i = count - 1; i >= 0; --i)
+		crypto_unregister_scomp(&algs[i]);
+}
+EXPORT_SYMBOL_GPL(crypto_unregister_scomps);
+
 MODULE_LICENSE("GPL");
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Synchronous compression type");
 MODULE_DESCRIPTION("Synchronous compression type");

+ 3 - 0
include/crypto/internal/scompress.h

@@ -133,4 +133,7 @@ int crypto_register_scomp(struct scomp_alg *alg);
  */
  */
 int crypto_unregister_scomp(struct scomp_alg *alg);
 int crypto_unregister_scomp(struct scomp_alg *alg);
 
 
+int crypto_register_scomps(struct scomp_alg *algs, int count);
+void crypto_unregister_scomps(struct scomp_alg *algs, int count);
+
 #endif
 #endif