Commit 31f44d15 authored by Fabio Estevam's avatar Fabio Estevam Committed by Herbert Xu

crypto: caam - Fix the error handling in caam_probe

In the error path we should disable the resources that were previously
acquired, so fix the error handling accordingly.
Signed-off-by: default avatarFabio Estevam <fabio.estevam@freescale.com>
Reviewed-by: default avatarHoria Geant? <horia.geanta@freescale.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 9f587fa2
...@@ -474,27 +474,27 @@ static int caam_probe(struct platform_device *pdev) ...@@ -474,27 +474,27 @@ static int caam_probe(struct platform_device *pdev)
ret = clk_prepare_enable(ctrlpriv->caam_ipg); ret = clk_prepare_enable(ctrlpriv->caam_ipg);
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "can't enable CAAM ipg clock: %d\n", ret); dev_err(&pdev->dev, "can't enable CAAM ipg clock: %d\n", ret);
return -ENODEV; return ret;
} }
ret = clk_prepare_enable(ctrlpriv->caam_mem); ret = clk_prepare_enable(ctrlpriv->caam_mem);
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "can't enable CAAM secure mem clock: %d\n", dev_err(&pdev->dev, "can't enable CAAM secure mem clock: %d\n",
ret); ret);
return -ENODEV; goto disable_caam_ipg;
} }
ret = clk_prepare_enable(ctrlpriv->caam_aclk); ret = clk_prepare_enable(ctrlpriv->caam_aclk);
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "can't enable CAAM aclk clock: %d\n", ret); dev_err(&pdev->dev, "can't enable CAAM aclk clock: %d\n", ret);
return -ENODEV; goto disable_caam_mem;
} }
ret = clk_prepare_enable(ctrlpriv->caam_emi_slow); ret = clk_prepare_enable(ctrlpriv->caam_emi_slow);
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "can't enable CAAM emi slow clock: %d\n", dev_err(&pdev->dev, "can't enable CAAM emi slow clock: %d\n",
ret); ret);
return -ENODEV; goto disable_caam_aclk;
} }
/* Get configuration properties from device tree */ /* Get configuration properties from device tree */
...@@ -502,7 +502,8 @@ static int caam_probe(struct platform_device *pdev) ...@@ -502,7 +502,8 @@ static int caam_probe(struct platform_device *pdev)
ctrl = of_iomap(nprop, 0); ctrl = of_iomap(nprop, 0);
if (ctrl == NULL) { if (ctrl == NULL) {
dev_err(dev, "caam: of_iomap() failed\n"); dev_err(dev, "caam: of_iomap() failed\n");
return -ENOMEM; ret = -ENOMEM;
goto disable_caam_emi_slow;
} }
/* Finding the page size for using the CTPR_MS register */ /* Finding the page size for using the CTPR_MS register */
comp_params = rd_reg32(&ctrl->perfmon.comp_parms_ms); comp_params = rd_reg32(&ctrl->perfmon.comp_parms_ms);
...@@ -586,8 +587,8 @@ static int caam_probe(struct platform_device *pdev) ...@@ -586,8 +587,8 @@ static int caam_probe(struct platform_device *pdev)
sizeof(struct platform_device *) * rspec, sizeof(struct platform_device *) * rspec,
GFP_KERNEL); GFP_KERNEL);
if (ctrlpriv->jrpdev == NULL) { if (ctrlpriv->jrpdev == NULL) {
iounmap(ctrl); ret = -ENOMEM;
return -ENOMEM; goto iounmap_ctrl;
} }
ring = 0; ring = 0;
...@@ -627,8 +628,8 @@ static int caam_probe(struct platform_device *pdev) ...@@ -627,8 +628,8 @@ static int caam_probe(struct platform_device *pdev)
/* If no QI and no rings specified, quit and go home */ /* If no QI and no rings specified, quit and go home */
if ((!ctrlpriv->qi_present) && (!ctrlpriv->total_jobrs)) { if ((!ctrlpriv->qi_present) && (!ctrlpriv->total_jobrs)) {
dev_err(dev, "no queues configured, terminating\n"); dev_err(dev, "no queues configured, terminating\n");
caam_remove(pdev); ret = -ENOMEM;
return -ENOMEM; goto caam_remove;
} }
cha_vid_ls = rd_reg32(&ctrl->perfmon.cha_id_ls); cha_vid_ls = rd_reg32(&ctrl->perfmon.cha_id_ls);
...@@ -685,8 +686,7 @@ static int caam_probe(struct platform_device *pdev) ...@@ -685,8 +686,7 @@ static int caam_probe(struct platform_device *pdev)
} while ((ret == -EAGAIN) && (ent_delay < RTSDCTL_ENT_DLY_MAX)); } while ((ret == -EAGAIN) && (ent_delay < RTSDCTL_ENT_DLY_MAX));
if (ret) { if (ret) {
dev_err(dev, "failed to instantiate RNG"); dev_err(dev, "failed to instantiate RNG");
caam_remove(pdev); goto caam_remove;
return ret;
} }
/* /*
* Set handles init'ed by this module as the complement of the * Set handles init'ed by this module as the complement of the
...@@ -790,6 +790,20 @@ static int caam_probe(struct platform_device *pdev) ...@@ -790,6 +790,20 @@ static int caam_probe(struct platform_device *pdev)
&ctrlpriv->ctl_tdsk_wrap); &ctrlpriv->ctl_tdsk_wrap);
#endif #endif
return 0; return 0;
caam_remove:
caam_remove(pdev);
iounmap_ctrl:
iounmap(ctrl);
disable_caam_emi_slow:
clk_disable_unprepare(ctrlpriv->caam_emi_slow);
disable_caam_aclk:
clk_disable_unprepare(ctrlpriv->caam_aclk);
disable_caam_mem:
clk_disable_unprepare(ctrlpriv->caam_mem);
disable_caam_ipg:
clk_disable_unprepare(ctrlpriv->caam_ipg);
return ret;
} }
static struct of_device_id caam_match[] = { static struct of_device_id caam_match[] = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment