* [PATCH 0/2] hwrng: imx-rngc - use devres for clk and hwrng
@ 2022-08-15 19:37 ` Martin Kaiser
0 siblings, 0 replies; 8+ messages in thread
From: Martin Kaiser @ 2022-08-15 19:37 UTC (permalink / raw)
To: Herbert Xu, Olivia Mackall
Cc: linux-crypto, linux-arm-kernel, linux-kernel, Martin Kaiser
Use devres for clock prepare+enable and for hwrng registration.
Martin Kaiser (2):
hwrng: imx-rngc - use devm_clk_get_enabled
hwrng: imx-rngc - use devres for hwrng registration
drivers/char/hw_random/imx-rngc.c | 37 ++++++-------------------------
1 file changed, 7 insertions(+), 30 deletions(-)
--
2.30.2
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 0/2] hwrng: imx-rngc - use devres for clk and hwrng
@ 2022-08-15 19:37 ` Martin Kaiser
0 siblings, 0 replies; 8+ messages in thread
From: Martin Kaiser @ 2022-08-15 19:37 UTC (permalink / raw)
To: Herbert Xu, Olivia Mackall
Cc: linux-crypto, linux-arm-kernel, linux-kernel, Martin Kaiser
Use devres for clock prepare+enable and for hwrng registration.
Martin Kaiser (2):
hwrng: imx-rngc - use devm_clk_get_enabled
hwrng: imx-rngc - use devres for hwrng registration
drivers/char/hw_random/imx-rngc.c | 37 ++++++-------------------------
1 file changed, 7 insertions(+), 30 deletions(-)
--
2.30.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/2] hwrng: imx-rngc - use devm_clk_get_enabled
2022-08-15 19:37 ` Martin Kaiser
@ 2022-08-15 19:37 ` Martin Kaiser
-1 siblings, 0 replies; 8+ messages in thread
From: Martin Kaiser @ 2022-08-15 19:37 UTC (permalink / raw)
To: Herbert Xu, Olivia Mackall
Cc: linux-crypto, linux-arm-kernel, linux-kernel, Martin Kaiser
Use the new devm_clk_get_enabled function to get our clock.
We don't have to disable and unprepare the clock ourselves any more in
error paths and in the remove function.
Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
drivers/char/hw_random/imx-rngc.c | 25 ++++++-------------------
1 file changed, 6 insertions(+), 19 deletions(-)
diff --git a/drivers/char/hw_random/imx-rngc.c b/drivers/char/hw_random/imx-rngc.c
index 4345df012d8f..23f490204341 100644
--- a/drivers/char/hw_random/imx-rngc.c
+++ b/drivers/char/hw_random/imx-rngc.c
@@ -245,7 +245,7 @@ static int imx_rngc_probe(struct platform_device *pdev)
if (IS_ERR(rngc->base))
return PTR_ERR(rngc->base);
- rngc->clk = devm_clk_get(&pdev->dev, NULL);
+ rngc->clk = devm_clk_get_enabled(&pdev->dev, NULL);
if (IS_ERR(rngc->clk)) {
dev_err(&pdev->dev, "Can not get rng_clk\n");
return PTR_ERR(rngc->clk);
@@ -255,26 +255,20 @@ static int imx_rngc_probe(struct platform_device *pdev)
if (irq < 0)
return irq;
- ret = clk_prepare_enable(rngc->clk);
- if (ret)
- return ret;
-
ver_id = readl(rngc->base + RNGC_VER_ID);
rng_type = ver_id >> RNGC_TYPE_SHIFT;
/*
* This driver supports only RNGC and RNGB. (There's a different
* driver for RNGA.)
*/
- if (rng_type != RNGC_TYPE_RNGC && rng_type != RNGC_TYPE_RNGB) {
- ret = -ENODEV;
- goto err;
- }
+ if (rng_type != RNGC_TYPE_RNGC && rng_type != RNGC_TYPE_RNGB)
+ return -ENODEV;
ret = devm_request_irq(&pdev->dev,
irq, imx_rngc_irq, 0, pdev->name, (void *)rngc);
if (ret) {
dev_err(rngc->dev, "Can't get interrupt working.\n");
- goto err;
+ return ret;
}
init_completion(&rngc->rng_op_done);
@@ -294,14 +288,14 @@ static int imx_rngc_probe(struct platform_device *pdev)
ret = imx_rngc_self_test(rngc);
if (ret) {
dev_err(rngc->dev, "self test failed\n");
- goto err;
+ return ret;
}
}
ret = hwrng_register(&rngc->rng);
if (ret) {
dev_err(&pdev->dev, "hwrng registration failed\n");
- goto err;
+ return ret;
}
dev_info(&pdev->dev,
@@ -309,11 +303,6 @@ static int imx_rngc_probe(struct platform_device *pdev)
rng_type == RNGC_TYPE_RNGB ? 'B' : 'C',
(ver_id >> RNGC_VER_MAJ_SHIFT) & 0xff, ver_id & 0xff);
return 0;
-
-err:
- clk_disable_unprepare(rngc->clk);
-
- return ret;
}
static int __exit imx_rngc_remove(struct platform_device *pdev)
@@ -322,8 +311,6 @@ static int __exit imx_rngc_remove(struct platform_device *pdev)
hwrng_unregister(&rngc->rng);
- clk_disable_unprepare(rngc->clk);
-
return 0;
}
--
2.30.2
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 1/2] hwrng: imx-rngc - use devm_clk_get_enabled
@ 2022-08-15 19:37 ` Martin Kaiser
0 siblings, 0 replies; 8+ messages in thread
From: Martin Kaiser @ 2022-08-15 19:37 UTC (permalink / raw)
To: Herbert Xu, Olivia Mackall
Cc: linux-crypto, linux-arm-kernel, linux-kernel, Martin Kaiser
Use the new devm_clk_get_enabled function to get our clock.
We don't have to disable and unprepare the clock ourselves any more in
error paths and in the remove function.
Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
drivers/char/hw_random/imx-rngc.c | 25 ++++++-------------------
1 file changed, 6 insertions(+), 19 deletions(-)
diff --git a/drivers/char/hw_random/imx-rngc.c b/drivers/char/hw_random/imx-rngc.c
index 4345df012d8f..23f490204341 100644
--- a/drivers/char/hw_random/imx-rngc.c
+++ b/drivers/char/hw_random/imx-rngc.c
@@ -245,7 +245,7 @@ static int imx_rngc_probe(struct platform_device *pdev)
if (IS_ERR(rngc->base))
return PTR_ERR(rngc->base);
- rngc->clk = devm_clk_get(&pdev->dev, NULL);
+ rngc->clk = devm_clk_get_enabled(&pdev->dev, NULL);
if (IS_ERR(rngc->clk)) {
dev_err(&pdev->dev, "Can not get rng_clk\n");
return PTR_ERR(rngc->clk);
@@ -255,26 +255,20 @@ static int imx_rngc_probe(struct platform_device *pdev)
if (irq < 0)
return irq;
- ret = clk_prepare_enable(rngc->clk);
- if (ret)
- return ret;
-
ver_id = readl(rngc->base + RNGC_VER_ID);
rng_type = ver_id >> RNGC_TYPE_SHIFT;
/*
* This driver supports only RNGC and RNGB. (There's a different
* driver for RNGA.)
*/
- if (rng_type != RNGC_TYPE_RNGC && rng_type != RNGC_TYPE_RNGB) {
- ret = -ENODEV;
- goto err;
- }
+ if (rng_type != RNGC_TYPE_RNGC && rng_type != RNGC_TYPE_RNGB)
+ return -ENODEV;
ret = devm_request_irq(&pdev->dev,
irq, imx_rngc_irq, 0, pdev->name, (void *)rngc);
if (ret) {
dev_err(rngc->dev, "Can't get interrupt working.\n");
- goto err;
+ return ret;
}
init_completion(&rngc->rng_op_done);
@@ -294,14 +288,14 @@ static int imx_rngc_probe(struct platform_device *pdev)
ret = imx_rngc_self_test(rngc);
if (ret) {
dev_err(rngc->dev, "self test failed\n");
- goto err;
+ return ret;
}
}
ret = hwrng_register(&rngc->rng);
if (ret) {
dev_err(&pdev->dev, "hwrng registration failed\n");
- goto err;
+ return ret;
}
dev_info(&pdev->dev,
@@ -309,11 +303,6 @@ static int imx_rngc_probe(struct platform_device *pdev)
rng_type == RNGC_TYPE_RNGB ? 'B' : 'C',
(ver_id >> RNGC_VER_MAJ_SHIFT) & 0xff, ver_id & 0xff);
return 0;
-
-err:
- clk_disable_unprepare(rngc->clk);
-
- return ret;
}
static int __exit imx_rngc_remove(struct platform_device *pdev)
@@ -322,8 +311,6 @@ static int __exit imx_rngc_remove(struct platform_device *pdev)
hwrng_unregister(&rngc->rng);
- clk_disable_unprepare(rngc->clk);
-
return 0;
}
--
2.30.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/2] hwrng: imx-rngc - use devres for hwrng registration
2022-08-15 19:37 ` Martin Kaiser
@ 2022-08-15 19:37 ` Martin Kaiser
-1 siblings, 0 replies; 8+ messages in thread
From: Martin Kaiser @ 2022-08-15 19:37 UTC (permalink / raw)
To: Herbert Xu, Olivia Mackall
Cc: linux-crypto, linux-arm-kernel, linux-kernel, Martin Kaiser
Replace hwrng_register with devm_hwrng_register and let devres unregister
our hwrng when the device is removed.
It's possible to do this now that devres also handles clock
disable+uprepare. When we had to disable+unprepare the clock ourselves,
we had to unregister the hwrng before this and couldn't use devres.
There's nothing left to do for imx_rngc_remove, this function can go.
Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
drivers/char/hw_random/imx-rngc.c | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)
diff --git a/drivers/char/hw_random/imx-rngc.c b/drivers/char/hw_random/imx-rngc.c
index 23f490204341..97d8dc931ca6 100644
--- a/drivers/char/hw_random/imx-rngc.c
+++ b/drivers/char/hw_random/imx-rngc.c
@@ -292,7 +292,7 @@ static int imx_rngc_probe(struct platform_device *pdev)
}
}
- ret = hwrng_register(&rngc->rng);
+ ret = devm_hwrng_register(&pdev->dev, &rngc->rng);
if (ret) {
dev_err(&pdev->dev, "hwrng registration failed\n");
return ret;
@@ -305,15 +305,6 @@ static int imx_rngc_probe(struct platform_device *pdev)
return 0;
}
-static int __exit imx_rngc_remove(struct platform_device *pdev)
-{
- struct imx_rngc *rngc = platform_get_drvdata(pdev);
-
- hwrng_unregister(&rngc->rng);
-
- return 0;
-}
-
static int __maybe_unused imx_rngc_suspend(struct device *dev)
{
struct imx_rngc *rngc = dev_get_drvdata(dev);
@@ -346,7 +337,6 @@ static struct platform_driver imx_rngc_driver = {
.pm = &imx_rngc_pm_ops,
.of_match_table = imx_rngc_dt_ids,
},
- .remove = __exit_p(imx_rngc_remove),
};
module_platform_driver_probe(imx_rngc_driver, imx_rngc_probe);
--
2.30.2
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/2] hwrng: imx-rngc - use devres for hwrng registration
@ 2022-08-15 19:37 ` Martin Kaiser
0 siblings, 0 replies; 8+ messages in thread
From: Martin Kaiser @ 2022-08-15 19:37 UTC (permalink / raw)
To: Herbert Xu, Olivia Mackall
Cc: linux-crypto, linux-arm-kernel, linux-kernel, Martin Kaiser
Replace hwrng_register with devm_hwrng_register and let devres unregister
our hwrng when the device is removed.
It's possible to do this now that devres also handles clock
disable+uprepare. When we had to disable+unprepare the clock ourselves,
we had to unregister the hwrng before this and couldn't use devres.
There's nothing left to do for imx_rngc_remove, this function can go.
Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
drivers/char/hw_random/imx-rngc.c | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)
diff --git a/drivers/char/hw_random/imx-rngc.c b/drivers/char/hw_random/imx-rngc.c
index 23f490204341..97d8dc931ca6 100644
--- a/drivers/char/hw_random/imx-rngc.c
+++ b/drivers/char/hw_random/imx-rngc.c
@@ -292,7 +292,7 @@ static int imx_rngc_probe(struct platform_device *pdev)
}
}
- ret = hwrng_register(&rngc->rng);
+ ret = devm_hwrng_register(&pdev->dev, &rngc->rng);
if (ret) {
dev_err(&pdev->dev, "hwrng registration failed\n");
return ret;
@@ -305,15 +305,6 @@ static int imx_rngc_probe(struct platform_device *pdev)
return 0;
}
-static int __exit imx_rngc_remove(struct platform_device *pdev)
-{
- struct imx_rngc *rngc = platform_get_drvdata(pdev);
-
- hwrng_unregister(&rngc->rng);
-
- return 0;
-}
-
static int __maybe_unused imx_rngc_suspend(struct device *dev)
{
struct imx_rngc *rngc = dev_get_drvdata(dev);
@@ -346,7 +337,6 @@ static struct platform_driver imx_rngc_driver = {
.pm = &imx_rngc_pm_ops,
.of_match_table = imx_rngc_dt_ids,
},
- .remove = __exit_p(imx_rngc_remove),
};
module_platform_driver_probe(imx_rngc_driver, imx_rngc_probe);
--
2.30.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 0/2] hwrng: imx-rngc - use devres for clk and hwrng
2022-08-15 19:37 ` Martin Kaiser
@ 2022-08-26 11:03 ` Herbert Xu
-1 siblings, 0 replies; 8+ messages in thread
From: Herbert Xu @ 2022-08-26 11:03 UTC (permalink / raw)
To: Martin Kaiser
Cc: Olivia Mackall, linux-crypto, linux-arm-kernel, linux-kernel
On Mon, Aug 15, 2022 at 09:37:41PM +0200, Martin Kaiser wrote:
> Use devres for clock prepare+enable and for hwrng registration.
>
> Martin Kaiser (2):
> hwrng: imx-rngc - use devm_clk_get_enabled
> hwrng: imx-rngc - use devres for hwrng registration
>
> drivers/char/hw_random/imx-rngc.c | 37 ++++++-------------------------
> 1 file changed, 7 insertions(+), 30 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] 8+ messages in thread
* Re: [PATCH 0/2] hwrng: imx-rngc - use devres for clk and hwrng
@ 2022-08-26 11:03 ` Herbert Xu
0 siblings, 0 replies; 8+ messages in thread
From: Herbert Xu @ 2022-08-26 11:03 UTC (permalink / raw)
To: Martin Kaiser
Cc: Olivia Mackall, linux-crypto, linux-arm-kernel, linux-kernel
On Mon, Aug 15, 2022 at 09:37:41PM +0200, Martin Kaiser wrote:
> Use devres for clock prepare+enable and for hwrng registration.
>
> Martin Kaiser (2):
> hwrng: imx-rngc - use devm_clk_get_enabled
> hwrng: imx-rngc - use devres for hwrng registration
>
> drivers/char/hw_random/imx-rngc.c | 37 ++++++-------------------------
> 1 file changed, 7 insertions(+), 30 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
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2022-08-26 11:05 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-15 19:37 [PATCH 0/2] hwrng: imx-rngc - use devres for clk and hwrng Martin Kaiser
2022-08-15 19:37 ` Martin Kaiser
2022-08-15 19:37 ` [PATCH 1/2] hwrng: imx-rngc - use devm_clk_get_enabled Martin Kaiser
2022-08-15 19:37 ` Martin Kaiser
2022-08-15 19:37 ` [PATCH 2/2] hwrng: imx-rngc - use devres for hwrng registration Martin Kaiser
2022-08-15 19:37 ` Martin Kaiser
2022-08-26 11:03 ` [PATCH 0/2] hwrng: imx-rngc - use devres for clk and hwrng Herbert Xu
2022-08-26 11:03 ` Herbert Xu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.