Skip to content

Commit a24a1fd

Browse files
ebiggersherbertx
authored andcommitted
crypto: algapi - remove crypto_template::{alloc,free}()
Now that all templates provide a ->create() method which creates an instance, installs a strongly-typed ->free() method directly to it, and registers it, the older ->alloc() and ->free() methods in 'struct crypto_template' are no longer used. Remove them. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent a39c66c commit a24a1fd

6 files changed

Lines changed: 1 addition & 33 deletions

File tree

‎crypto/aead.c‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,6 @@ static void crypto_aead_free_instance(struct crypto_instance *inst)
185185
{
186186
struct aead_instance *aead = aead_instance(inst);
187187

188-
if (!aead->free) {
189-
inst->tmpl->free(inst);
190-
return;
191-
}
192-
193188
aead->free(aead);
194189
}
195190

‎crypto/ahash.c‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -515,11 +515,6 @@ static void crypto_ahash_free_instance(struct crypto_instance *inst)
515515
{
516516
struct ahash_instance *ahash = ahash_instance(inst);
517517

518-
if (!ahash->free) {
519-
inst->tmpl->free(inst);
520-
return;
521-
}
522-
523518
ahash->free(ahash);
524519
}
525520

‎crypto/algapi.c‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,6 @@ static int crypto_check_alg(struct crypto_alg *alg)
6565

6666
static void crypto_free_instance(struct crypto_instance *inst)
6767
{
68-
if (!inst->alg.cra_type->free) {
69-
inst->tmpl->free(inst);
70-
return;
71-
}
72-
7368
inst->alg.cra_type->free(inst);
7469
}
7570

‎crypto/algboss.c‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,24 +58,14 @@ static int cryptomgr_probe(void *data)
5858
{
5959
struct cryptomgr_param *param = data;
6060
struct crypto_template *tmpl;
61-
struct crypto_instance *inst;
6261
int err;
6362

6463
tmpl = crypto_lookup_template(param->template);
6564
if (!tmpl)
6665
goto out;
6766

6867
do {
69-
if (tmpl->create) {
70-
err = tmpl->create(tmpl, param->tb);
71-
continue;
72-
}
73-
74-
inst = tmpl->alloc(param->tb);
75-
if (IS_ERR(inst))
76-
err = PTR_ERR(inst);
77-
else if ((err = crypto_register_instance(tmpl, inst)))
78-
tmpl->free(inst);
68+
err = tmpl->create(tmpl, param->tb);
7969
} while (err == -EAGAIN && !signal_pending(current));
8070

8171
crypto_tmpl_put(tmpl);

‎crypto/shash.c‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -427,11 +427,6 @@ static void crypto_shash_free_instance(struct crypto_instance *inst)
427427
{
428428
struct shash_instance *shash = shash_instance(inst);
429429

430-
if (!shash->free) {
431-
inst->tmpl->free(inst);
432-
return;
433-
}
434-
435430
shash->free(shash);
436431
}
437432

‎include/crypto/algapi.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ struct crypto_template {
6363
struct hlist_head instances;
6464
struct module *module;
6565

66-
struct crypto_instance *(*alloc)(struct rtattr **tb);
67-
void (*free)(struct crypto_instance *inst);
6866
int (*create)(struct crypto_template *tmpl, struct rtattr **tb);
6967

7068
char name[CRYPTO_MAX_ALG_NAME];

0 commit comments

Comments
 (0)