mirror of
https://github.com/torvalds/linux.git
synced 2024-11-11 14:42:24 +00:00
hwrng: Make explicit that max >= 32 always
As hw_random core calls ->read with max > 32 or more, make it explicit. Also remove checks involving 'max' being less than 8. Signed-off-by: PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
8ff4c191d1
commit
ed424bb368
@ -90,10 +90,6 @@ static int msm_rng_read(struct hwrng *hwrng, void *data, size_t max, bool wait)
|
|||||||
/* calculate max size bytes to transfer back to caller */
|
/* calculate max size bytes to transfer back to caller */
|
||||||
maxsize = min_t(size_t, MAX_HW_FIFO_SIZE, max);
|
maxsize = min_t(size_t, MAX_HW_FIFO_SIZE, max);
|
||||||
|
|
||||||
/* no room for word data */
|
|
||||||
if (maxsize < WORD_SZ)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
ret = clk_prepare_enable(rng->clk);
|
ret = clk_prepare_enable(rng->clk);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -62,9 +62,6 @@ static int pic32_rng_read(struct hwrng *rng, void *buf, size_t max,
|
|||||||
u32 t;
|
u32 t;
|
||||||
unsigned int timeout = RNG_TIMEOUT;
|
unsigned int timeout = RNG_TIMEOUT;
|
||||||
|
|
||||||
if (max < 8)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
t = readl(priv->base + RNGRCNT) & RCNT_MASK;
|
t = readl(priv->base + RNGRCNT) & RCNT_MASK;
|
||||||
if (t == 64) {
|
if (t == 64) {
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
static int pseries_rng_read(struct hwrng *rng, void *data, size_t max, bool wait)
|
static int pseries_rng_read(struct hwrng *rng, void *data, size_t max, bool wait)
|
||||||
{
|
{
|
||||||
u64 buffer[PLPAR_HCALL_BUFSIZE];
|
u64 buffer[PLPAR_HCALL_BUFSIZE];
|
||||||
size_t size = max < 8 ? max : 8;
|
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = plpar_hcall(H_RANDOM, (unsigned long *)buffer);
|
rc = plpar_hcall(H_RANDOM, (unsigned long *)buffer);
|
||||||
@ -36,10 +35,10 @@ static int pseries_rng_read(struct hwrng *rng, void *data, size_t max, bool wait
|
|||||||
pr_err_ratelimited("H_RANDOM call failed %d\n", rc);
|
pr_err_ratelimited("H_RANDOM call failed %d\n", rc);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
memcpy(data, buffer, size);
|
memcpy(data, buffer, 8);
|
||||||
|
|
||||||
/* The hypervisor interface returns 64 bits */
|
/* The hypervisor interface returns 64 bits */
|
||||||
return size;
|
return 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,8 +30,7 @@
|
|||||||
* Must not be NULL. *OBSOLETE*
|
* Must not be NULL. *OBSOLETE*
|
||||||
* @read: New API. drivers can fill up to max bytes of data
|
* @read: New API. drivers can fill up to max bytes of data
|
||||||
* into the buffer. The buffer is aligned for any type
|
* into the buffer. The buffer is aligned for any type
|
||||||
* and max is guaranteed to be >= to that alignment
|
* and max is a multiple of 4 and >= 32 bytes.
|
||||||
* (either 4 or 8 depending on architecture).
|
|
||||||
* @priv: Private data, for use by the RNG driver.
|
* @priv: Private data, for use by the RNG driver.
|
||||||
* @quality: Estimation of true entropy in RNG's bitstream
|
* @quality: Estimation of true entropy in RNG's bitstream
|
||||||
* (per mill).
|
* (per mill).
|
||||||
|
Loading…
Reference in New Issue
Block a user