aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/crypto
diff options
context:
space:
mode:
authorFabio Estevam <fabio.estevam@freescale.com>2015-08-21 12:51:58 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2015-08-24 10:07:39 -0400
commit31f44d150791c3fe923399a1159320acc4a9b3b4 (patch)
tree3ff5b02ef0fb2afbc683aa43ce69775109e60ff7 /drivers/crypto
parent9f587fa29f7e8ed6b8885cff51a51ace3ad85152 (diff)
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: Fabio Estevam <fabio.estevam@freescale.com> Reviewed-by: Horia Geant? <horia.geanta@freescale.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto')
-rw-r--r--drivers/crypto/caam/ctrl.c36
1 files changed, 25 insertions, 11 deletions
diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c
index 09c16f5ea97d..17102d62c707 100644
--- a/drivers/crypto/caam/ctrl.c
+++ b/drivers/crypto/caam/ctrl.c
@@ -474,27 +474,27 @@ static int caam_probe(struct platform_device *pdev)
474 ret = clk_prepare_enable(ctrlpriv->caam_ipg); 474 ret = clk_prepare_enable(ctrlpriv->caam_ipg);
475 if (ret < 0) { 475 if (ret < 0) {
476 dev_err(&pdev->dev, "can't enable CAAM ipg clock: %d\n", ret); 476 dev_err(&pdev->dev, "can't enable CAAM ipg clock: %d\n", ret);
477 return -ENODEV; 477 return ret;
478 } 478 }
479 479
480 ret = clk_prepare_enable(ctrlpriv->caam_mem); 480 ret = clk_prepare_enable(ctrlpriv->caam_mem);
481 if (ret < 0) { 481 if (ret < 0) {
482 dev_err(&pdev->dev, "can't enable CAAM secure mem clock: %d\n", 482 dev_err(&pdev->dev, "can't enable CAAM secure mem clock: %d\n",
483 ret); 483 ret);
484 return -ENODEV; 484 goto disable_caam_ipg;
485 } 485 }
486 486
487 ret = clk_prepare_enable(ctrlpriv->caam_aclk); 487 ret = clk_prepare_enable(ctrlpriv->caam_aclk);
488 if (ret < 0) { 488 if (ret < 0) {
489 dev_err(&pdev->dev, "can't enable CAAM aclk clock: %d\n", ret); 489 dev_err(&pdev->dev, "can't enable CAAM aclk clock: %d\n", ret);
490 return -ENODEV; 490 goto disable_caam_mem;
491 } 491 }
492 492
493 ret = clk_prepare_enable(ctrlpriv->caam_emi_slow); 493 ret = clk_prepare_enable(ctrlpriv->caam_emi_slow);
494 if (ret < 0) { 494 if (ret < 0) {
495 dev_err(&pdev->dev, "can't enable CAAM emi slow clock: %d\n", 495 dev_err(&pdev->dev, "can't enable CAAM emi slow clock: %d\n",
496 ret); 496 ret);
497 return -ENODEV; 497 goto disable_caam_aclk;
498 } 498 }
499 499
500 /* Get configuration properties from device tree */ 500 /* Get configuration properties from device tree */
@@ -502,7 +502,8 @@ static int caam_probe(struct platform_device *pdev)
502 ctrl = of_iomap(nprop, 0); 502 ctrl = of_iomap(nprop, 0);
503 if (ctrl == NULL) { 503 if (ctrl == NULL) {
504 dev_err(dev, "caam: of_iomap() failed\n"); 504 dev_err(dev, "caam: of_iomap() failed\n");
505 return -ENOMEM; 505 ret = -ENOMEM;
506 goto disable_caam_emi_slow;
506 } 507 }
507 /* Finding the page size for using the CTPR_MS register */ 508 /* Finding the page size for using the CTPR_MS register */
508 comp_params = rd_reg32(&ctrl->perfmon.comp_parms_ms); 509 comp_params = rd_reg32(&ctrl->perfmon.comp_parms_ms);
@@ -586,8 +587,8 @@ static int caam_probe(struct platform_device *pdev)
586 sizeof(struct platform_device *) * rspec, 587 sizeof(struct platform_device *) * rspec,
587 GFP_KERNEL); 588 GFP_KERNEL);
588 if (ctrlpriv->jrpdev == NULL) { 589 if (ctrlpriv->jrpdev == NULL) {
589 iounmap(ctrl); 590 ret = -ENOMEM;
590 return -ENOMEM; 591 goto iounmap_ctrl;
591 } 592 }
592 593
593 ring = 0; 594 ring = 0;
@@ -627,8 +628,8 @@ static int caam_probe(struct platform_device *pdev)
627 /* If no QI and no rings specified, quit and go home */ 628 /* If no QI and no rings specified, quit and go home */
628 if ((!ctrlpriv->qi_present) && (!ctrlpriv->total_jobrs)) { 629 if ((!ctrlpriv->qi_present) && (!ctrlpriv->total_jobrs)) {
629 dev_err(dev, "no queues configured, terminating\n"); 630 dev_err(dev, "no queues configured, terminating\n");
630 caam_remove(pdev); 631 ret = -ENOMEM;
631 return -ENOMEM; 632 goto caam_remove;
632 } 633 }
633 634
634 cha_vid_ls = rd_reg32(&ctrl->perfmon.cha_id_ls); 635 cha_vid_ls = rd_reg32(&ctrl->perfmon.cha_id_ls);
@@ -685,8 +686,7 @@ static int caam_probe(struct platform_device *pdev)
685 } while ((ret == -EAGAIN) && (ent_delay < RTSDCTL_ENT_DLY_MAX)); 686 } while ((ret == -EAGAIN) && (ent_delay < RTSDCTL_ENT_DLY_MAX));
686 if (ret) { 687 if (ret) {
687 dev_err(dev, "failed to instantiate RNG"); 688 dev_err(dev, "failed to instantiate RNG");
688 caam_remove(pdev); 689 goto caam_remove;
689 return ret;
690 } 690 }
691 /* 691 /*
692 * Set handles init'ed by this module as the complement of the 692 * 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 &ctrlpriv->ctl_tdsk_wrap); 790 &ctrlpriv->ctl_tdsk_wrap);
791#endif 791#endif
792 return 0; 792 return 0;
793
794caam_remove:
795 caam_remove(pdev);
796iounmap_ctrl:
797 iounmap(ctrl);
798disable_caam_emi_slow:
799 clk_disable_unprepare(ctrlpriv->caam_emi_slow);
800disable_caam_aclk:
801 clk_disable_unprepare(ctrlpriv->caam_aclk);
802disable_caam_mem:
803 clk_disable_unprepare(ctrlpriv->caam_mem);
804disable_caam_ipg:
805 clk_disable_unprepare(ctrlpriv->caam_ipg);
806 return ret;
793} 807}
794 808
795static struct of_device_id caam_match[] = { 809static struct of_device_id caam_match[] = {