* [PATCH 1/2] crypto: crypto4xx_core: avoid explicit resource @ 2024-10-10 19:48 Rosen Penev 2024-10-10 19:48 ` [PATCH 2/2] crypto: crypto4xx_core: use devm in probe Rosen Penev 2024-10-19 11:58 ` [PATCH 1/2] crypto: crypto4xx_core: avoid explicit resource Herbert Xu 0 siblings, 2 replies; 3+ messages in thread From: Rosen Penev @ 2024-10-10 19:48 UTC (permalink / raw) To: linux-crypto Cc: Herbert Xu, David S. Miller, Rosen Penev, Uwe Kleine-König, open list There's no use for the resource struct. Just use devm_platform_ioremap_resource to simplify the code. Avoids the need to iounmap manually. Signed-off-by: Rosen Penev <rosenp@gmail.com> --- drivers/crypto/amcc/crypto4xx_core.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/crypto/amcc/crypto4xx_core.c b/drivers/crypto/amcc/crypto4xx_core.c index 6006703fb6d7..5ebbf83b4f3e 100644 --- a/drivers/crypto/amcc/crypto4xx_core.c +++ b/drivers/crypto/amcc/crypto4xx_core.c @@ -653,7 +653,6 @@ static void crypto4xx_stop_all(struct crypto4xx_core_device *core_dev) crypto4xx_destroy_pdr(core_dev->dev); crypto4xx_destroy_gdr(core_dev->dev); crypto4xx_destroy_sdr(core_dev->dev); - iounmap(core_dev->dev->ce_base); kfree(core_dev->dev); kfree(core_dev); } @@ -1333,17 +1332,12 @@ static struct crypto4xx_alg_common crypto4xx_alg[] = { static int crypto4xx_probe(struct platform_device *ofdev) { int rc; - struct resource res; struct device *dev = &ofdev->dev; struct crypto4xx_core_device *core_dev; struct device_node *np; u32 pvr; bool is_revb = true; - rc = of_address_to_resource(ofdev->dev.of_node, 0, &res); - if (rc) - return -ENODEV; - np = of_find_compatible_node(NULL, NULL, "amcc,ppc460ex-crypto"); if (np) { mtdcri(SDR0, PPC460EX_SDR0_SRST, @@ -1421,11 +1415,11 @@ static int crypto4xx_probe(struct platform_device *ofdev) tasklet_init(&core_dev->tasklet, crypto4xx_bh_tasklet_cb, (unsigned long) dev); - core_dev->dev->ce_base = of_iomap(ofdev->dev.of_node, 0); - if (!core_dev->dev->ce_base) { - dev_err(dev, "failed to of_iomap\n"); - rc = -ENOMEM; - goto err_iomap; + core_dev->dev->ce_base = devm_platform_ioremap_resource(ofdev, 0); + if (IS_ERR(core_dev->dev->ce_base)) { + dev_err(&ofdev->dev, "failed to ioremap resource"); + rc = PTR_ERR(core_dev->dev->ce_base); + goto err_build_sdr; } /* Register for Crypto isr, Crypto Engine IRQ */ @@ -1453,7 +1447,6 @@ static int crypto4xx_probe(struct platform_device *ofdev) free_irq(core_dev->irq, dev); err_request_irq: irq_dispose_mapping(core_dev->irq); - iounmap(core_dev->dev->ce_base); err_iomap: tasklet_kill(&core_dev->tasklet); err_build_sdr: -- 2.46.2 ^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/2] crypto: crypto4xx_core: use devm in probe 2024-10-10 19:48 [PATCH 1/2] crypto: crypto4xx_core: avoid explicit resource Rosen Penev @ 2024-10-10 19:48 ` Rosen Penev 2024-10-19 11:58 ` [PATCH 1/2] crypto: crypto4xx_core: avoid explicit resource Herbert Xu 1 sibling, 0 replies; 3+ messages in thread From: Rosen Penev @ 2024-10-10 19:48 UTC (permalink / raw) To: linux-crypto Cc: Herbert Xu, David S. Miller, Rosen Penev, Uwe Kleine-König, open list Allows removing some gotos and simplifying remove a bit. Tested Cisco MX60W. Signed-off-by: Rosen Penev <rosenp@gmail.com> --- drivers/crypto/amcc/crypto4xx_core.c | 39 ++++++++++------------------ 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/drivers/crypto/amcc/crypto4xx_core.c b/drivers/crypto/amcc/crypto4xx_core.c index 5ebbf83b4f3e..4e9aa1c37fc7 100644 --- a/drivers/crypto/amcc/crypto4xx_core.c +++ b/drivers/crypto/amcc/crypto4xx_core.c @@ -653,8 +653,6 @@ static void crypto4xx_stop_all(struct crypto4xx_core_device *core_dev) crypto4xx_destroy_pdr(core_dev->dev); crypto4xx_destroy_gdr(core_dev->dev); crypto4xx_destroy_sdr(core_dev->dev); - kfree(core_dev->dev); - kfree(core_dev); } static u32 get_next_gd(u32 current) @@ -1368,16 +1366,17 @@ static int crypto4xx_probe(struct platform_device *ofdev) of_node_put(np); - core_dev = kzalloc(sizeof(struct crypto4xx_core_device), GFP_KERNEL); + core_dev = devm_kzalloc( + &ofdev->dev, sizeof(struct crypto4xx_core_device), GFP_KERNEL); if (!core_dev) return -ENOMEM; dev_set_drvdata(dev, core_dev); core_dev->ofdev = ofdev; - core_dev->dev = kzalloc(sizeof(struct crypto4xx_device), GFP_KERNEL); - rc = -ENOMEM; + core_dev->dev = devm_kzalloc( + &ofdev->dev, sizeof(struct crypto4xx_device), GFP_KERNEL); if (!core_dev->dev) - goto err_alloc_dev; + return -ENOMEM; /* * Older version of 460EX/GT have a hardware bug. @@ -1396,7 +1395,9 @@ static int crypto4xx_probe(struct platform_device *ofdev) core_dev->dev->core_dev = core_dev; core_dev->dev->is_revb = is_revb; core_dev->device = dev; - mutex_init(&core_dev->rng_lock); + rc = devm_mutex_init(&ofdev->dev, &core_dev->rng_lock); + if (rc) + return rc; spin_lock_init(&core_dev->lock); INIT_LIST_HEAD(&core_dev->dev->alg_list); ratelimit_default_init(&core_dev->dev->aead_ratelimit); @@ -1424,12 +1425,12 @@ static int crypto4xx_probe(struct platform_device *ofdev) /* Register for Crypto isr, Crypto Engine IRQ */ core_dev->irq = irq_of_parse_and_map(ofdev->dev.of_node, 0); - rc = request_irq(core_dev->irq, is_revb ? - crypto4xx_ce_interrupt_handler_revb : - crypto4xx_ce_interrupt_handler, 0, - KBUILD_MODNAME, dev); + rc = devm_request_irq(&ofdev->dev, core_dev->irq, + is_revb ? crypto4xx_ce_interrupt_handler_revb : + crypto4xx_ce_interrupt_handler, + 0, KBUILD_MODNAME, dev); if (rc) - goto err_request_irq; + goto err_iomap; /* need to setup pdr, rdr, gdr and sdr before this */ crypto4xx_hw_init(core_dev->dev); @@ -1438,25 +1439,17 @@ static int crypto4xx_probe(struct platform_device *ofdev) rc = crypto4xx_register_alg(core_dev->dev, crypto4xx_alg, ARRAY_SIZE(crypto4xx_alg)); if (rc) - goto err_start_dev; + goto err_iomap; ppc4xx_trng_probe(core_dev); return 0; -err_start_dev: - free_irq(core_dev->irq, dev); -err_request_irq: - irq_dispose_mapping(core_dev->irq); err_iomap: tasklet_kill(&core_dev->tasklet); err_build_sdr: crypto4xx_destroy_sdr(core_dev->dev); crypto4xx_destroy_gdr(core_dev->dev); crypto4xx_destroy_pdr(core_dev->dev); - kfree(core_dev->dev); -err_alloc_dev: - kfree(core_dev); - return rc; } @@ -1467,13 +1460,9 @@ static void crypto4xx_remove(struct platform_device *ofdev) ppc4xx_trng_remove(core_dev); - free_irq(core_dev->irq, dev); - irq_dispose_mapping(core_dev->irq); - tasklet_kill(&core_dev->tasklet); /* Un-register with Linux CryptoAPI */ crypto4xx_unregister_alg(core_dev->dev); - mutex_destroy(&core_dev->rng_lock); /* Free all allocated memory */ crypto4xx_stop_all(core_dev); } -- 2.46.2 ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] crypto: crypto4xx_core: avoid explicit resource 2024-10-10 19:48 [PATCH 1/2] crypto: crypto4xx_core: avoid explicit resource Rosen Penev 2024-10-10 19:48 ` [PATCH 2/2] crypto: crypto4xx_core: use devm in probe Rosen Penev @ 2024-10-19 11:58 ` Herbert Xu 1 sibling, 0 replies; 3+ messages in thread From: Herbert Xu @ 2024-10-19 11:58 UTC (permalink / raw) To: Rosen Penev Cc: linux-crypto, David S. Miller, Uwe Kleine-König, open list On Thu, Oct 10, 2024 at 12:48:20PM -0700, Rosen Penev wrote: > There's no use for the resource struct. Just use > devm_platform_ioremap_resource to simplify the code. > > Avoids the need to iounmap manually. > > Signed-off-by: Rosen Penev <rosenp@gmail.com> > --- > drivers/crypto/amcc/crypto4xx_core.c | 17 +++++------------ > 1 file changed, 5 insertions(+), 12 deletions(-) All applied. Thanks. -- Email: Herbert Xu <herbert@gondor.apana.org.au> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-10-19 11:58 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2024-10-10 19:48 [PATCH 1/2] crypto: crypto4xx_core: avoid explicit resource Rosen Penev 2024-10-10 19:48 ` [PATCH 2/2] crypto: crypto4xx_core: use devm in probe Rosen Penev 2024-10-19 11:58 ` [PATCH 1/2] crypto: crypto4xx_core: avoid explicit resource Herbert Xu
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®