mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Xiongfeng Wang <wangxiongfeng2@huawei.com>
To: <agk@redhat.com>, <snitzer@redhat.com>, <herbert@gondor.apana.org.au>
Cc: <dm-devel@redhat.com>, <linux-kernel@vger.kernel.org>,
	<wangxiongfeng2@huawei.com>, <broonie@kernel.org>,
	<arnd@arndb.de>, <jonathan.cameron@huawei.com>
Subject: [PATCH 1/5] crypto: api - introduce API to (un)register a array of templates
Date: Wed, 18 Jul 2018 15:30:51 +0800	[thread overview]
Message-ID: <1531899055-29362-2-git-send-email-wangxiongfeng2@huawei.com> (raw)
In-Reply-To: <1531899055-29362-1-git-send-email-wangxiongfeng2@huawei.com>

The following patch introduce several crypto templates. To simplify the
code, this patch add two APIs to (un)register a array of templates.

Signed-off-by: Xiongfeng Wang <xiongfeng.wang@linaro.org>
---
 crypto/algapi.c         | 27 +++++++++++++++++++++++++++
 include/crypto/algapi.h |  2 ++
 2 files changed, 29 insertions(+)

diff --git a/crypto/algapi.c b/crypto/algapi.c
index c0755cf..08c29e6 100644
--- a/crypto/algapi.c
+++ b/crypto/algapi.c
@@ -485,6 +485,24 @@ int crypto_register_template(struct crypto_template *tmpl)
 }
 EXPORT_SYMBOL_GPL(crypto_register_template);
 
+int crypto_register_template_array(struct crypto_template *tmpl, int num)
+{
+	int i, err;
+
+	for (i = 0; i < num; i++) {
+		err = crypto_register_template(&tmpl[i]);
+		if (err)
+			goto out;
+	}
+	return 0;
+
+out:
+	for (i -= 1; i >= 0; i--)
+		crypto_unregister_template(&tmpl[i]);
+	return err;
+}
+EXPORT_SYMBOL_GPL(crypto_register_template_array);
+
 void crypto_unregister_template(struct crypto_template *tmpl)
 {
 	struct crypto_instance *inst;
@@ -514,6 +532,15 @@ void crypto_unregister_template(struct crypto_template *tmpl)
 }
 EXPORT_SYMBOL_GPL(crypto_unregister_template);
 
+void crypto_unregister_template_array(struct crypto_template *tmpl, int num)
+{
+	int i;
+
+	for (i = 0; i < num; i++)
+		crypto_unregister_template(&tmpl[i]);
+}
+EXPORT_SYMBOL_GPL(crypto_unregister_template_array);
+
 static struct crypto_template *__crypto_lookup_template(const char *name)
 {
 	struct crypto_template *q, *tmpl = NULL;
diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
index bd5e8cc..14bfbe31 100644
--- a/include/crypto/algapi.h
+++ b/include/crypto/algapi.h
@@ -141,7 +141,9 @@ struct ablkcipher_walk {
 void crypto_mod_put(struct crypto_alg *alg);
 
 int crypto_register_template(struct crypto_template *tmpl);
+int crypto_register_template_array(struct crypto_template *tmpl, int num);
 void crypto_unregister_template(struct crypto_template *tmpl);
+void crypto_unregister_template_array(struct crypto_template *tmpl, int num);
 struct crypto_template *crypto_lookup_template(const char *name);
 
 int crypto_register_instance(struct crypto_template *tmpl,
-- 
1.7.12.4


  reply	other threads:[~2018-07-18  7:43 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-18  7:30 [PATCH 0/5] crypto: add IV generation templates Xiongfeng Wang
2018-07-18  7:30 ` Xiongfeng Wang [this message]
2018-07-18  7:30 ` [PATCH 2/5] crypto: ccm - use template array registering API to simplify the code Xiongfeng Wang
2018-07-18  7:30 ` [PATCH 3/5] crypto: gcm " Xiongfeng Wang
2018-07-18  7:30 ` [PATCH 4/5] crypto: Add IV generation templates Xiongfeng Wang
2018-07-18  8:16   ` Milan Broz
2018-07-18  8:48     ` Xiongfeng Wang
2018-07-18 13:11     ` Mike Snitzer
2018-07-18 16:46     ` Mark Brown
2018-07-18 17:17       ` Milan Broz
2018-07-18 17:47         ` Mark Brown
2018-07-19  1:46         ` Xiongfeng Wang
2018-07-19  8:50           ` Arnd Bergmann
2018-07-19  8:54             ` Herbert Xu
2018-07-19 13:30             ` Mark Brown
2018-07-19 18:14   ` kbuild test robot
2018-07-18  7:30 ` [PATCH 5/5] dm-crypt: modify dm-crypt to rely on " Xiongfeng Wang
2018-07-18 10:59 ` [PATCH 0/5] crypto: add " Arnd Bergmann
2018-07-18 15:34   ` Ard Biesheuvel
2018-07-19 10:55     ` Xiongfeng Wang
2018-07-19 14:08       ` Ard Biesheuvel
2018-07-19 15:50         ` Mark Brown
2018-07-20  1:02           ` Ard Biesheuvel
2018-07-20 11:45             ` Mark Brown
2018-07-20 12:23               ` Ard Biesheuvel
2018-07-20 12:32                 ` Mark Brown
2018-07-22 13:39               ` Gilad Ben-Yossef
2018-07-23  0:13                 ` Ard Biesheuvel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1531899055-29362-2-git-send-email-wangxiongfeng2@huawei.com \
    --to=wangxiongfeng2@huawei.com \
    --cc=agk@redhat.com \
    --cc=arnd@arndb.de \
    --cc=broonie@kernel.org \
    --cc=dm-devel@redhat.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=jonathan.cameron@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=snitzer@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®