From patchwork Sat Sep 14 21:03:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tony Lindgren X-Patchwork-Id: 11145779 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7D0D814E5 for ; Sat, 14 Sep 2019 21:03:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6839E206CD for ; Sat, 14 Sep 2019 21:03:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731485AbfINVDU (ORCPT ); Sat, 14 Sep 2019 17:03:20 -0400 Received: from muru.com ([72.249.23.125]:32974 "EHLO muru.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731477AbfINVDT (ORCPT ); Sat, 14 Sep 2019 17:03:19 -0400 Received: from hillo.muru.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTP id F057B813A; Sat, 14 Sep 2019 21:03:48 +0000 (UTC) From: Tony Lindgren To: Matt Mackall , Herbert Xu , linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org Cc: linux-crypto@vger.kernel.org, Aaro Koskinen , Adam Ford , =?utf-8?q?Pali_Roh=C3=A1r?= , Sebastian Reichel , Tero Kristo , Rob Herring , 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 Message-Id: <20190914210300.15836-8-tony@atomide.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190914210300.15836-1-tony@atomide.com> References: <20190914210300.15836-1-tony@atomide.com> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org This allows us to simplify things more for probe and exit. Cc: Aaro Koskinen Cc: Adam Ford Cc: Pali Rohár Cc: Sebastian Reichel Cc: Tero Kristo Suggested-by: Sebastian Reichel Signed-off-by: Tony Lindgren --- 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);