From: Akinobu Mita <akinobu.mita@gmail.com>
To: linux-kernel@vger.kernel.org,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>
Subject: [PATCH 2/2] crypto: delete duplicated code
Date: Mon, 9 Oct 2006 18:01:22 +0900 [thread overview]
Message-ID: <20061009090122.GA6129@localhost> (raw)
In-Reply-To: <20061009085812.GA6020@localhost>
crypto_alloc_tfm() and crypto_alloc_base() are almost same.
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
crypto/api.c | 40 +++++++++-------------------------------
1 file changed, 9 insertions(+), 31 deletions(-)
Index: work-fault-inject/crypto/api.c
===================================================================
--- work-fault-inject.orig/crypto/api.c 2006-10-09 15:09:00.000000000 +0900
+++ work-fault-inject/crypto/api.c 2006-10-09 15:09:04.000000000 +0900
@@ -362,7 +362,8 @@ out:
}
EXPORT_SYMBOL_GPL(__crypto_alloc_tfm);
-struct crypto_tfm *crypto_alloc_tfm(const char *name, u32 flags)
+static struct crypto_tfm *crypto_alloc_tfm_base(const char *name, u32 flags,
+ u32 type, u32 mask)
{
struct crypto_tfm *tfm;
int err;
@@ -370,7 +371,7 @@ struct crypto_tfm *crypto_alloc_tfm(cons
for (;;) {
struct crypto_alg *alg;
- alg = crypto_alg_mod_lookup(name, 0, CRYPTO_ALG_ASYNC);
+ alg = crypto_alg_mod_lookup(name, type, mask);
if (IS_ERR(alg)) {
err = PTR_ERR(alg);
goto err;
@@ -395,6 +396,11 @@ err:
return ERR_PTR(err);
}
+struct crypto_tfm *crypto_alloc_tfm(const char *name, u32 flags)
+{
+ return crypto_alloc_tfm_base(name, flags, 0, CRYPTO_ALG_ASYNC);
+}
+
/*
* crypto_alloc_base - Locate algorithm and allocate transform
* @alg_name: Name of algorithm
@@ -416,35 +422,7 @@ err:
*/
struct crypto_tfm *crypto_alloc_base(const char *alg_name, u32 type, u32 mask)
{
- struct crypto_tfm *tfm;
- int err;
-
- for (;;) {
- struct crypto_alg *alg;
-
- alg = crypto_alg_mod_lookup(alg_name, type, mask);
- if (IS_ERR(alg)) {
- err = PTR_ERR(alg);
- goto err;
- }
-
- tfm = __crypto_alloc_tfm(alg, 0);
- if (!IS_ERR(tfm))
- return tfm;
-
- crypto_mod_put(alg);
- err = PTR_ERR(tfm);
-
-err:
- if (err != -EAGAIN)
- break;
- if (signal_pending(current)) {
- err = -EINTR;
- break;
- }
- }
-
- return ERR_PTR(err);
+ return crypto_alloc_tfm_base(alg_name, 0, type, mask);
}
EXPORT_SYMBOL_GPL(crypto_alloc_base);
next prev parent reply other threads:[~2006-10-09 9:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-09 8:58 [PATCH 1/2] crypto: fix crypto_alloc_{tfm,base}() return value Akinobu Mita
2006-10-09 9:01 ` Akinobu Mita [this message]
2006-10-09 11:14 ` Herbert Xu
2006-10-09 11:55 ` Akinobu Mita
2006-10-10 3:53 ` Herbert Xu
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=20061009090122.GA6129@localhost \
--to=akinobu.mita@gmail.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-kernel@vger.kernel.org \
/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