summaryrefslogtreecommitdiff
path: root/drivers/crypto/ccp/ccp-dev.c
diff options
context:
space:
mode:
authorGary R Hook <gary.hook@amd.com>2016-03-01 13:49:15 -0600
committerHerbert Xu <herbert@gondor.apana.org.au>2016-03-11 21:19:16 +0800
commitc7019c4d739e79d7baaa13c86dcaaedec8113d70 (patch)
treec24da238ee41a0692db13c0903fc7d28b02deb3a /drivers/crypto/ccp/ccp-dev.c
parent553d2374db0bb3f48bbd29bef7ba2a4d1a3f325d (diff)
downloadlinux-c7019c4d739e79d7baaa13c86dcaaedec8113d70.tar.gz
crypto: ccp - CCP versioning support
Future hardware may introduce new algorithms wherein the driver will need to manage resources for different versions of the cryptographic coprocessor. This precursor patch determines the version of the available device, and marks and registers algorithms accordingly. A structure is added which manages the version-specific data. Signed-off-by: Gary R Hook <gary.hook@amd.com> Acked-by: Tom Lendacky <thomas.lendacky@amd.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/ccp/ccp-dev.c')
-rw-r--r--drivers/crypto/ccp/ccp-dev.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/drivers/crypto/ccp/ccp-dev.c b/drivers/crypto/ccp/ccp-dev.c
index dd71e673a109..5348512da643 100644
--- a/drivers/crypto/ccp/ccp-dev.c
+++ b/drivers/crypto/ccp/ccp-dev.c
@@ -150,6 +150,29 @@ int ccp_present(void)
EXPORT_SYMBOL_GPL(ccp_present);
/**
+ * ccp_version - get the version of the CCP device
+ *
+ * Returns the version from the first unit on the list;
+ * otherwise a zero if no CCP device is present
+ */
+unsigned int ccp_version(void)
+{
+ struct ccp_device *dp;
+ unsigned long flags;
+ int ret = 0;
+
+ read_lock_irqsave(&ccp_unit_lock, flags);
+ if (!list_empty(&ccp_units)) {
+ dp = list_first_entry(&ccp_units, struct ccp_device, entry);
+ ret = dp->vdata->version;
+ }
+ read_unlock_irqrestore(&ccp_unit_lock, flags);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(ccp_version);
+
+/**
* ccp_enqueue_cmd - queue an operation for processing by the CCP
*
* @cmd: ccp_cmd struct to be processed
@@ -664,6 +687,10 @@ bool ccp_queues_suspended(struct ccp_device *ccp)
}
#endif
+struct ccp_vdata ccpv3 = {
+ .version = CCP_VERSION(3, 0),
+};
+
static int __init ccp_mod_init(void)
{
#ifdef CONFIG_X86