diff options
| author | Michal Ludvig <michal@logix.cz> | 2006-08-06 08:46:20 -0400 |
|---|---|---|
| committer | Herbert Xu <herbert@gondor.apana.org.au> | 2006-09-20 21:40:21 -0400 |
| commit | 1191f0a49390caf16f4a2831a4fc373757471ad6 (patch) | |
| tree | 8b92255ab82b777feade49a68cc0dc9691f1c665 /drivers/crypto | |
| parent | b14cdd6704c96474ba5c74b5959487beaa5ee1cd (diff) | |
[CRYPTO] padlock: Get rid of padlock-generic.c
Merge padlock-generic.c into padlock-aes.c and compile
AES as a standalone module. We won't make a monolithic
padlock.ko with all supported algorithms, instead we'll
compile each driver into its own module.
Signed-off-by: Michal Ludvig <michal@logix.cz>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto')
| -rw-r--r-- | drivers/crypto/Kconfig | 16 | ||||
| -rw-r--r-- | drivers/crypto/Makefile | 8 | ||||
| -rw-r--r-- | drivers/crypto/padlock-aes.c | 34 | ||||
| -rw-r--r-- | drivers/crypto/padlock-generic.c | 63 |
4 files changed, 42 insertions, 79 deletions
diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig index ba23683ab8c4..d260c86218fa 100644 --- a/drivers/crypto/Kconfig +++ b/drivers/crypto/Kconfig | |||
| @@ -1,24 +1,30 @@ | |||
| 1 | menu "Hardware crypto devices" | 1 | menu "Hardware crypto devices" |
| 2 | 2 | ||
| 3 | config CRYPTO_DEV_PADLOCK | 3 | config CRYPTO_DEV_PADLOCK |
| 4 | tristate "Support for VIA PadLock ACE" | 4 | bool "Support for VIA PadLock ACE" |
| 5 | depends on X86_32 | 5 | depends on X86_32 |
| 6 | select CRYPTO_ALGAPI | 6 | select CRYPTO_ALGAPI |
| 7 | default y | ||
| 7 | help | 8 | help |
| 8 | Some VIA processors come with an integrated crypto engine | 9 | Some VIA processors come with an integrated crypto engine |
| 9 | (so called VIA PadLock ACE, Advanced Cryptography Engine) | 10 | (so called VIA PadLock ACE, Advanced Cryptography Engine) |
| 10 | that provides instructions for very fast {en,de}cryption | 11 | that provides instructions for very fast cryptographic |
| 11 | with some algorithms. | 12 | operations with supported algorithms. |
| 12 | 13 | ||
| 13 | The instructions are used only when the CPU supports them. | 14 | The instructions are used only when the CPU supports them. |
| 14 | Otherwise software encryption is used. If you are unsure, | 15 | Otherwise software encryption is used. If you are unsure, |
| 15 | say Y. | 16 | say Y. |
| 16 | 17 | ||
| 17 | config CRYPTO_DEV_PADLOCK_AES | 18 | config CRYPTO_DEV_PADLOCK_AES |
| 18 | bool "Support for AES in VIA PadLock" | 19 | tristate "PadLock driver for AES algorithm" |
| 19 | depends on CRYPTO_DEV_PADLOCK | 20 | depends on CRYPTO_DEV_PADLOCK |
| 20 | default y | 21 | default m |
| 21 | help | 22 | help |
| 22 | Use VIA PadLock for AES algorithm. | 23 | Use VIA PadLock for AES algorithm. |
| 23 | 24 | ||
| 25 | Available in VIA C3 and newer CPUs. | ||
| 26 | |||
| 27 | If unsure say M. The compiled module will be | ||
| 28 | called padlock-aes.ko | ||
| 29 | |||
| 24 | endmenu | 30 | endmenu |
diff --git a/drivers/crypto/Makefile b/drivers/crypto/Makefile index 45426ca19a23..5e7d7d5e805a 100644 --- a/drivers/crypto/Makefile +++ b/drivers/crypto/Makefile | |||
| @@ -1,7 +1 @@ | |||
| 1 | obj-$(CONFIG_CRYPTO_DEV_PADLOCK_AES) += padlock-aes.o | ||
| 2 | obj-$(CONFIG_CRYPTO_DEV_PADLOCK) += padlock.o | ||
| 3 | |||
| 4 | padlock-objs-$(CONFIG_CRYPTO_DEV_PADLOCK_AES) += padlock-aes.o | ||
| 5 | |||
| 6 | padlock-objs := padlock-generic.o $(padlock-objs-y) | ||
| 7 | |||
diff --git a/drivers/crypto/padlock-aes.c b/drivers/crypto/padlock-aes.c index b643d71298a9..ee33bd6c1b77 100644 --- a/drivers/crypto/padlock-aes.c +++ b/drivers/crypto/padlock-aes.c | |||
| @@ -495,15 +495,41 @@ static struct crypto_alg aes_alg = { | |||
| 495 | } | 495 | } |
| 496 | }; | 496 | }; |
| 497 | 497 | ||
| 498 | int __init padlock_init_aes(void) | 498 | static int __init padlock_init(void) |
| 499 | { | 499 | { |
| 500 | printk(KERN_NOTICE PFX "Using VIA PadLock ACE for AES algorithm.\n"); | 500 | int ret; |
| 501 | |||
| 502 | if (!cpu_has_xcrypt) { | ||
| 503 | printk(KERN_ERR PFX "VIA PadLock not detected.\n"); | ||
| 504 | return -ENODEV; | ||
| 505 | } | ||
| 506 | |||
| 507 | if (!cpu_has_xcrypt_enabled) { | ||
| 508 | printk(KERN_ERR PFX "VIA PadLock detected, but not enabled. Hmm, strange...\n"); | ||
| 509 | return -ENODEV; | ||
| 510 | } | ||
| 501 | 511 | ||
| 502 | gen_tabs(); | 512 | gen_tabs(); |
| 503 | return crypto_register_alg(&aes_alg); | 513 | if ((ret = crypto_register_alg(&aes_alg))) { |
| 514 | printk(KERN_ERR PFX "VIA PadLock AES initialization failed.\n"); | ||
| 515 | return ret; | ||
| 516 | } | ||
| 517 | |||
| 518 | printk(KERN_NOTICE PFX "Using VIA PadLock ACE for AES algorithm.\n"); | ||
| 519 | |||
| 520 | return ret; | ||
| 504 | } | 521 | } |
| 505 | 522 | ||
| 506 | void __exit padlock_fini_aes(void) | 523 | static void __exit padlock_fini(void) |
| 507 | { | 524 | { |
| 508 | crypto_unregister_alg(&aes_alg); | 525 | crypto_unregister_alg(&aes_alg); |
| 509 | } | 526 | } |
| 527 | |||
| 528 | module_init(padlock_init); | ||
| 529 | module_exit(padlock_fini); | ||
| 530 | |||
| 531 | MODULE_DESCRIPTION("VIA PadLock AES algorithm support"); | ||
| 532 | MODULE_LICENSE("GPL"); | ||
| 533 | MODULE_AUTHOR("Michal Ludvig"); | ||
| 534 | |||
| 535 | MODULE_ALIAS("aes-padlock"); | ||
diff --git a/drivers/crypto/padlock-generic.c b/drivers/crypto/padlock-generic.c deleted file mode 100644 index 18cf0e8274a7..000000000000 --- a/drivers/crypto/padlock-generic.c +++ /dev/null | |||
| @@ -1,63 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Cryptographic API. | ||
| 3 | * | ||
| 4 | * Support for VIA PadLock hardware crypto engine. | ||
| 5 | * | ||
| 6 | * Copyright (c) 2004 Michal Ludvig <michal@logix.cz> | ||
| 7 | * | ||
| 8 | * This program is free software; you can redistribute it and/or modify | ||
| 9 | * it under the terms of the GNU General Public License as published by | ||
| 10 | * the Free Software Foundation; either version 2 of the License, or | ||
| 11 | * (at your option) any later version. | ||
| 12 | */ | ||
| 13 | |||
| 14 | #include <linux/module.h> | ||
| 15 | #include <linux/init.h> | ||
| 16 | #include <linux/types.h> | ||
| 17 | #include <linux/errno.h> | ||
| 18 | #include <linux/crypto.h> | ||
| 19 | #include <asm/byteorder.h> | ||
| 20 | #include "padlock.h" | ||
| 21 | |||
| 22 | static int __init | ||
| 23 | padlock_init(void) | ||
| 24 | { | ||
| 25 | int ret = -ENOSYS; | ||
| 26 | |||
| 27 | if (!cpu_has_xcrypt) { | ||
| 28 | printk(KERN_ERR PFX "VIA PadLock not detected.\n"); | ||
| 29 | return -ENODEV; | ||
| 30 | } | ||
| 31 | |||
| 32 | if (!cpu_has_xcrypt_enabled) { | ||
| 33 | printk(KERN_ERR PFX "VIA PadLock detected, but not enabled. Hmm, strange...\n"); | ||
| 34 | return -ENODEV; | ||
| 35 | } | ||
| 36 | |||
| 37 | #ifdef CONFIG_CRYPTO_DEV_PADLOCK_AES | ||
| 38 | if ((ret = padlock_init_aes())) { | ||
| 39 | printk(KERN_ERR PFX "VIA PadLock AES initialization failed.\n"); | ||
| 40 | return ret; | ||
| 41 | } | ||
| 42 | #endif | ||
| 43 | |||
| 44 | if (ret == -ENOSYS) | ||
| 45 | printk(KERN_ERR PFX "Hmm, VIA PadLock was compiled without any algorithm.\n"); | ||
| 46 | |||
| 47 | return ret; | ||
| 48 | } | ||
| 49 | |||
| 50 | static void __exit | ||
| 51 | padlock_fini(void) | ||
| 52 | { | ||
| 53 | #ifdef CONFIG_CRYPTO_DEV_PADLOCK_AES | ||
| 54 | padlock_fini_aes(); | ||
| 55 | #endif | ||
| 56 | } | ||
| 57 | |||
| 58 | module_init(padlock_init); | ||
| 59 | module_exit(padlock_fini); | ||
| 60 | |||
| 61 | MODULE_DESCRIPTION("VIA PadLock crypto engine support."); | ||
| 62 | MODULE_LICENSE("Dual BSD/GPL"); | ||
| 63 | MODULE_AUTHOR("Michal Ludvig"); | ||
