Skip to contentSkip to conversation

hwrng: atmel - use HZ_PER_MHZ in atmel_trng_init()

PATCH In review Thorsten Blum 2 participants 2 messages Sep 29 – Oct 8

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hwrng: atmel - use HZ_PER_MHZ in atmel_trng_init()

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.

---
 drivers/char/hw_random/atmel-rng.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/char/hw_random/atmel-rng.c +3 -8
index 06e79d516743..fe444196e6b3 100644
@@ -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);
 
maintainer
#1 lore raw
Quoted 7 lines · Thorsten Blum

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.

---
 drivers/char/hw_random/atmel-rng.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt