diff options
author | Jussi Kivilinna <jussi.kivilinna@mbnet.fi> | 2012-05-11 09:00:54 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2012-05-15 03:25:33 -0400 |
commit | ef45b834319f8a18f257a40ba4bce6b829ef1708 (patch) | |
tree | 896c13f5b76fe9d0dd1e7bd8fd1c6b71f4bcca89 /arch/x86/crypto | |
parent | fa46ccb8eb960c62c1e5e3237085d4007788a345 (diff) |
crypto: aesni-intel - move more common code to ablk_init_common
ablk_*_init functions share more common code than what is currently in
ablk_init_common. Move all of the common code to ablk_init_common.
Cc: Huang Ying <ying.huang@intel.com>
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'arch/x86/crypto')
-rw-r--r-- | arch/x86/crypto/aesni-intel_glue.c | 70 |
1 files changed, 15 insertions, 55 deletions
diff --git a/arch/x86/crypto/aesni-intel_glue.c b/arch/x86/crypto/aesni-intel_glue.c index 20c622016629..ac7f5cd019e8 100644 --- a/arch/x86/crypto/aesni-intel_glue.c +++ b/arch/x86/crypto/aesni-intel_glue.c | |||
@@ -442,61 +442,42 @@ static void ablk_exit(struct crypto_tfm *tfm) | |||
442 | cryptd_free_ablkcipher(ctx->cryptd_tfm); | 442 | cryptd_free_ablkcipher(ctx->cryptd_tfm); |
443 | } | 443 | } |
444 | 444 | ||
445 | static void ablk_init_common(struct crypto_tfm *tfm, | 445 | static int ablk_init_common(struct crypto_tfm *tfm, const char *drv_name) |
446 | struct cryptd_ablkcipher *cryptd_tfm) | ||
447 | { | 446 | { |
448 | struct async_aes_ctx *ctx = crypto_tfm_ctx(tfm); | 447 | struct async_aes_ctx *ctx = crypto_tfm_ctx(tfm); |
448 | struct cryptd_ablkcipher *cryptd_tfm; | ||
449 | |||
450 | cryptd_tfm = cryptd_alloc_ablkcipher(drv_name, 0, 0); | ||
451 | if (IS_ERR(cryptd_tfm)) | ||
452 | return PTR_ERR(cryptd_tfm); | ||
449 | 453 | ||
450 | ctx->cryptd_tfm = cryptd_tfm; | 454 | ctx->cryptd_tfm = cryptd_tfm; |
451 | tfm->crt_ablkcipher.reqsize = sizeof(struct ablkcipher_request) + | 455 | tfm->crt_ablkcipher.reqsize = sizeof(struct ablkcipher_request) + |
452 | crypto_ablkcipher_reqsize(&cryptd_tfm->base); | 456 | crypto_ablkcipher_reqsize(&cryptd_tfm->base); |
457 | |||
458 | return 0; | ||
453 | } | 459 | } |
454 | 460 | ||
455 | static int ablk_ecb_init(struct crypto_tfm *tfm) | 461 | static int ablk_ecb_init(struct crypto_tfm *tfm) |
456 | { | 462 | { |
457 | struct cryptd_ablkcipher *cryptd_tfm; | 463 | return ablk_init_common(tfm, "__driver-ecb-aes-aesni"); |
458 | |||
459 | cryptd_tfm = cryptd_alloc_ablkcipher("__driver-ecb-aes-aesni", 0, 0); | ||
460 | if (IS_ERR(cryptd_tfm)) | ||
461 | return PTR_ERR(cryptd_tfm); | ||
462 | ablk_init_common(tfm, cryptd_tfm); | ||
463 | return 0; | ||
464 | } | 464 | } |
465 | 465 | ||
466 | static int ablk_cbc_init(struct crypto_tfm *tfm) | 466 | static int ablk_cbc_init(struct crypto_tfm *tfm) |
467 | { | 467 | { |
468 | struct cryptd_ablkcipher *cryptd_tfm; | 468 | return ablk_init_common(tfm, "__driver-cbc-aes-aesni"); |
469 | |||
470 | cryptd_tfm = cryptd_alloc_ablkcipher("__driver-cbc-aes-aesni", 0, 0); | ||
471 | if (IS_ERR(cryptd_tfm)) | ||
472 | return PTR_ERR(cryptd_tfm); | ||
473 | ablk_init_common(tfm, cryptd_tfm); | ||
474 | return 0; | ||
475 | } | 469 | } |
476 | 470 | ||
477 | #ifdef CONFIG_X86_64 | 471 | #ifdef CONFIG_X86_64 |
478 | static int ablk_ctr_init(struct crypto_tfm *tfm) | 472 | static int ablk_ctr_init(struct crypto_tfm *tfm) |
479 | { | 473 | { |
480 | struct cryptd_ablkcipher *cryptd_tfm; | 474 | return ablk_init_common(tfm, "__driver-ctr-aes-aesni"); |
481 | |||
482 | cryptd_tfm = cryptd_alloc_ablkcipher("__driver-ctr-aes-aesni", 0, 0); | ||
483 | if (IS_ERR(cryptd_tfm)) | ||
484 | return PTR_ERR(cryptd_tfm); | ||
485 | ablk_init_common(tfm, cryptd_tfm); | ||
486 | return 0; | ||
487 | } | 475 | } |
488 | 476 | ||
489 | #ifdef HAS_CTR | 477 | #ifdef HAS_CTR |
490 | static int ablk_rfc3686_ctr_init(struct crypto_tfm *tfm) | 478 | static int ablk_rfc3686_ctr_init(struct crypto_tfm *tfm) |
491 | { | 479 | { |
492 | struct cryptd_ablkcipher *cryptd_tfm; | 480 | return ablk_init_common(tfm, "rfc3686(__driver-ctr-aes-aesni)"); |
493 | |||
494 | cryptd_tfm = cryptd_alloc_ablkcipher( | ||
495 | "rfc3686(__driver-ctr-aes-aesni)", 0, 0); | ||
496 | if (IS_ERR(cryptd_tfm)) | ||
497 | return PTR_ERR(cryptd_tfm); | ||
498 | ablk_init_common(tfm, cryptd_tfm); | ||
499 | return 0; | ||
500 | } | 481 | } |
501 | #endif | 482 | #endif |
502 | #endif | 483 | #endif |
@@ -504,42 +485,21 @@ static int ablk_rfc3686_ctr_init(struct crypto_tfm *tfm) | |||
504 | #ifdef HAS_LRW | 485 | #ifdef HAS_LRW |
505 | static int ablk_lrw_init(struct crypto_tfm *tfm) | 486 | static int ablk_lrw_init(struct crypto_tfm *tfm) |
506 | { | 487 | { |
507 | struct cryptd_ablkcipher *cryptd_tfm; | 488 | return ablk_init_common(tfm, "fpu(lrw(__driver-aes-aesni))"); |
508 | |||
509 | cryptd_tfm = cryptd_alloc_ablkcipher("fpu(lrw(__driver-aes-aesni))", | ||
510 | 0, 0); | ||
511 | if (IS_ERR(cryptd_tfm)) | ||
512 | return PTR_ERR(cryptd_tfm); | ||
513 | ablk_init_common(tfm, cryptd_tfm); | ||
514 | return 0; | ||
515 | } | 489 | } |
516 | #endif | 490 | #endif |
517 | 491 | ||
518 | #ifdef HAS_PCBC | 492 | #ifdef HAS_PCBC |
519 | static int ablk_pcbc_init(struct crypto_tfm *tfm) | 493 | static int ablk_pcbc_init(struct crypto_tfm *tfm) |
520 | { | 494 | { |
521 | struct cryptd_ablkcipher *cryptd_tfm; | 495 | return ablk_init_common(tfm, "fpu(pcbc(__driver-aes-aesni))"); |
522 | |||
523 | cryptd_tfm = cryptd_alloc_ablkcipher("fpu(pcbc(__driver-aes-aesni))", | ||
524 | 0, 0); | ||
525 | if (IS_ERR(cryptd_tfm)) | ||
526 | return PTR_ERR(cryptd_tfm); | ||
527 | ablk_init_common(tfm, cryptd_tfm); | ||
528 | return 0; | ||
529 | } | 496 | } |
530 | #endif | 497 | #endif |
531 | 498 | ||
532 | #ifdef HAS_XTS | 499 | #ifdef HAS_XTS |
533 | static int ablk_xts_init(struct crypto_tfm *tfm) | 500 | static int ablk_xts_init(struct crypto_tfm *tfm) |
534 | { | 501 | { |
535 | struct cryptd_ablkcipher *cryptd_tfm; | 502 | return ablk_init_common(tfm, "fpu(xts(__driver-aes-aesni))"); |
536 | |||
537 | cryptd_tfm = cryptd_alloc_ablkcipher("fpu(xts(__driver-aes-aesni))", | ||
538 | 0, 0); | ||
539 | if (IS_ERR(cryptd_tfm)) | ||
540 | return PTR_ERR(cryptd_tfm); | ||
541 | ablk_init_common(tfm, cryptd_tfm); | ||
542 | return 0; | ||
543 | } | 503 | } |
544 | #endif | 504 | #endif |
545 | 505 | ||