Skip to contentSkip to conversation

hw_random: Remove check for max less than 4 bytes

PATCH In review PrasannaKumar Muralidharan 2 participants 2 messages Aug 26, 2016 – Aug 31, 2016

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

PATCH 1/1 hw_random: Remove check for max less than 4 bytes

HW RNG core never asks for data less than 4 bytes. The check whether max is less than 4 bytes is unnecessary. Remove the check.

---
 drivers/char/hw_random/meson-rng.c | 3 ---
 drivers/char/hw_random/st-rng.c    | 3 ---
 2 files changed, 6 deletions(-)
drivers/char/hw_random/meson-rng.c +0 -3
index 0cfd81b..58bef39 100644
@@ -76,9 +76,6 @@ static int meson_rng_read(struct hwrng *rng, void *buf, size_t max, bool wait)
 	struct meson_rng_data *data =
 			container_of(rng, struct meson_rng_data, rng);
 
-	if (max < sizeof(u32))
-		return 0;
-
 	*(u32 *)buf = readl_relaxed(data->base + RNG_DATA);
 
 	return sizeof(u32);
drivers/char/hw_random/st-rng.c +0 -3
index 1d35363..7e8aa6b 100644
@@ -54,9 +54,6 @@ static int st_rng_read(struct hwrng *rng, void *data, size_t max, bool wait)
 	u32 status;
 	int i;
 
-	if (max < sizeof(u16))
-		return -EINVAL;
-
 	/* Wait until FIFO is full - max 4uS*/
 	for (i = 0; i < ST_RNG_FILL_FIFO_TIMEOUT; i++) {
 		status = readl_relaxed(ddata->base + ST_RNG_STATUS_REG);
Signature · 1 line
2.5.0
maintainer
#1 lore raw
Quoted 4 lines · PrasannaKumar Muralidharan

HW RNG core never asks for data less than 4 bytes. The check whether max is less than 4 bytes is unnecessary. Remove the check.

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