* [PATCH v1] hw_random: npcm: modify readl to readb
@ 2020-09-23 21:23 ` Tomer Maimon
0 siblings, 0 replies; 4+ messages in thread
From: Tomer Maimon @ 2020-09-23 21:23 UTC (permalink / raw)
To: mpm, herbert, arnd, gregkh, avifishman70, tali.perry1, venture,
yuenn, benjaminfair, joel
Cc: linux-crypto, linux-kernel, openbmc, tmaimon77
Modify the read size to the correct HW random
registers size, 8bit.
The incorrect read size caused and faulty
HW random value.
Signed-off-by: Tomer Maimon <tmaimon77@gmail.com>
---
drivers/char/hw_random/npcm-rng.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/char/hw_random/npcm-rng.c b/drivers/char/hw_random/npcm-rng.c
index 5d0d13f891b7..1ec5f267a656 100644
--- a/drivers/char/hw_random/npcm-rng.c
+++ b/drivers/char/hw_random/npcm-rng.c
@@ -58,24 +58,24 @@ static int npcm_rng_read(struct hwrng *rng, void *buf, size_t max, bool wait)
pm_runtime_get_sync((struct device *)priv->rng.priv);
- while (max >= sizeof(u32)) {
+ while (max) {
if (wait) {
- if (readl_poll_timeout(priv->base + NPCM_RNGCS_REG,
+ if (readb_poll_timeout(priv->base + NPCM_RNGCS_REG,
ready,
ready & NPCM_RNG_DATA_VALID,
NPCM_RNG_POLL_USEC,
NPCM_RNG_TIMEOUT_USEC))
break;
} else {
- if ((readl(priv->base + NPCM_RNGCS_REG) &
+ if ((readb(priv->base + NPCM_RNGCS_REG) &
NPCM_RNG_DATA_VALID) == 0)
break;
}
- *(u32 *)buf = readl(priv->base + NPCM_RNGD_REG);
- retval += sizeof(u32);
- buf += sizeof(u32);
- max -= sizeof(u32);
+ *(u8 *)buf = readb(priv->base + NPCM_RNGD_REG);
+ retval++;
+ buf++;
+ max--;
}
pm_runtime_mark_last_busy((struct device *)priv->rng.priv);
--
2.22.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v1] hw_random: npcm: modify readl to readb
@ 2020-09-23 21:23 ` Tomer Maimon
0 siblings, 0 replies; 4+ messages in thread
From: Tomer Maimon @ 2020-09-23 21:23 UTC (permalink / raw)
To: mpm, herbert, arnd, gregkh, avifishman70, tali.perry1, venture,
yuenn, benjaminfair, joel
Cc: openbmc, tmaimon77, linux-crypto, linux-kernel
Modify the read size to the correct HW random
registers size, 8bit.
The incorrect read size caused and faulty
HW random value.
Signed-off-by: Tomer Maimon <tmaimon77@gmail.com>
---
drivers/char/hw_random/npcm-rng.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/char/hw_random/npcm-rng.c b/drivers/char/hw_random/npcm-rng.c
index 5d0d13f891b7..1ec5f267a656 100644
--- a/drivers/char/hw_random/npcm-rng.c
+++ b/drivers/char/hw_random/npcm-rng.c
@@ -58,24 +58,24 @@ static int npcm_rng_read(struct hwrng *rng, void *buf, size_t max, bool wait)
pm_runtime_get_sync((struct device *)priv->rng.priv);
- while (max >= sizeof(u32)) {
+ while (max) {
if (wait) {
- if (readl_poll_timeout(priv->base + NPCM_RNGCS_REG,
+ if (readb_poll_timeout(priv->base + NPCM_RNGCS_REG,
ready,
ready & NPCM_RNG_DATA_VALID,
NPCM_RNG_POLL_USEC,
NPCM_RNG_TIMEOUT_USEC))
break;
} else {
- if ((readl(priv->base + NPCM_RNGCS_REG) &
+ if ((readb(priv->base + NPCM_RNGCS_REG) &
NPCM_RNG_DATA_VALID) == 0)
break;
}
- *(u32 *)buf = readl(priv->base + NPCM_RNGD_REG);
- retval += sizeof(u32);
- buf += sizeof(u32);
- max -= sizeof(u32);
+ *(u8 *)buf = readb(priv->base + NPCM_RNGD_REG);
+ retval++;
+ buf++;
+ max--;
}
pm_runtime_mark_last_busy((struct device *)priv->rng.priv);
--
2.22.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v1] hw_random: npcm: modify readl to readb
2020-09-23 21:23 ` Tomer Maimon
@ 2020-10-02 11:54 ` Herbert Xu
-1 siblings, 0 replies; 4+ messages in thread
From: Herbert Xu @ 2020-10-02 11:54 UTC (permalink / raw)
To: Tomer Maimon
Cc: mpm, arnd, gregkh, avifishman70, tali.perry1, venture, yuenn,
benjaminfair, joel, linux-crypto, linux-kernel, openbmc
On Thu, Sep 24, 2020 at 12:23:05AM +0300, Tomer Maimon wrote:
> Modify the read size to the correct HW random
> registers size, 8bit.
> The incorrect read size caused and faulty
> HW random value.
>
> Signed-off-by: Tomer Maimon <tmaimon77@gmail.com>
> ---
> drivers/char/hw_random/npcm-rng.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
Patch applied. Thanks.
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v1] hw_random: npcm: modify readl to readb
@ 2020-10-02 11:54 ` Herbert Xu
0 siblings, 0 replies; 4+ messages in thread
From: Herbert Xu @ 2020-10-02 11:54 UTC (permalink / raw)
To: Tomer Maimon
Cc: benjaminfair, arnd, avifishman70, gregkh, openbmc, mpm,
linux-kernel, tali.perry1, venture, linux-crypto
On Thu, Sep 24, 2020 at 12:23:05AM +0300, Tomer Maimon wrote:
> Modify the read size to the correct HW random
> registers size, 8bit.
> The incorrect read size caused and faulty
> HW random value.
>
> Signed-off-by: Tomer Maimon <tmaimon77@gmail.com>
> ---
> drivers/char/hw_random/npcm-rng.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
Patch applied. Thanks.
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-10-02 11:57 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-23 21:23 [PATCH v1] hw_random: npcm: modify readl to readb Tomer Maimon
2020-09-23 21:23 ` Tomer Maimon
2020-10-02 11:54 ` Herbert Xu
2020-10-02 11:54 ` Herbert Xu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.