Skip to content

Commit

Permalink
crypto: algapi - remove crypto_template::{alloc,free}()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
ebiggers authored and herbertx committed Jan 9, 2020
1 parent a39c66c commit a24a1fd
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 33 deletions.
5 changes: 0 additions & 5 deletions crypto/aead.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,6 @@ static void crypto_aead_free_instance(struct crypto_instance *inst)
{
struct aead_instance *aead = aead_instance(inst);

if (!aead->free) {
inst->tmpl->free(inst);
return;
}

aead->free(aead);
}

Expand Down
5 changes: 0 additions & 5 deletions crypto/ahash.c
Original file line number Diff line number Diff line change
Expand Up @@ -515,11 +515,6 @@ static void crypto_ahash_free_instance(struct crypto_instance *inst)
{
struct ahash_instance *ahash = ahash_instance(inst);

if (!ahash->free) {
inst->tmpl->free(inst);
return;
}

ahash->free(ahash);
}

Expand Down
5 changes: 0 additions & 5 deletions crypto/algapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,6 @@ static int crypto_check_alg(struct crypto_alg *alg)

static void crypto_free_instance(struct crypto_instance *inst)
{
if (!inst->alg.cra_type->free) {
inst->tmpl->free(inst);
return;
}

inst->alg.cra_type->free(inst);
}

Expand Down
12 changes: 1 addition & 11 deletions crypto/algboss.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,14 @@ static int cryptomgr_probe(void *data)
{
struct cryptomgr_param *param = data;
struct crypto_template *tmpl;
struct crypto_instance *inst;
int err;

tmpl = crypto_lookup_template(param->template);
if (!tmpl)
goto out;

do {
if (tmpl->create) {
err = tmpl->create(tmpl, param->tb);
continue;
}

inst = tmpl->alloc(param->tb);
if (IS_ERR(inst))
err = PTR_ERR(inst);
else if ((err = crypto_register_instance(tmpl, inst)))
tmpl->free(inst);
err = tmpl->create(tmpl, param->tb);
} while (err == -EAGAIN && !signal_pending(current));

crypto_tmpl_put(tmpl);
Expand Down
5 changes: 0 additions & 5 deletions crypto/shash.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,11 +427,6 @@ static void crypto_shash_free_instance(struct crypto_instance *inst)
{
struct shash_instance *shash = shash_instance(inst);

if (!shash->free) {
inst->tmpl->free(inst);
return;
}

shash->free(shash);
}

Expand Down
2 changes: 0 additions & 2 deletions include/crypto/algapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ struct crypto_template {
struct hlist_head instances;
struct module *module;

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];
Expand Down

0 comments on commit a24a1fd

Please sign in to comment.