* [PATCH] hw/misc/macio/cuda: Simplify using the ldst API
@ 2022-01-24 23:13 Philippe Mathieu-Daudé via
2022-01-25 13:55 ` Matheus K. Ferst
2022-01-26 7:42 ` Mark Cave-Ayland
0 siblings, 2 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-01-24 23:13 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-ppc, qemu-trivial, Mark Cave-Ayland, Philippe Mathieu-Daudé
This code is easier to review using the load/store API.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/misc/macio/cuda.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/hw/misc/macio/cuda.c b/hw/misc/macio/cuda.c
index e917a6a095..f1186671bf 100644
--- a/hw/misc/macio/cuda.c
+++ b/hw/misc/macio/cuda.c
@@ -36,6 +36,7 @@
#include "sysemu/runstate.h"
#include "qapi/error.h"
#include "qemu/cutils.h"
+#include "qemu/bswap.h"
#include "qemu/log.h"
#include "qemu/module.h"
#include "trace.h"
@@ -345,10 +346,7 @@ static bool cuda_cmd_get_time(CUDAState *s,
ti = s->tick_offset + (qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL)
/ NANOSECONDS_PER_SECOND);
- out_data[0] = ti >> 24;
- out_data[1] = ti >> 16;
- out_data[2] = ti >> 8;
- out_data[3] = ti;
+ stl_be_p(out_data, ti);
*out_len = 4;
return true;
}
@@ -363,8 +361,7 @@ static bool cuda_cmd_set_time(CUDAState *s,
return false;
}
- ti = (((uint32_t)in_data[0]) << 24) + (((uint32_t)in_data[1]) << 16)
- + (((uint32_t)in_data[2]) << 8) + in_data[3];
+ ti = ldl_be_p(in_data);
s->tick_offset = ti - (qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL)
/ NANOSECONDS_PER_SECOND);
return true;
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] hw/misc/macio/cuda: Simplify using the ldst API
2022-01-24 23:13 [PATCH] hw/misc/macio/cuda: Simplify using the ldst API Philippe Mathieu-Daudé via
@ 2022-01-25 13:55 ` Matheus K. Ferst
2022-01-26 7:42 ` Mark Cave-Ayland
1 sibling, 0 replies; 3+ messages in thread
From: Matheus K. Ferst @ 2022-01-25 13:55 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: qemu-trivial, Mark Cave-Ayland, qemu-ppc
On 24/01/2022 20:13, Philippe Mathieu-Daudé via wrote:
> This code is easier to review using the load/store API.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> hw/misc/macio/cuda.c | 9 +++------
> 1 file changed, 3 insertions(+), 6 deletions(-)
Reviewed-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
--
Matheus K. Ferst
Instituto de Pesquisas ELDORADO <http://www.eldorado.org.br/>
Analista de Software
Aviso Legal - Disclaimer <https://www.eldorado.org.br/disclaimer.html>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] hw/misc/macio/cuda: Simplify using the ldst API
2022-01-24 23:13 [PATCH] hw/misc/macio/cuda: Simplify using the ldst API Philippe Mathieu-Daudé via
2022-01-25 13:55 ` Matheus K. Ferst
@ 2022-01-26 7:42 ` Mark Cave-Ayland
1 sibling, 0 replies; 3+ messages in thread
From: Mark Cave-Ayland @ 2022-01-26 7:42 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel; +Cc: qemu-trivial, qemu-ppc
On 24/01/2022 23:13, Philippe Mathieu-Daudé via wrote:
> This code is easier to review using the load/store API.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> hw/misc/macio/cuda.c | 9 +++------
> 1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/hw/misc/macio/cuda.c b/hw/misc/macio/cuda.c
> index e917a6a095..f1186671bf 100644
> --- a/hw/misc/macio/cuda.c
> +++ b/hw/misc/macio/cuda.c
> @@ -36,6 +36,7 @@
> #include "sysemu/runstate.h"
> #include "qapi/error.h"
> #include "qemu/cutils.h"
> +#include "qemu/bswap.h"
> #include "qemu/log.h"
> #include "qemu/module.h"
> #include "trace.h"
> @@ -345,10 +346,7 @@ static bool cuda_cmd_get_time(CUDAState *s,
>
> ti = s->tick_offset + (qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL)
> / NANOSECONDS_PER_SECOND);
> - out_data[0] = ti >> 24;
> - out_data[1] = ti >> 16;
> - out_data[2] = ti >> 8;
> - out_data[3] = ti;
> + stl_be_p(out_data, ti);
> *out_len = 4;
> return true;
> }
> @@ -363,8 +361,7 @@ static bool cuda_cmd_set_time(CUDAState *s,
> return false;
> }
>
> - ti = (((uint32_t)in_data[0]) << 24) + (((uint32_t)in_data[1]) << 16)
> - + (((uint32_t)in_data[2]) << 8) + in_data[3];
> + ti = ldl_be_p(in_data);
> s->tick_offset = ti - (qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL)
> / NANOSECONDS_PER_SECOND);
> return true;
Looks fine to me.
Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
ATB,
Mark.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-01-26 7:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-24 23:13 [PATCH] hw/misc/macio/cuda: Simplify using the ldst API Philippe Mathieu-Daudé via
2022-01-25 13:55 ` Matheus K. Ferst
2022-01-26 7:42 ` Mark Cave-Ayland
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.