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)
Signed-off-by: Dan Douglass <dan.douglass@freescale.com>
Signed-off-by: Vipul Kumar <vipul_kumar@mentor.com>
This commit is contained in:
Victoria Milhoan 2014-11-03 15:28:10 -07:00 committed by Leonard Crestez
parent f78b660983
commit 997fb2ff88
2 changed files with 12 additions and 0 deletions

View File

@ -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 */

View File

@ -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);
}