| b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame] | 1 | From 7200bc3a88315a59e7094bf111c7816f0298923f Mon Sep 17 00:00:00 2001 |
| 2 | From: Andrey Smirnov <andrew.smirnov@gmail.com> |
| 3 | Date: Tue, 22 Oct 2019 08:30:12 -0700 |
| 4 | Subject: [PATCH] crypto: caam - use devres to populate platform devices |
| 5 | MIME-Version: 1.0 |
| 6 | Content-Type: text/plain; charset=UTF-8 |
| 7 | Content-Transfer-Encoding: 8bit |
| 8 | |
| 9 | Use devres to de-initialize the RNG and drop explicit de-initialization |
| 10 | code in caam_remove(). |
| 11 | |
| 12 | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> |
| 13 | Reviewed-by: Horia Geantă <horia.geanta@nxp.com> |
| 14 | Cc: Chris Healy <cphealy@gmail.com> |
| 15 | Cc: Lucas Stach <l.stach@pengutronix.de> |
| 16 | Cc: Horia Geantă <horia.geanta@nxp.com> |
| 17 | Cc: Herbert Xu <herbert@gondor.apana.org.au> |
| 18 | Cc: Iuliana Prodan <iuliana.prodan@nxp.com> |
| 19 | Cc: linux-crypto@vger.kernel.org |
| 20 | Cc: linux-kernel@vger.kernel.org |
| 21 | Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> |
| 22 | (cherry picked from commit 1a1c4f004444ebb962a02b7fc6d534e0f2ed9acb) |
| 23 | --- |
| 24 | drivers/crypto/caam/ctrl.c | 26 +++----------------------- |
| 25 | 1 file changed, 3 insertions(+), 23 deletions(-) |
| 26 | |
| 27 | --- a/drivers/crypto/caam/ctrl.c |
| 28 | +++ b/drivers/crypto/caam/ctrl.c |
| 29 | @@ -321,20 +321,6 @@ static int instantiate_rng(struct device |
| 30 | return ret; |
| 31 | } |
| 32 | |
| 33 | -static int caam_remove(struct platform_device *pdev) |
| 34 | -{ |
| 35 | - struct device *ctrldev; |
| 36 | - struct caam_drv_private *ctrlpriv; |
| 37 | - |
| 38 | - ctrldev = &pdev->dev; |
| 39 | - ctrlpriv = dev_get_drvdata(ctrldev); |
| 40 | - |
| 41 | - /* Remove platform devices under the crypto node */ |
| 42 | - of_platform_depopulate(ctrldev); |
| 43 | - |
| 44 | - return 0; |
| 45 | -} |
| 46 | - |
| 47 | /* |
| 48 | * kick_trng - sets the various parameters for enabling the initialization |
| 49 | * of the RNG4 block in CAAM |
| 50 | @@ -759,7 +745,7 @@ static int caam_probe(struct platform_de |
| 51 | #endif |
| 52 | } |
| 53 | |
| 54 | - ret = of_platform_populate(nprop, caam_match, NULL, dev); |
| 55 | + ret = devm_of_platform_populate(dev); |
| 56 | if (ret) { |
| 57 | dev_err(dev, "JR platform devices creation error\n"); |
| 58 | return ret; |
| 59 | @@ -781,8 +767,7 @@ static int caam_probe(struct platform_de |
| 60 | /* If no QI and no rings specified, quit and go home */ |
| 61 | if ((!ctrlpriv->qi_present) && (!ctrlpriv->total_jobrs)) { |
| 62 | dev_err(dev, "no queues configured, terminating\n"); |
| 63 | - ret = -ENOMEM; |
| 64 | - goto caam_remove; |
| 65 | + return -ENOMEM; |
| 66 | } |
| 67 | |
| 68 | if (ctrlpriv->era < 10) |
| 69 | @@ -845,7 +830,7 @@ static int caam_probe(struct platform_de |
| 70 | } while ((ret == -EAGAIN) && (ent_delay < RTSDCTL_ENT_DLY_MAX)); |
| 71 | if (ret) { |
| 72 | dev_err(dev, "failed to instantiate RNG"); |
| 73 | - goto caam_remove; |
| 74 | + return ret; |
| 75 | } |
| 76 | /* |
| 77 | * Set handles init'ed by this module as the complement of the |
| 78 | @@ -919,10 +904,6 @@ static int caam_probe(struct platform_de |
| 79 | &ctrlpriv->ctl_tdsk_wrap); |
| 80 | #endif |
| 81 | return 0; |
| 82 | - |
| 83 | -caam_remove: |
| 84 | - caam_remove(pdev); |
| 85 | - return ret; |
| 86 | } |
| 87 | |
| 88 | static struct platform_driver caam_driver = { |
| 89 | @@ -931,7 +912,6 @@ static struct platform_driver caam_drive |
| 90 | .of_match_table = caam_match, |
| 91 | }, |
| 92 | .probe = caam_probe, |
| 93 | - .remove = caam_remove, |
| 94 | }; |
| 95 | |
| 96 | module_platform_driver(caam_driver); |