mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] hwrng: rockchip - two simple cleanups
@ 2024-08-21 18:12 Martin Kaiser
  2024-08-21 18:12 ` [PATCH 1/2] hwrng: rockchip - rst is used only during probe Martin Kaiser
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Martin Kaiser @ 2024-08-21 18:12 UTC (permalink / raw)
  To: Herbert Xu
  Cc: Aurelien Jarno, Daniel Golle, linux-crypto, linux-arm-kernel,
	linux-kernel, Martin Kaiser

Two simple cleanups for the Rockchip RK3568 driver.

Martin Kaiser (2):
  hwrng: rockchip - rst is used only during probe
  hwrng: rockchip - handle devm_pm_runtime_enable errors

 drivers/char/hw_random/rockchip-rng.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

-- 
2.39.2


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] hwrng: rockchip - rst is used only during probe
  2024-08-21 18:12 [PATCH 0/2] hwrng: rockchip - two simple cleanups Martin Kaiser
@ 2024-08-21 18:12 ` Martin Kaiser
  2024-08-21 18:12 ` [PATCH 2/2] hwrng: rockchip - handle devm_pm_runtime_enable errors Martin Kaiser
  2024-08-30 10:38 ` [PATCH 0/2] hwrng: rockchip - two simple cleanups Herbert Xu
  2 siblings, 0 replies; 4+ messages in thread
From: Martin Kaiser @ 2024-08-21 18:12 UTC (permalink / raw)
  To: Herbert Xu
  Cc: Aurelien Jarno, Daniel Golle, linux-crypto, linux-arm-kernel,
	linux-kernel, Martin Kaiser

The driver uses the rst variable only for an initial reset when the chip
is probed. There's no need to store rst in the driver's private data, we
can make it a local variable in the probe function.

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
 drivers/char/hw_random/rockchip-rng.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/char/hw_random/rockchip-rng.c b/drivers/char/hw_random/rockchip-rng.c
index 548e2f4d1490..0dff9de64bc5 100644
--- a/drivers/char/hw_random/rockchip-rng.c
+++ b/drivers/char/hw_random/rockchip-rng.c
@@ -52,7 +52,6 @@
 struct rk_rng {
 	struct hwrng rng;
 	void __iomem *base;
-	struct reset_control *rst;
 	int clk_num;
 	struct clk_bulk_data *clk_bulks;
 };
@@ -132,6 +131,7 @@ static int rk_rng_read(struct hwrng *rng, void *buf, size_t max, bool wait)
 static int rk_rng_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
+	struct reset_control *rst;
 	struct rk_rng *rk_rng;
 	int ret;
 
@@ -148,14 +148,13 @@ static int rk_rng_probe(struct platform_device *pdev)
 		return dev_err_probe(dev, rk_rng->clk_num,
 				     "Failed to get clks property\n");
 
-	rk_rng->rst = devm_reset_control_array_get_exclusive(&pdev->dev);
-	if (IS_ERR(rk_rng->rst))
-		return dev_err_probe(dev, PTR_ERR(rk_rng->rst),
-				     "Failed to get reset property\n");
+	rst = devm_reset_control_array_get_exclusive(&pdev->dev);
+	if (IS_ERR(rst))
+		return dev_err_probe(dev, PTR_ERR(rst), "Failed to get reset property\n");
 
-	reset_control_assert(rk_rng->rst);
+	reset_control_assert(rst);
 	udelay(2);
-	reset_control_deassert(rk_rng->rst);
+	reset_control_deassert(rst);
 
 	platform_set_drvdata(pdev, rk_rng);
 
-- 
2.39.2


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/2] hwrng: rockchip - handle devm_pm_runtime_enable errors
  2024-08-21 18:12 [PATCH 0/2] hwrng: rockchip - two simple cleanups Martin Kaiser
  2024-08-21 18:12 ` [PATCH 1/2] hwrng: rockchip - rst is used only during probe Martin Kaiser
@ 2024-08-21 18:12 ` Martin Kaiser
  2024-08-30 10:38 ` [PATCH 0/2] hwrng: rockchip - two simple cleanups Herbert Xu
  2 siblings, 0 replies; 4+ messages in thread
From: Martin Kaiser @ 2024-08-21 18:12 UTC (permalink / raw)
  To: Herbert Xu
  Cc: Aurelien Jarno, Daniel Golle, linux-crypto, linux-arm-kernel,
	linux-kernel, Martin Kaiser

It's unlikely that devm_pm_runtime_enable ever fails. Still, it makes
sense to read the return value and handle errors.

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
 drivers/char/hw_random/rockchip-rng.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/char/hw_random/rockchip-rng.c b/drivers/char/hw_random/rockchip-rng.c
index 0dff9de64bc5..289b385bbf05 100644
--- a/drivers/char/hw_random/rockchip-rng.c
+++ b/drivers/char/hw_random/rockchip-rng.c
@@ -169,7 +169,9 @@ static int rk_rng_probe(struct platform_device *pdev)
 
 	pm_runtime_set_autosuspend_delay(dev, RK_RNG_AUTOSUSPEND_DELAY);
 	pm_runtime_use_autosuspend(dev);
-	devm_pm_runtime_enable(dev);
+	ret = devm_pm_runtime_enable(dev);
+	if (ret)
+		return dev_err_probe(&pdev->dev, ret, "Runtime pm activation failed.\n");
 
 	ret = devm_hwrng_register(dev, &rk_rng->rng);
 	if (ret)
-- 
2.39.2


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] hwrng: rockchip - two simple cleanups
  2024-08-21 18:12 [PATCH 0/2] hwrng: rockchip - two simple cleanups Martin Kaiser
  2024-08-21 18:12 ` [PATCH 1/2] hwrng: rockchip - rst is used only during probe Martin Kaiser
  2024-08-21 18:12 ` [PATCH 2/2] hwrng: rockchip - handle devm_pm_runtime_enable errors Martin Kaiser
@ 2024-08-30 10:38 ` Herbert Xu
  2 siblings, 0 replies; 4+ messages in thread
From: Herbert Xu @ 2024-08-30 10:38 UTC (permalink / raw)
  To: Martin Kaiser
  Cc: Aurelien Jarno, Daniel Golle, linux-crypto, linux-arm-kernel,
	linux-kernel

On Wed, Aug 21, 2024 at 08:12:33PM +0200, Martin Kaiser wrote:
> Two simple cleanups for the Rockchip RK3568 driver.
> 
> Martin Kaiser (2):
>   hwrng: rockchip - rst is used only during probe
>   hwrng: rockchip - handle devm_pm_runtime_enable errors
> 
>  drivers/char/hw_random/rockchip-rng.c | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)
> 
> -- 
> 2.39.2

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] 4+ messages in thread

end of thread, other threads:[~2024-08-30 10:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-21 18:12 [PATCH 0/2] hwrng: rockchip - two simple cleanups Martin Kaiser
2024-08-21 18:12 ` [PATCH 1/2] hwrng: rockchip - rst is used only during probe Martin Kaiser
2024-08-21 18:12 ` [PATCH 2/2] hwrng: rockchip - handle devm_pm_runtime_enable errors Martin Kaiser
2024-08-30 10:38 ` [PATCH 0/2] hwrng: rockchip - two simple cleanups 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®