Commit f2ac72e8268d9559c3114d5a22679f91f80a2238

Authored by Herbert Xu
1 parent fd09d7facb

crypto: api - Add new template create function

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>

Showing 2 changed files with 6 additions and 0 deletions Side-by-side Diff

... ... @@ -68,6 +68,11 @@
68 68 goto err;
69 69  
70 70 do {
  71 + if (tmpl->create) {
  72 + err = tmpl->create(tmpl, param->tb);
  73 + continue;
  74 + }
  75 +
71 76 inst = tmpl->alloc(param->tb);
72 77 if (IS_ERR(inst))
73 78 err = PTR_ERR(inst);
include/crypto/algapi.h
... ... @@ -52,6 +52,7 @@
52 52  
53 53 struct crypto_instance *(*alloc)(struct rtattr **tb);
54 54 void (*free)(struct crypto_instance *inst);
  55 + int (*create)(struct crypto_template *tmpl, struct rtattr **tb);
55 56  
56 57 char name[CRYPTO_MAX_ALG_NAME];
57 58 };