All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vinod Koul <vinod.koul@linaro.org>
To: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Matt Mackall <mpm@selenic.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-arm-msm@vger.kernel.org, Vinod Koul <vkoul@kernel.org>
Subject: [PATCH 1/3] hwrng: msm - Move hwrng to a table
Date: Mon, 18 Jun 2018 19:42:57 +0530	[thread overview]
Message-ID: <20180618141259.23141-2-vkoul@kernel.org> (raw)
In-Reply-To: <20180618141259.23141-1-vkoul@kernel.org>

Future versions of msm-prng require bit differs callbacks so move
driver to use a table for hwrng.

No functional change.

Signed-off-by: Vinod Koul <vkoul@kernel.org>
---
 drivers/char/hw_random/msm-rng.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/drivers/char/hw_random/msm-rng.c b/drivers/char/hw_random/msm-rng.c
index 841fee845ec9..7644474035e5 100644
--- a/drivers/char/hw_random/msm-rng.c
+++ b/drivers/char/hw_random/msm-rng.c
@@ -38,14 +38,12 @@
 struct msm_rng {
 	void __iomem *base;
 	struct clk *clk;
-	struct hwrng hwrng;
+	struct hwrng *hwrng;
 };
 
-#define to_msm_rng(p)	container_of(p, struct msm_rng, hwrng)
-
 static int msm_rng_enable(struct hwrng *hwrng, int enable)
 {
-	struct msm_rng *rng = to_msm_rng(hwrng);
+	struct msm_rng *rng = (struct msm_rng *)hwrng->priv;
 	u32 val;
 	int ret;
 
@@ -80,7 +78,7 @@ static int msm_rng_enable(struct hwrng *hwrng, int enable)
 
 static int msm_rng_read(struct hwrng *hwrng, void *data, size_t max, bool wait)
 {
-	struct msm_rng *rng = to_msm_rng(hwrng);
+	struct msm_rng *rng = (struct msm_rng *)hwrng->priv;
 	size_t currsize = 0;
 	u32 *retdata = data;
 	size_t maxsize;
@@ -127,6 +125,13 @@ static void msm_rng_cleanup(struct hwrng *hwrng)
 	msm_rng_enable(hwrng, 0);
 }
 
+static struct hwrng msm_rng = {
+	.name = KBUILD_MODNAME,
+	.init = msm_rng_init,
+	.cleanup = msm_rng_cleanup,
+	.read = msm_rng_read,
+};
+
 static int msm_rng_probe(struct platform_device *pdev)
 {
 	struct resource *res;
@@ -148,12 +153,10 @@ static int msm_rng_probe(struct platform_device *pdev)
 	if (IS_ERR(rng->clk))
 		return PTR_ERR(rng->clk);
 
-	rng->hwrng.name = KBUILD_MODNAME,
-	rng->hwrng.init = msm_rng_init,
-	rng->hwrng.cleanup = msm_rng_cleanup,
-	rng->hwrng.read = msm_rng_read,
+	rng->hwrng = &msm_rng;
 
-	ret = devm_hwrng_register(&pdev->dev, &rng->hwrng);
+	rng->hwrng->priv = (unsigned long)rng;
+	ret = devm_hwrng_register(&pdev->dev, rng->hwrng);
 	if (ret) {
 		dev_err(&pdev->dev, "failed to register hwrng\n");
 		return ret;
-- 
2.14.4

  reply	other threads:[~2018-06-18 14:12 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-18 14:12 [PATCH 0/3]: hwrng: Add support for qcpm v2 hwrng Vinod Koul
2018-06-18 14:12 ` Vinod Koul [this message]
2018-06-18 15:58   ` [PATCH 1/3] hwrng: msm - Move hwrng to a table Stephen Boyd
2018-06-18 16:54     ` Vinod
2018-06-18 14:12 ` [PATCH 2/3] dt-bindings: rng: Add new compatible qcom,prng-v2 Vinod Koul
2018-06-18 14:12 ` [PATCH 3/3] hwrng: msm - Add support for prng v2 Vinod Koul
2018-06-18 18:21   ` Bjorn Andersson
2018-06-18 20:24     ` Stephen Boyd
2018-06-19  4:06       ` Vinod
2018-06-19  4:04     ` Vinod
2018-06-19 14:28   ` Herbert Xu
2018-06-20  5:32     ` Vinod
2018-06-20 14:37       ` Herbert Xu
2018-06-20 17:45       ` PrasannaKumar Muralidharan
2018-06-20 17:45         ` PrasannaKumar Muralidharan
2018-06-21  4:17         ` Vinod
2018-06-21  4:17           ` Vinod
2018-06-21  9:56     ` Stanimir Varbanov
2018-06-21 10:15       ` Herbert Xu
2018-06-21 11:27         ` Stanimir Varbanov
2018-06-21 11:53           ` Herbert Xu
2018-06-22  8:27             ` Stanimir Varbanov
2018-06-22 14:38               ` Herbert Xu
2018-06-22 14:48                 ` Vinod
2018-06-22 14:50                   ` Herbert Xu
     [not found]                     ` <70ED61EB-BD3E-48D1-8B4D-D7835494C035@chronox.de>
2018-06-27  5:08                       ` Vinod
2018-06-27  6:13                         ` Stephan Mueller
2018-06-27  6:27                           ` Vinod
2018-06-27  6:43                             ` Stephan Mueller
2018-06-27  7:01                               ` Vinod
2018-06-27  7:51                                 ` Stephan Mueller
2018-06-22 15:33                 ` Stanimir Varbanov
2018-06-28 22:04             ` Timur Tabi
2018-06-29  8:37               ` Vinod
2018-07-01  6:27                 ` 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=20180618141259.23141-2-vkoul@kernel.org \
    --to=vinod.koul@linaro.org \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpm@selenic.com \
    --cc=vkoul@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.