Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp2498113ybe; Sat, 14 Sep 2019 16:40:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqzUNBm5GjKAQLaLUvMZ0u1tOjZIeCJU5PL16VenZ2r0WXPRgaTAO2Ahe7MUSx3hwk5eNsP4 X-Received: by 2002:a50:eb07:: with SMTP id y7mr18879242edp.240.1568504434111; Sat, 14 Sep 2019 16:40:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568504434; cv=none; d=google.com; s=arc-20160816; b=SP0NhxpsX9SyFXB5+7inOVHQkvj55XA7CAWHU8qj5vQUi1bdUzeMNlTRFzaAcXx8KO lHRv5juMaeSXw3Q1U95jPvVg8pft3h2TxVzY/PPNAvfkSeM6hr9JOOlKzw93EtZZpi+7 31NA6Rirqt9ZqQTsW9hDsjayEgVSc5ZBJFLs9/s0rcIKMINyZHmVWklodr0JEeKyM13+ KyCttZegJiXsIVWZ+ZO2dVdrB2sAJGpxSOUlqSC7i00msFv3FR3HIKPdtiXFtkm7Fnk3 WRJQ0GxfzTVHJRVwxXUCUQrNTBZMmBPAMA+76EM/hEAYTyFs1WI/hKs9Fqe7VRAhBXLG z7kQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=9XvD29XDnuUy+Mt7qoxIJ4eGDfh1g+QMLQfBgkGDrfw=; b=YEvm+VeW19Jvbl5Z7gClbm7MHo5CgnEImPF/6LKACDqkn4cstz3/ZOIHX7I0glTorT VCvhVRvso6A9dlSlJlJX8NsDAxLV0am1s7uccRefpJ5HEDejKaBxmfcjtaYnuk+iO9/b xSNrH5fY152nT7eXa7vBCcrW+NHigPttis3e3ny9Pqz2yKL6d7TtIM5N4ESDu2lmvB8g FmER02L3wApeuh5CqD8rmPsetp243XAMQKb2Dq2TfzJPgjOUwNu9GzVx1ajgYZurv1vz 2G3yrUEHE7EQaxJJ0STXMrXUQTqvSGcDz139PYZeaEN3wR2UMj565EuCqY8UhECdHSyP koCw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id um3si17181318ejb.391.2019.09.14.16.40.09; Sat, 14 Sep 2019 16:40:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731485AbfINVDU (ORCPT + 99 others); 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=20Roh=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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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); -- 2.23.0