From db34cf9122319d6fed59bd3ba26fa099a8ece432 Mon Sep 17 00:00:00 2001 From: Tom Lendacky Date: Mon, 6 Jan 2014 13:34:29 -0600 Subject: crypto: ccp - CCP device enabled/disabled changes The CCP cannot be hot-plugged so it will either be there or it won't. Do not allow the driver to stay loaded if the CCP does not successfully initialize. Provide stub routines in the ccp.h file that return -ENODEV if the CCP has not been configured in the build. Signed-off-by: Tom Lendacky Signed-off-by: Herbert Xu --- drivers/crypto/ccp/ccp-dev.c | 15 ++++++++++++++- drivers/crypto/ccp/ccp-pci.c | 3 +++ 2 files changed, 17 insertions(+), 1 deletion(-) (limited to 'drivers/crypto') diff --git a/drivers/crypto/ccp/ccp-dev.c b/drivers/crypto/ccp/ccp-dev.c index b2038a7e91e..c3bc2126460 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[] = { static int __init ccp_mod_init(void) { struct cpuinfo_x86 *cpuinfo = &boot_cpu_data; + int ret; if (!x86_match_cpu(ccp_support)) return -ENODEV; @@ -560,7 +561,19 @@ static int __init ccp_mod_init(void) case 22: if ((cpuinfo->x86_model < 48) || (cpuinfo->x86_model > 63)) return -ENODEV; - return ccp_pci_init(); + + ret = ccp_pci_init(); + if (ret) + return ret; + + /* Don't leave the driver loaded if init failed */ + if (!ccp_get_device()) { + ccp_pci_exit(); + return -ENODEV; + } + + return 0; + break; } diff --git a/drivers/crypto/ccp/ccp-pci.c b/drivers/crypto/ccp/ccp-pci.c index f08c16d370c..93319f9db75 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) struct device *dev = &pdev->dev; struct ccp_device *ccp = dev_get_drvdata(dev); + if (!ccp) + return; + ccp_destroy(ccp); pci_iounmap(pdev, ccp->io_map); -- cgit v1.2.3