Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1345084ybe; Fri, 13 Sep 2019 15:10:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqzZeKThQaOs3SVr8CPmqwQ4CMzEcbuvJQvP28VopjFm+Z4gAuYkigLpMRva/2hWSArgRSzN X-Received: by 2002:a50:f152:: with SMTP id z18mr48978221edl.141.1568412637250; Fri, 13 Sep 2019 15:10:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568412637; cv=none; d=google.com; s=arc-20160816; b=bh+nJGo2I/02Bg0n3hETHmY9cWsv9yYQy1DdXA+KLJ3sp3tLzZQHdxE0ORn2cl8eWm K7K4PaMhPAzeqN9D87Oe2c2I1sKhTHhUsL57auU51OWuCdlvEUlctMhGYE9hW0BotD7c aPh3HA4sTf7xIJgyjE4Dl+tJTSxuXuGrZT1GsAf4l83hBSlhtwL/VQg519GOIYy5Jrff WdCzAZw1dPsQXkOuuN83MNFBVf8XYFmqvWlWm1QJS9gG3u1gABlgtQB5VP9qMf/9bXWv f/2TDZ95KxeTCo2hmMBTwAnN0++1cniJ3F7qHZV+IysMGG57UUNrPKO39n3Dz29h7gM5 53rg== 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=zCAfPGE+vXgTMfBQjd/uuwwC9qHDppVuHq/g2Nnu76A=; b=hmjsVJ7Bre8FCEkmdjPwgYqsnRPrCscm+vX1tIpQjnIaHB4lGUO/4UelO+xbvCJJuA duGQAkYwBueZfyeb/0iJe5IARpnpIlhZH0G7vnFa5chdWELXQ3wbouNVXYAmZEjkfJfA eFh6UNZ6wfB0DCuhfm87ud1gWhAbcWg5Gsa8mP8NI4JsRX8ACNOnNgDi2zUj5jdx2cbX DB3LhtBJLtgX6uvf+7Neu889mtiLAripm2I8MQ5IPYXn5h2NeQx3HxIgeXG2Uu00mlgR v+JNHAlEI29PbLH5pftVZc5xoqPKrN5tpkIHZKTl3/ynNMnIDLMAXaH5GGL0qzHaUNkd 8mng== 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 y25si14580823edt.408.2019.09.13.15.10.12; Fri, 13 Sep 2019 15:10:37 -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 S2390665AbfIMWJh (ORCPT + 99 others); Fri, 13 Sep 2019 18:09:37 -0400 Received: from muru.com ([72.249.23.125]:60766 "EHLO muru.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390600AbfIMWJh (ORCPT ); Fri, 13 Sep 2019 18:09:37 -0400 Received: from hillo.muru.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTP id DD7D1823F; Fri, 13 Sep 2019 22:10:06 +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?= , Rob Herring , Tero Kristo , devicetree@vger.kernel.org Subject: [PATCH 5/6] hwrng: omap3-rom - Update to use standard driver data Date: Fri, 13 Sep 2019 15:09:21 -0700 Message-Id: <20190913220922.29501-6-tony@atomide.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190913220922.29501-1-tony@atomide.com> References: <20190913220922.29501-1-tony@atomide.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Let's update omap3-rom-rng to use standard driver data to make it easier to add runtime PM support in the following patch. Just use it for the clock for now, but still keep also old rng_clk still around. We will remove delayed work and rng_clk with runtime PM in the next patch. Signed-off-by: Tony Lindgren --- drivers/char/hw_random/omap3-rom-rng.c | 51 +++++++++++++++++--------- 1 file changed, 33 insertions(+), 18 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 @@ -31,6 +31,12 @@ /* param1: ptr, param2: count, param3: flag */ static u32 (*omap3_rom_rng_call)(u32, u32, u32); +struct omap_rom_rng { + struct clk *clk; + struct device *dev; + struct hwrng ops; +}; + static struct delayed_work idle_work; static int rng_idle; static struct clk *rng_clk; @@ -86,60 +92,69 @@ static int omap3_rom_rng_read(struct hwrng *rng, void *data, size_t max, bool w) return 4; } -static struct hwrng omap3_rom_rng_ops = { - .name = "omap3-rom", - .quality = 900, -}; - static int omap3_rom_rng_probe(struct platform_device *pdev) { + struct omap_rom_rng *ddata; int ret = 0; - omap3_rom_rng_ops.read = of_device_get_match_data(&pdev->dev); - if (!omap3_rom_rng_ops.read) { + ddata = devm_kzalloc(&pdev->dev, sizeof(*ddata), GFP_KERNEL); + if (!ddata) + return -ENOMEM; + + ddata->dev = &pdev->dev; + ddata->ops.priv = (unsigned long)ddata; + ddata->ops.name = "omap3-rom"; + ddata->ops.read = of_device_get_match_data(&pdev->dev); + ddata->ops.quality = 900; + if (!ddata->ops.read) { dev_err(&pdev->dev, "missing rom code handler\n"); return -ENODEV; } + dev_set_drvdata(ddata->dev, ddata); omap3_rom_rng_call = pdev->dev.platform_data; if (!omap3_rom_rng_call) { - pr_err("omap3_rom_rng_call is NULL\n"); + dev_err(ddata->dev, "rom_rng_call is NULL\n"); return -EINVAL; } INIT_DELAYED_WORK(&idle_work, omap3_rom_rng_idle); - rng_clk = devm_clk_get(&pdev->dev, "ick"); - if (IS_ERR(rng_clk)) { - pr_err("unable to get RNG clock\n"); - return PTR_ERR(rng_clk); + ddata->clk = devm_clk_get(ddata->dev, "ick"); + if (IS_ERR(ddata->clk)) { + dev_err(ddata->dev, "unable to get RNG clock\n"); + return PTR_ERR(ddata->clk); } + rng_clk = ddata->clk; - ret = clk_prepare(rng_clk); + ret = clk_prepare(ddata->clk); if (ret < 0) { dev_err(&pdev->dev, "clk_prepare failed: %i\n", ret); return ret; } /* Leave the RNG in reset state. */ - ret = clk_enable(rng_clk); + ret = clk_enable(ddata->clk); if (ret) goto err_unprepare; omap3_rom_rng_idle(0); - return hwrng_register(&omap3_rom_rng_ops); + return hwrng_register(&ddata->ops); err_unprepare: - clk_unprepare(rng_clk); + clk_unprepare(ddata->clk); return ret; } static int omap3_rom_rng_remove(struct platform_device *pdev) { + struct omap_rom_rng *ddata; + + ddata = dev_get_drvdata(&pdev->dev); cancel_delayed_work_sync(&idle_work); - hwrng_unregister(&omap3_rom_rng_ops); - clk_unprepare(rng_clk); + hwrng_unregister(&ddata->ops); + clk_unprepare(ddata->clk); return 0; } -- 2.23.0