* [PATCH v3] rng: Add Turris Mox rTWM RNG driver
@ 2024-02-07 15:00 Max Resch
2024-02-08 5:42 ` Stefan Roese
0 siblings, 1 reply; 2+ messages in thread
From: Max Resch @ 2024-02-07 15:00 UTC (permalink / raw)
To: u-boot; +Cc: sr, Max Resch
A RNG driver for Armada 3720 boards running the Turris Mox rWTM firmware
from CZ.NIC in the secure processor.
Signed-off-by: Max Resch <resch.max@gmail.com>
---
Changes in v3:
- More meaningful variable names in accordance with review
Changes in v2:
- Removed ring buffer implementation
drivers/rng/turris_rwtm_rng.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/rng/turris_rwtm_rng.c b/drivers/rng/turris_rwtm_rng.c
index 143fe0b47f..ec2cb0bca3 100644
--- a/drivers/rng/turris_rwtm_rng.c
+++ b/drivers/rng/turris_rwtm_rng.c
@@ -41,18 +41,19 @@ static int turris_rwtm_rng_fill_entropy(phys_addr_t entropy, size_t size)
static int turris_rwtm_rng_random_read(struct udevice *dev, void *data, size_t count)
{
- phys_addr_t p;
+ struct turris_rwtm_rng_priv *priv = dev_get_priv(dev);
+ phys_addr_t phys;
size_t size;
int ret;
- p = ((struct turris_rwtm_rng_priv *)dev_get_priv(dev))->buffer;
+ phys = priv->buffer;
while (count) {
size = min_t(size_t, RNG_BUFFER_SIZE, count);
- ret = turris_rwtm_rng_fill_entropy(p, size);
+ ret = turris_rwtm_rng_fill_entropy(phys, size);
- memcpy(data, (void *)p, size);
+ memcpy(data, (void *)phys, size);
count -= size;
data = (u8 *)data + size;
}
@@ -62,7 +63,7 @@ static int turris_rwtm_rng_random_read(struct udevice *dev, void *data, size_t c
static int turris_rwtm_rng_probe(struct udevice *dev)
{
- struct turris_rwtm_rng_priv *priv;
+ struct turris_rwtm_rng_priv *priv = dev_get_priv(dev);
u32 args[] = { 0 };
int ret;
@@ -76,7 +77,6 @@ static int turris_rwtm_rng_probe(struct udevice *dev)
return ret;
/* entropy buffer */
- priv = (struct turris_rwtm_rng_priv *)dev_get_priv(dev);
priv->buffer = 0;
/* buffer address need to be aligned */
@@ -89,10 +89,10 @@ static int turris_rwtm_rng_probe(struct udevice *dev)
static int turris_rwtm_rng_remove(struct udevice *dev)
{
- phys_addr_t p;
+ struct turris_rwtm_rng_priv *priv = dev_get_priv(dev);
+ phys_addr_t phys = priv->buffer;
- p = ((struct turris_rwtm_rng_priv *)dev_get_priv(dev))->buffer;
- dma_free_coherent((void *)p);
+ dma_free_coherent((void *)phys);
return 0;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v3] rng: Add Turris Mox rTWM RNG driver
2024-02-07 15:00 [PATCH v3] rng: Add Turris Mox rTWM RNG driver Max Resch
@ 2024-02-08 5:42 ` Stefan Roese
0 siblings, 0 replies; 2+ messages in thread
From: Stefan Roese @ 2024-02-08 5:42 UTC (permalink / raw)
To: Max Resch, u-boot
Hi Max,
On 2/7/24 16:00, Max Resch wrote:
> A RNG driver for Armada 3720 boards running the Turris Mox rWTM firmware
> from CZ.NIC in the secure processor.
>
> Signed-off-by: Max Resch <resch.max@gmail.com>
> ---
>
> Changes in v3:
> - More meaningful variable names in accordance with review
>
> Changes in v2:
> - Removed ring buffer implementation
>
> drivers/rng/turris_rwtm_rng.c | 18 +++++++++---------
> 1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/rng/turris_rwtm_rng.c b/drivers/rng/turris_rwtm_rng.c
> index 143fe0b47f..ec2cb0bca3 100644
> --- a/drivers/rng/turris_rwtm_rng.c
> +++ b/drivers/rng/turris_rwtm_rng.c
> @@ -41,18 +41,19 @@ static int turris_rwtm_rng_fill_entropy(phys_addr_t entropy, size_t size)
>
> static int turris_rwtm_rng_random_read(struct udevice *dev, void *data, size_t count)
> {
> - phys_addr_t p;
> + struct turris_rwtm_rng_priv *priv = dev_get_priv(dev);
> + phys_addr_t phys;
You've now just sent the update v2->v3. As v2 is not applied yet
this is not the way to do it. Please squash this patch into the v2
one a send this as v3 or even better v4 now.
Thanks,
Stefan
> size_t size;
> int ret;
>
> - p = ((struct turris_rwtm_rng_priv *)dev_get_priv(dev))->buffer;
> + phys = priv->buffer;
>
> while (count) {
> size = min_t(size_t, RNG_BUFFER_SIZE, count);
>
> - ret = turris_rwtm_rng_fill_entropy(p, size);
> + ret = turris_rwtm_rng_fill_entropy(phys, size);
>
> - memcpy(data, (void *)p, size);
> + memcpy(data, (void *)phys, size);
> count -= size;
> data = (u8 *)data + size;
> }
> @@ -62,7 +63,7 @@ static int turris_rwtm_rng_random_read(struct udevice *dev, void *data, size_t c
>
> static int turris_rwtm_rng_probe(struct udevice *dev)
> {
> - struct turris_rwtm_rng_priv *priv;
> + struct turris_rwtm_rng_priv *priv = dev_get_priv(dev);
> u32 args[] = { 0 };
> int ret;
>
> @@ -76,7 +77,6 @@ static int turris_rwtm_rng_probe(struct udevice *dev)
> return ret;
>
> /* entropy buffer */
> - priv = (struct turris_rwtm_rng_priv *)dev_get_priv(dev);
> priv->buffer = 0;
>
> /* buffer address need to be aligned */
> @@ -89,10 +89,10 @@ static int turris_rwtm_rng_probe(struct udevice *dev)
>
> static int turris_rwtm_rng_remove(struct udevice *dev)
> {
> - phys_addr_t p;
> + struct turris_rwtm_rng_priv *priv = dev_get_priv(dev);
> + phys_addr_t phys = priv->buffer;
>
> - p = ((struct turris_rwtm_rng_priv *)dev_get_priv(dev))->buffer;
> - dma_free_coherent((void *)p);
> + dma_free_coherent((void *)phys);
>
> return 0;
> }
Viele Grüße,
Stefan Roese
--
DENX Software Engineering GmbH, Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-02-08 5:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-07 15:00 [PATCH v3] rng: Add Turris Mox rTWM RNG driver Max Resch
2024-02-08 5:42 ` Stefan Roese
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.