crypto: scomp - allow registration of multiple scomps
authorGiovanni Cabiddu <giovanni.cabiddu@intel.com>
Fri, 21 Apr 2017 20:54:29 +0000 (21:54 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Mon, 24 Apr 2017 10:11:07 +0000 (18:11 +0800)
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>
crypto/scompress.c
include/crypto/internal/scompress.h

index 6b048b36312dac5f97b47e56765fc7ed9d686aa5..ae1d3cf209e4836b5cdbdf0e261caa9190e59bb4 100644 (file)
@@ -353,5 +353,34 @@ int crypto_unregister_scomp(struct scomp_alg *alg)
 }
 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_DESCRIPTION("Synchronous compression type");
index 3fda3c5655a0e071870dd2f6ea1859bb4b269822..ccad9b2c9bd67679790cf3eb9d884cb5f47b0202 100644 (file)
@@ -133,4 +133,7 @@ int crypto_register_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