* [PATCH] hwrng: atmel - use HZ_PER_MHZ in atmel_trng_init()
@ 2026-09-29 21:37 Thorsten Blum
0 siblings, 0 replies; only message in thread
From: Thorsten Blum @ 2026-09-29 21:37 UTC (permalink / raw)
To: Olivia Mackall, Herbert Xu, Nicolas Ferre, Alexandre Belloni,
Claudiu Beznea, Danilo Krummrich, Bjorn Helgaas, Thorsten Blum,
Uwe Kleine-König (The Capable Hub),
Takashi Sakamoto
Cc: linux-crypto, linux-arm-kernel, linux-kernel
Combine and inline the rate check to simplify the code. Drop the local
rate variable and use HZ_PER_MHZ instead of the hard-coded frequency.
Signed-off-by: Thorsten Blum <blum@kernel.org>
---
drivers/char/hw_random/atmel-rng.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/char/hw_random/atmel-rng.c b/drivers/char/hw_random/atmel-rng.c
index 06e79d516743..fe444196e6b3 100644
--- a/drivers/char/hw_random/atmel-rng.c
+++ b/drivers/char/hw_random/atmel-rng.c
@@ -17,6 +17,7 @@
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
+#include <linux/units.h>
#define TRNG_CR 0x00
#define TRNG_MR 0x04
@@ -85,20 +86,14 @@ static int atmel_trng_read(struct hwrng *rng, void *buf, size_t max,
static int atmel_trng_init(struct atmel_trng *trng)
{
- unsigned long rate;
int ret;
ret = clk_prepare_enable(trng->clk);
if (ret)
return ret;
- if (trng->has_half_rate) {
- rate = clk_get_rate(trng->clk);
-
- /* if peripheral clk is above 100MHz, set HALFR */
- if (rate > 100000000)
- writel(TRNG_HALFR, trng->base + TRNG_MR);
- }
+ if (trng->has_half_rate && clk_get_rate(trng->clk) > 100 * HZ_PER_MHZ)
+ writel(TRNG_HALFR, trng->base + TRNG_MR);
writel(TRNG_KEY | 1, trng->base + TRNG_CR);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-09-29 21:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-29 21:37 [PATCH] hwrng: atmel - use HZ_PER_MHZ in atmel_trng_init() Thorsten Blum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®