diff options
-rw-r--r-- | drivers/crypto/ccp/ccp-dev.c | 15 | ||||
-rw-r--r-- | drivers/crypto/ccp/ccp-pci.c | 3 | ||||
-rw-r--r-- | include/linux/ccp.h | 12 |
3 files changed, 29 insertions, 1 deletions
diff --git a/drivers/crypto/ccp/ccp-dev.c b/drivers/crypto/ccp/ccp-dev.c index b2038a7e91e1..c3bc21264600 100644 --- a/drivers/crypto/ccp/ccp-dev.c +++ b/drivers/crypto/ccp/ccp-dev.c | |||
@@ -552,6 +552,7 @@ static const struct x86_cpu_id ccp_support[] = { | |||
552 | static int __init ccp_mod_init(void) | 552 | static int __init ccp_mod_init(void) |
553 | { | 553 | { |
554 | struct cpuinfo_x86 *cpuinfo = &boot_cpu_data; | 554 | struct cpuinfo_x86 *cpuinfo = &boot_cpu_data; |
555 | int ret; | ||
555 | 556 | ||
556 | if (!x86_match_cpu(ccp_support)) | 557 | if (!x86_match_cpu(ccp_support)) |
557 | return -ENODEV; | 558 | return -ENODEV; |
@@ -560,7 +561,19 @@ static int __init ccp_mod_init(void) | |||
560 | case 22: | 561 | case 22: |
561 | if ((cpuinfo->x86_model < 48) || (cpuinfo->x86_model > 63)) | 562 | if ((cpuinfo->x86_model < 48) || (cpuinfo->x86_model > 63)) |
562 | return -ENODEV; | 563 | return -ENODEV; |
563 | return ccp_pci_init(); | 564 | |
565 | ret = ccp_pci_init(); | ||
566 | if (ret) | ||
567 | return ret; | ||
568 | |||
569 | /* Don't leave the driver loaded if init failed */ | ||
570 | if (!ccp_get_device()) { | ||
571 | ccp_pci_exit(); | ||
572 | return -ENODEV; | ||
573 | } | ||
574 | |||
575 | return 0; | ||
576 | |||
564 | break; | 577 | break; |
565 | } | 578 | } |
566 | 579 | ||
diff --git a/drivers/crypto/ccp/ccp-pci.c b/drivers/crypto/ccp/ccp-pci.c index f08c16d370cd..93319f9db753 100644 --- a/drivers/crypto/ccp/ccp-pci.c +++ b/drivers/crypto/ccp/ccp-pci.c | |||
@@ -267,6 +267,9 @@ static void ccp_pci_remove(struct pci_dev *pdev) | |||
267 | struct device *dev = &pdev->dev; | 267 | struct device *dev = &pdev->dev; |
268 | struct ccp_device *ccp = dev_get_drvdata(dev); | 268 | struct ccp_device *ccp = dev_get_drvdata(dev); |
269 | 269 | ||
270 | if (!ccp) | ||
271 | return; | ||
272 | |||
270 | ccp_destroy(ccp); | 273 | ccp_destroy(ccp); |
271 | 274 | ||
272 | pci_iounmap(pdev, ccp->io_map); | 275 | pci_iounmap(pdev, ccp->io_map); |
diff --git a/include/linux/ccp.h b/include/linux/ccp.h index 12f1cfdbd3a3..b941ab9f762b 100644 --- a/include/linux/ccp.h +++ b/include/linux/ccp.h | |||
@@ -23,6 +23,9 @@ | |||
23 | struct ccp_device; | 23 | struct ccp_device; |
24 | struct ccp_cmd; | 24 | struct ccp_cmd; |
25 | 25 | ||
26 | #if defined(CONFIG_CRYPTO_DEV_CCP_DD) || \ | ||
27 | defined(CONFIG_CRYPTO_DEV_CCP_DD_MODULE) | ||
28 | |||
26 | /** | 29 | /** |
27 | * ccp_enqueue_cmd - queue an operation for processing by the CCP | 30 | * ccp_enqueue_cmd - queue an operation for processing by the CCP |
28 | * | 31 | * |
@@ -48,6 +51,15 @@ struct ccp_cmd; | |||
48 | */ | 51 | */ |
49 | int ccp_enqueue_cmd(struct ccp_cmd *cmd); | 52 | int ccp_enqueue_cmd(struct ccp_cmd *cmd); |
50 | 53 | ||
54 | #else /* CONFIG_CRYPTO_DEV_CCP_DD is not enabled */ | ||
55 | |||
56 | static inline int ccp_enqueue_cmd(struct ccp_cmd *cmd) | ||
57 | { | ||
58 | return -ENODEV; | ||
59 | } | ||
60 | |||
61 | #endif /* CONFIG_CRYPTO_DEV_CCP_DD */ | ||
62 | |||
51 | 63 | ||
52 | /***** AES engine *****/ | 64 | /***** AES engine *****/ |
53 | /** | 65 | /** |