From: Geert Uytterhoeven Add a type init function to crypto_tfm, so transforms can override the default action of calling the algorithm's cra_init() method. This will be used by the "comp" compatibility layer for the "pcomp" type, which needs to call the algorithm's coa_setup() method, in addition to the cra_init() method. Signed-off-by: Geert Uytterhoeven --- crypto/api.c | 20 ++++++++++++++++---- include/linux/crypto.h | 1 + 2 files changed, 17 insertions(+), 4 deletions(-) --- a/crypto/api.c +++ b/crypto/api.c @@ -390,8 +390,14 @@ struct crypto_tfm *__crypto_alloc_tfm(st if (err) goto out_free_tfm; - if (!tfm->exit && alg->cra_init && (err = alg->cra_init(tfm))) - goto cra_init_failed; + if (!tfm->exit) { + if (tfm->init) + err = tfm->init(tfm); + else if (alg->cra_init) + err = alg->cra_init(tfm); + if (err) + goto cra_init_failed; + } goto out; @@ -487,8 +493,14 @@ struct crypto_tfm *crypto_create_tfm(str if (err) goto out_free_tfm; - if (!tfm->exit && alg->cra_init && (err = alg->cra_init(tfm))) - goto cra_init_failed; + if (!tfm->exit) { + if (tfm->init) + err = tfm->init(tfm); + else if (alg->cra_init) + err = alg->cra_init(tfm); + if (err) + goto cra_init_failed; + } goto out; --- a/include/linux/crypto.h +++ b/include/linux/crypto.h @@ -527,6 +527,7 @@ struct crypto_tfm { struct rng_tfm rng; } crt_u; + int (*init)(struct crypto_tfm *tfm); void (*exit)(struct crypto_tfm *tfm); struct crypto_alg *__crt_alg; -- With kind regards, Geert Uytterhoeven Software Architect Sony Techsoft Centre Europe The Corporate Village · Da Vincilaan 7-D1 · B-1935 Zaventem · Belgium Phone: +32 (0)2 700 8453 Fax: +32 (0)2 700 8622 E-mail: Geert.Uytterhoeven@sonycom.com Internet: http://www.sony-europe.com/ A division of Sony Europe (Belgium) N.V. VAT BE 0413.825.160 · RPR Brussels Fortis · BIC GEBABEBB · IBAN BE41293037680010 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/