summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictoria Milhoan <vicki.milhoan@freescale.com>2014-11-03 15:28:10 -0700
committerNitin Garg <nitin.garg@freescale.com>2015-01-15 21:19:57 -0600
commit4563a63cb0b6a049080ab1204282f6933dc2d6b2 (patch)
tree49babece20d3b4acfda6f50e6f8daa13ba6a94b3
parent24574e576aa27a1d05c5d1231266a8c2f5be2009 (diff)
MLK-9710-5 Unregister Secure Memory platform device upon shutdown
Unregister Secure Memory platform device when the Secure Memory module is shut down. This allows the Secure Memory module to be inserted again successfully. Signed-off-by: Victoria Milhoan <vicki.milhoan@freescale.com> (cherry picked from commit 785456f38234e64618ee9c74ab4258f39f00e73c)
-rw-r--r--drivers/crypto/caam/sm.h1
-rw-r--r--drivers/crypto/caam/sm_store.c11
2 files changed, 12 insertions, 0 deletions
diff --git a/drivers/crypto/caam/sm.h b/drivers/crypto/caam/sm.h
index 51020de82edb..c8114d126700 100644
--- a/drivers/crypto/caam/sm.h
+++ b/drivers/crypto/caam/sm.h
@@ -93,6 +93,7 @@ struct sm_page_descriptor {
struct caam_drv_private_sm {
struct device *parentdev; /* this ends up as the controller */
struct device *smringdev; /* ring that owns this instance */
+ struct platform_device *sm_pdev; /* Secure Memory platform device */
spinlock_t kslock ____cacheline_aligned;
/* Default parameters for geometry */
diff --git a/drivers/crypto/caam/sm_store.c b/drivers/crypto/caam/sm_store.c
index 5562b74ad558..51c1f2ee93e4 100644
--- a/drivers/crypto/caam/sm_store.c
+++ b/drivers/crypto/caam/sm_store.c
@@ -979,6 +979,9 @@ int caam_sm_startup(struct platform_device *pdev)
kfree(smpriv);
return -EINVAL;
}
+
+ /* Save a pointer to the platform device for Secure Memory */
+ smpriv->sm_pdev = sm_pdev;
smdev = &sm_pdev->dev;
dev_set_drvdata(smdev, smpriv);
ctrlpriv->smdev = smdev;
@@ -1092,8 +1095,16 @@ void caam_sm_shutdown(struct platform_device *pdev)
ctrldev = &pdev->dev;
priv = dev_get_drvdata(ctrldev);
smdev = priv->smdev;
+
+ /* Return if resource not initialized by startup */
+ if (smdev == NULL)
+ return;
+
smpriv = dev_get_drvdata(smdev);
+ /* Remove Secure Memory Platform Device */
+ of_device_unregister(smpriv->sm_pdev);
+
kfree(smpriv->pagedesc);
kfree(smpriv);
}