]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
crypto: ccp - CCP device enabled/disabled changes
authorTom Lendacky <thomas.lendacky@amd.com>
Mon, 6 Jan 2014 19:34:29 +0000 (13:34 -0600)
committerHerbert Xu <herbert@gondor.apana.org.au>
Wed, 15 Jan 2014 03:33:40 +0000 (11:33 +0800)
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 <thomas.lendacky@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/ccp/ccp-dev.c
drivers/crypto/ccp/ccp-pci.c
include/linux/ccp.h

index b2038a7e91e1fc50f0a8b026490557374b749d06..c3bc21264600a2cde0bf3dbf5e01de214b96b132 100644 (file)
@@ -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;
        }
 
index f08c16d370cd2e6f675ea693b05c80646806ecda..93319f9db7531b5667542fe6b3c371046711fd5e 100644 (file)
@@ -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);
index 12f1cfdbd3a3344d020ddf093a9cda1b4adadf7a..b941ab9f762b1060c73abd33c1d914f2bba74615 100644 (file)
@@ -23,6 +23,9 @@
 struct ccp_device;
 struct ccp_cmd;
 
+#if defined(CONFIG_CRYPTO_DEV_CCP_DD) || \
+       defined(CONFIG_CRYPTO_DEV_CCP_DD_MODULE)
+
 /**
  * ccp_enqueue_cmd - queue an operation for processing by the CCP
  *
@@ -48,6 +51,15 @@ struct ccp_cmd;
  */
 int ccp_enqueue_cmd(struct ccp_cmd *cmd);
 
+#else /* CONFIG_CRYPTO_DEV_CCP_DD is not enabled */
+
+static inline int ccp_enqueue_cmd(struct ccp_cmd *cmd)
+{
+       return -ENODEV;
+}
+
+#endif /* CONFIG_CRYPTO_DEV_CCP_DD */
+
 
 /***** AES engine *****/
 /**