linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Martin Kaiser <martin@kaiser.cx>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: linux-crypto@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, Martin Kaiser <martin@kaiser.cx>
Subject: [PATCH v2 2/3] hwrng: imx-rngc - use bitfield macros to read rng type
Date: Fri, 19 May 2023 18:04:32 +0200	[thread overview]
Message-ID: <20230519160433.287161-3-martin@kaiser.cx> (raw)
In-Reply-To: <20230519160433.287161-1-martin@kaiser.cx>

Use the mechanism from bitfield.h to read the rng type field in the
version_id register. This makes the code a tiny bit simpler.

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
 drivers/char/hw_random/imx-rngc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/char/hw_random/imx-rngc.c b/drivers/char/hw_random/imx-rngc.c
index cf29c323453a..b5f7b91bd13e 100644
--- a/drivers/char/hw_random/imx-rngc.c
+++ b/drivers/char/hw_random/imx-rngc.c
@@ -27,7 +27,7 @@
 #define RNGC_FIFO			0x0014
 
 /* the fields in the ver id register */
-#define RNGC_TYPE_SHIFT		28
+#define RNG_TYPE			GENMASK(31, 28)
 #define RNGC_VER_MAJ_SHIFT		8
 
 /* the rng_type field */
@@ -251,7 +251,7 @@ static int imx_rngc_probe(struct platform_device *pdev)
 		return irq;
 
 	ver_id = readl(rngc->base + RNGC_VER_ID);
-	rng_type = ver_id >> RNGC_TYPE_SHIFT;
+	rng_type = FIELD_GET(RNG_TYPE, ver_id);
 	/*
 	 * This driver supports only RNGC and RNGB. (There's a different
 	 * driver for RNGA.)
-- 
2.30.2


  parent reply	other threads:[~2023-05-19 16:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-27 18:53 [PATCH 0/3] hwrng: imx-rngc - simplify register definitions Martin Kaiser
2023-04-27 18:53 ` [PATCH 1/3] hwrng: imx-rngc - use bitfield macros to read fifo level Martin Kaiser
2023-05-11  5:16   ` Herbert Xu
2023-05-11  7:43     ` Martin Kaiser
2023-04-27 18:53 ` [PATCH 2/3] hwrng: imx-rngc - use bitfield macros to read rng type Martin Kaiser
2023-04-27 18:53 ` [PATCH 3/3] hwrng: imx-rngc - use BIT(x) for register bit defines Martin Kaiser
2023-05-19 16:04 ` [PATCH v2 0/3] hwrng: imx-rngc - simplify register definitions Martin Kaiser
2023-05-19 16:04   ` [PATCH v2 1/3] hwrng: imx-rngc - simpler check for available random bytes Martin Kaiser
2023-05-19 16:04   ` Martin Kaiser [this message]
2023-05-19 16:04   ` [PATCH v2 3/3] hwrng: imx-rngc - use BIT(x) for register bit defines Martin Kaiser
2023-05-24 10:14   ` [PATCH v2 0/3] hwrng: imx-rngc - simplify register definitions 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=20230519160433.287161-3-martin@kaiser.cx \
    --to=martin@kaiser.cx \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.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 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).