* [PATCH] hw/m68k/mcf5206: Embed m5206_timer_state in m5206_mbar_state
@ 2023-12-21 12:29 Thomas Huth
2023-12-26 11:55 ` Philippe Mathieu-Daudé
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Thomas Huth @ 2023-12-21 12:29 UTC (permalink / raw)
To: qemu-devel; +Cc: Mark Cave-Ayland, Laurent Vivier
There's no need to explicitely allocate the memory here, we can
simply embed it into the m5206_mbar_state instead.
Signed-off-by: Thomas Huth <huth@tuxfamily.org>
---
hw/m68k/mcf5206.c | 20 ++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)
diff --git a/hw/m68k/mcf5206.c b/hw/m68k/mcf5206.c
index a46a23538d..183fd3cc08 100644
--- a/hw/m68k/mcf5206.c
+++ b/hw/m68k/mcf5206.c
@@ -148,15 +148,11 @@ static void m5206_timer_write(m5206_timer_state *s, uint32_t addr, uint32_t val)
m5206_timer_update(s);
}
-static m5206_timer_state *m5206_timer_init(qemu_irq irq)
+static void m5206_timer_init(m5206_timer_state *s, qemu_irq irq)
{
- m5206_timer_state *s;
-
- s = g_new0(m5206_timer_state, 1);
s->timer = ptimer_init(m5206_timer_trigger, s, PTIMER_POLICY_LEGACY);
s->irq = irq;
m5206_timer_reset(s);
- return s;
}
/* System Integration Module. */
@@ -167,7 +163,7 @@ typedef struct {
M68kCPU *cpu;
MemoryRegion iomem;
qemu_irq *pic;
- m5206_timer_state *timer[2];
+ m5206_timer_state timer[2];
DeviceState *uart[2];
uint8_t scr;
uint8_t icr[14];
@@ -293,9 +289,9 @@ static uint64_t m5206_mbar_read(m5206_mbar_state *s,
uint16_t offset, unsigned size)
{
if (offset >= 0x100 && offset < 0x120) {
- return m5206_timer_read(s->timer[0], offset - 0x100);
+ return m5206_timer_read(&s->timer[0], offset - 0x100);
} else if (offset >= 0x120 && offset < 0x140) {
- return m5206_timer_read(s->timer[1], offset - 0x120);
+ return m5206_timer_read(&s->timer[1], offset - 0x120);
} else if (offset >= 0x140 && offset < 0x160) {
return mcf_uart_read(s->uart[0], offset - 0x140, size);
} else if (offset >= 0x180 && offset < 0x1a0) {
@@ -333,10 +329,10 @@ static void m5206_mbar_write(m5206_mbar_state *s, uint16_t offset,
uint64_t value, unsigned size)
{
if (offset >= 0x100 && offset < 0x120) {
- m5206_timer_write(s->timer[0], offset - 0x100, value);
+ m5206_timer_write(&s->timer[0], offset - 0x100, value);
return;
} else if (offset >= 0x120 && offset < 0x140) {
- m5206_timer_write(s->timer[1], offset - 0x120, value);
+ m5206_timer_write(&s->timer[1], offset - 0x120, value);
return;
} else if (offset >= 0x140 && offset < 0x160) {
mcf_uart_write(s->uart[0], offset - 0x140, value, size);
@@ -598,8 +594,8 @@ static void mcf5206_mbar_realize(DeviceState *dev, Error **errp)
sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem);
s->pic = qemu_allocate_irqs(m5206_mbar_set_irq, s, 14);
- s->timer[0] = m5206_timer_init(s->pic[9]);
- s->timer[1] = m5206_timer_init(s->pic[10]);
+ m5206_timer_init(&s->timer[0], s->pic[9]);
+ m5206_timer_init(&s->timer[1], s->pic[10]);
s->uart[0] = mcf_uart_create(s->pic[12], serial_hd(0));
s->uart[1] = mcf_uart_create(s->pic[13], serial_hd(1));
}
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] hw/m68k/mcf5206: Embed m5206_timer_state in m5206_mbar_state
2023-12-21 12:29 [PATCH] hw/m68k/mcf5206: Embed m5206_timer_state in m5206_mbar_state Thomas Huth
@ 2023-12-26 11:55 ` Philippe Mathieu-Daudé
2023-12-27 19:54 ` Mark Cave-Ayland
2024-01-05 21:59 ` Philippe Mathieu-Daudé
2 siblings, 0 replies; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-26 11:55 UTC (permalink / raw)
To: Thomas Huth, qemu-devel; +Cc: Mark Cave-Ayland, Laurent Vivier
On 21/12/23 13:29, Thomas Huth wrote:
> There's no need to explicitely allocate the memory here, we can
> simply embed it into the m5206_mbar_state instead.
>
> Signed-off-by: Thomas Huth <huth@tuxfamily.org>
> ---
> hw/m68k/mcf5206.c | 20 ++++++++------------
> 1 file changed, 8 insertions(+), 12 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] hw/m68k/mcf5206: Embed m5206_timer_state in m5206_mbar_state
2023-12-21 12:29 [PATCH] hw/m68k/mcf5206: Embed m5206_timer_state in m5206_mbar_state Thomas Huth
2023-12-26 11:55 ` Philippe Mathieu-Daudé
@ 2023-12-27 19:54 ` Mark Cave-Ayland
2024-01-05 21:59 ` Philippe Mathieu-Daudé
2 siblings, 0 replies; 4+ messages in thread
From: Mark Cave-Ayland @ 2023-12-27 19:54 UTC (permalink / raw)
To: Thomas Huth, qemu-devel; +Cc: Laurent Vivier
On 21/12/2023 12:29, Thomas Huth wrote:
> There's no need to explicitely allocate the memory here, we can
> simply embed it into the m5206_mbar_state instead.
>
> Signed-off-by: Thomas Huth <huth@tuxfamily.org>
> ---
> hw/m68k/mcf5206.c | 20 ++++++++------------
> 1 file changed, 8 insertions(+), 12 deletions(-)
>
> diff --git a/hw/m68k/mcf5206.c b/hw/m68k/mcf5206.c
> index a46a23538d..183fd3cc08 100644
> --- a/hw/m68k/mcf5206.c
> +++ b/hw/m68k/mcf5206.c
> @@ -148,15 +148,11 @@ static void m5206_timer_write(m5206_timer_state *s, uint32_t addr, uint32_t val)
> m5206_timer_update(s);
> }
>
> -static m5206_timer_state *m5206_timer_init(qemu_irq irq)
> +static void m5206_timer_init(m5206_timer_state *s, qemu_irq irq)
> {
> - m5206_timer_state *s;
> -
> - s = g_new0(m5206_timer_state, 1);
> s->timer = ptimer_init(m5206_timer_trigger, s, PTIMER_POLICY_LEGACY);
> s->irq = irq;
> m5206_timer_reset(s);
> - return s;
> }
>
> /* System Integration Module. */
> @@ -167,7 +163,7 @@ typedef struct {
> M68kCPU *cpu;
> MemoryRegion iomem;
> qemu_irq *pic;
> - m5206_timer_state *timer[2];
> + m5206_timer_state timer[2];
> DeviceState *uart[2];
> uint8_t scr;
> uint8_t icr[14];
> @@ -293,9 +289,9 @@ static uint64_t m5206_mbar_read(m5206_mbar_state *s,
> uint16_t offset, unsigned size)
> {
> if (offset >= 0x100 && offset < 0x120) {
> - return m5206_timer_read(s->timer[0], offset - 0x100);
> + return m5206_timer_read(&s->timer[0], offset - 0x100);
> } else if (offset >= 0x120 && offset < 0x140) {
> - return m5206_timer_read(s->timer[1], offset - 0x120);
> + return m5206_timer_read(&s->timer[1], offset - 0x120);
> } else if (offset >= 0x140 && offset < 0x160) {
> return mcf_uart_read(s->uart[0], offset - 0x140, size);
> } else if (offset >= 0x180 && offset < 0x1a0) {
> @@ -333,10 +329,10 @@ static void m5206_mbar_write(m5206_mbar_state *s, uint16_t offset,
> uint64_t value, unsigned size)
> {
> if (offset >= 0x100 && offset < 0x120) {
> - m5206_timer_write(s->timer[0], offset - 0x100, value);
> + m5206_timer_write(&s->timer[0], offset - 0x100, value);
> return;
> } else if (offset >= 0x120 && offset < 0x140) {
> - m5206_timer_write(s->timer[1], offset - 0x120, value);
> + m5206_timer_write(&s->timer[1], offset - 0x120, value);
> return;
> } else if (offset >= 0x140 && offset < 0x160) {
> mcf_uart_write(s->uart[0], offset - 0x140, value, size);
> @@ -598,8 +594,8 @@ static void mcf5206_mbar_realize(DeviceState *dev, Error **errp)
> sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem);
>
> s->pic = qemu_allocate_irqs(m5206_mbar_set_irq, s, 14);
> - s->timer[0] = m5206_timer_init(s->pic[9]);
> - s->timer[1] = m5206_timer_init(s->pic[10]);
> + m5206_timer_init(&s->timer[0], s->pic[9]);
> + m5206_timer_init(&s->timer[1], s->pic[10]);
> s->uart[0] = mcf_uart_create(s->pic[12], serial_hd(0));
> s->uart[1] = mcf_uart_create(s->pic[13], serial_hd(1));
> }
Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
This reminds me that there is one still remaining memory region left to convert in
q800.c...
ATB,
Mark.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] hw/m68k/mcf5206: Embed m5206_timer_state in m5206_mbar_state
2023-12-21 12:29 [PATCH] hw/m68k/mcf5206: Embed m5206_timer_state in m5206_mbar_state Thomas Huth
2023-12-26 11:55 ` Philippe Mathieu-Daudé
2023-12-27 19:54 ` Mark Cave-Ayland
@ 2024-01-05 21:59 ` Philippe Mathieu-Daudé
2 siblings, 0 replies; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-01-05 21:59 UTC (permalink / raw)
To: Thomas Huth, qemu-devel; +Cc: Mark Cave-Ayland, Laurent Vivier
On 21/12/23 13:29, Thomas Huth wrote:
> There's no need to explicitely allocate the memory here, we can
> simply embed it into the m5206_mbar_state instead.
>
> Signed-off-by: Thomas Huth <huth@tuxfamily.org>
> ---
> hw/m68k/mcf5206.c | 20 ++++++++------------
> 1 file changed, 8 insertions(+), 12 deletions(-)
Patch merged as commit 5e077a7767.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-01-05 21:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-21 12:29 [PATCH] hw/m68k/mcf5206: Embed m5206_timer_state in m5206_mbar_state Thomas Huth
2023-12-26 11:55 ` Philippe Mathieu-Daudé
2023-12-27 19:54 ` Mark Cave-Ayland
2024-01-05 21:59 ` Philippe Mathieu-Daudé
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).