devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tony Lindgren <tony@atomide.com>
To: Matt Mackall <mpm@selenic.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org
Cc: linux-crypto@vger.kernel.org,
	"Aaro Koskinen" <aaro.koskinen@iki.fi>,
	"Adam Ford" <aford173@gmail.com>,
	"Pali Rohár" <pali.rohar@gmail.com>,
	"Sebastian Reichel" <sre@kernel.org>,
	"Tero Kristo" <t-kristo@ti.com>,
	"Rob Herring" <robh+dt@kernel.org>,
	devicetree@vger.kernel.org
Subject: [PATCH 7/7] hwrng: omap3-rom - Use devm hwrng and runtime PM
Date: Sat, 14 Sep 2019 14:03:00 -0700	[thread overview]
Message-ID: <20190914210300.15836-8-tony@atomide.com> (raw)
In-Reply-To: <20190914210300.15836-1-tony@atomide.com>

This allows us to simplify things more for probe and exit.

Cc: Aaro Koskinen <aaro.koskinen@iki.fi>
Cc: Adam Ford <aford173@gmail.com>
Cc: Pali Rohár <pali.rohar@gmail.com>
Cc: Sebastian Reichel <sre@kernel.org>
Cc: Tero Kristo <t-kristo@ti.com>
Suggested-by: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 drivers/char/hw_random/omap3-rom-rng.c | 42 ++++++++++----------------
 1 file changed, 16 insertions(+), 26 deletions(-)

diff --git a/drivers/char/hw_random/omap3-rom-rng.c b/drivers/char/hw_random/omap3-rom-rng.c
--- a/drivers/char/hw_random/omap3-rom-rng.c
+++ b/drivers/char/hw_random/omap3-rom-rng.c
@@ -100,6 +100,14 @@ static int omap_rom_rng_runtime_resume(struct device *dev)
 	return 0;
 }
 
+static void omap_rom_rng_finish(void *data)
+{
+	struct omap_rom_rng *ddata = data;
+
+	pm_runtime_dont_use_autosuspend(ddata->dev);
+	pm_runtime_disable(ddata->dev);
+}
+
 static int omap3_rom_rng_probe(struct platform_device *pdev)
 {
 	struct omap_rom_rng *ddata;
@@ -133,33 +141,16 @@ static int omap3_rom_rng_probe(struct platform_device *pdev)
 		return PTR_ERR(ddata->clk);
 	}
 
-	pm_runtime_enable(ddata->dev);
-
-	ret = hwrng_register(&ddata->ops);
-	if (!ret)
-		goto err_disable;
-
-	pm_runtime_set_autosuspend_delay(ddata->dev, 500);
-	pm_runtime_use_autosuspend(ddata->dev);
-
-	return 0;
-
-err_disable:
-	pm_runtime_disable(ddata->dev);
-
-	return ret;
-}
-
-static int omap3_rom_rng_remove(struct platform_device *pdev)
-{
-	struct omap_rom_rng *ddata;
+	pm_runtime_enable(&pdev->dev);
+	pm_runtime_set_autosuspend_delay(&pdev->dev, 500);
+	pm_runtime_use_autosuspend(&pdev->dev);
 
-	ddata = dev_get_drvdata(&pdev->dev);
-	hwrng_unregister(&ddata->ops);
-	pm_runtime_dont_use_autosuspend(ddata->dev);
-	pm_runtime_disable(ddata->dev);
+	ret = devm_add_action_or_reset(ddata->dev, omap_rom_rng_finish,
+				       ddata);
+	if (ret)
+		return ret;
 
-	return 0;
+	return devm_hwrng_register(ddata->dev, &ddata->ops);
 }
 
 static const struct of_device_id omap_rom_rng_match[] = {
@@ -180,7 +171,6 @@ static struct platform_driver omap3_rom_rng_driver = {
 		.pm = &omap_rom_rng_pm_ops,
 	},
 	.probe		= omap3_rom_rng_probe,
-	.remove		= omap3_rom_rng_remove,
 };
 
 module_platform_driver(omap3_rom_rng_driver);
-- 
2.23.0

  parent reply	other threads:[~2019-09-14 21:03 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-14 21:02 [PATCHv2 0/7] Non-urgent fixes and improvments for omap3-rom-rng Tony Lindgren
2019-09-14 21:02 ` [PATCH 1/7] ARM: OMAP2+: Check omap3-rom-rng for GP device instead of HS device Tony Lindgren
2019-09-14 21:02 ` [PATCH 2/7] hwrng: omap3-rom - Fix missing clock by probing with device tree Tony Lindgren
2019-09-30 22:20   ` Rob Herring
2019-09-14 21:02 ` [PATCH 3/7] hwrng: omap3-rom - Call clk_disable_unprepare() on exit only if not idled Tony Lindgren
2019-09-14 21:02 ` [PATCH 4/7] hwrng: omap3-rom - Initialize default quality to get data Tony Lindgren
2019-09-14 21:02 ` [PATCH 5/7] hwrng: omap3-rom - Update to use standard driver data Tony Lindgren
2019-09-14 21:02 ` [PATCH 6/7] hwrng: omap3-rom - Use runtime PM instead of custom functions Tony Lindgren
2019-09-14 21:03 ` Tony Lindgren [this message]
2019-09-16  6:47 ` [PATCHv2 0/7] Non-urgent fixes and improvments for omap3-rom-rng Tero Kristo
2019-09-16 19:08 ` Sebastian Reichel
2019-09-16 20:17 ` Aaro Koskinen
2019-10-04 15:40 ` Herbert Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190914210300.15836-8-tony@atomide.com \
    --to=tony@atomide.com \
    --cc=aaro.koskinen@iki.fi \
    --cc=aford173@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=mpm@selenic.com \
    --cc=pali.rohar@gmail.com \
    --cc=robh+dt@kernel.org \
    --cc=sre@kernel.org \
    --cc=t-kristo@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).