crypto: api - Add new template create function
authorHerbert Xu <herbert@gondor.apana.org.au>
Tue, 7 Jul 2009 04:30:33 +0000 (12:30 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Tue, 7 Jul 2009 04:30:33 +0000 (12:30 +0800)
This patch introduces the template->create function intended
to replace the existing alloc function.  The intention is for
create to handle the registration directly, whereas currently
the caller of alloc has to handle the registration.

This allows type-specific code to be run prior to registration.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/algboss.c
include/crypto/algapi.h

index 9908dd830c2631041c3a681b3efae8b4eb687e39..412241ce4cfae25822a6beccf9360c9f52ccc89f 100644 (file)
@@ -68,6 +68,11 @@ static int cryptomgr_probe(void *data)
                goto err;
 
        do {
+               if (tmpl->create) {
+                       err = tmpl->create(tmpl, param->tb);
+                       continue;
+               }
+
                inst = tmpl->alloc(param->tb);
                if (IS_ERR(inst))
                        err = PTR_ERR(inst);
index 010545436efa22593f4a124c9a68849f78a85872..ce010a3464209a17024bbb074268dd73df762881 100644 (file)
@@ -52,6 +52,7 @@ struct crypto_template {
 
        struct crypto_instance *(*alloc)(struct rtattr **tb);
        void (*free)(struct crypto_instance *inst);
+       int (*create)(struct crypto_template *tmpl, struct rtattr **tb);
 
        char name[CRYPTO_MAX_ALG_NAME];
 };