[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v6 11/30] hw/char/sh_serial: Embed QEMUTimer in state struct
From: |
BALATON Zoltan |
Subject: |
[PATCH v6 11/30] hw/char/sh_serial: Embed QEMUTimer in state struct |
Date: |
Fri, 29 Oct 2021 23:02:09 +0200 |
Instead of allocating timer with timer_new store it directly in the
state struct. This makes it simpler to free it together with the device.
Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
---
hw/char/sh_serial.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/hw/char/sh_serial.c b/hw/char/sh_serial.c
index bc5e0c4404..5ee93dc732 100644
--- a/hw/char/sh_serial.c
+++ b/hw/char/sh_serial.c
@@ -65,7 +65,7 @@ typedef struct {
int rtrg;
CharBackend chr;
- QEMUTimer *fifo_timeout_timer;
+ QEMUTimer fifo_timeout_timer;
uint64_t etu; /* Elementary Time Unit (ns) */
qemu_irq eri;
@@ -353,11 +353,11 @@ static void sh_serial_receive1(void *opaque, const
uint8_t *buf, int size)
if (s->rx_cnt >= s->rtrg) {
s->flags |= SH_SERIAL_FLAG_RDF;
if (s->scr & (1 << 6) && s->rxi) {
- timer_del(s->fifo_timeout_timer);
+ timer_del(&s->fifo_timeout_timer);
qemu_set_irq(s->rxi, 1);
}
} else {
- timer_mod(s->fifo_timeout_timer,
+ timer_mod(&s->fifo_timeout_timer,
qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + 15 * s->etu);
}
}
@@ -427,8 +427,8 @@ void sh_serial_init(MemoryRegion *sysmem,
sh_serial_event, NULL, s, NULL, true);
}
- s->fifo_timeout_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL,
- sh_serial_timeout_int, s);
+ timer_init_ns(&s->fifo_timeout_timer, QEMU_CLOCK_VIRTUAL,
+ sh_serial_timeout_int, s);
s->etu = NANOSECONDS_PER_SECOND / 9600;
s->eri = eri_source;
s->rxi = rxi_source;
--
2.21.4
- [PATCH v6 05/30] hw/sh4: Coding style: Remove unnecessary casts, (continued)
- [PATCH v6 05/30] hw/sh4: Coding style: Remove unnecessary casts, BALATON Zoltan, 2021/10/29
- [PATCH v6 08/30] hw/sh4/r2d: Use error_report instead of fprintf to stderr, BALATON Zoltan, 2021/10/29
- [PATCH v6 09/30] hw/char/sh_serial: Do not abort on invalid access, BALATON Zoltan, 2021/10/29
- [PATCH v6 12/30] hw/char/sh_serial: Split off sh_serial_reset() from sh_serial_init(), BALATON Zoltan, 2021/10/29
- [PATCH v6 07/30] hw/sh4: Change debug printfs to traces, BALATON Zoltan, 2021/10/29
- [PATCH v6 10/30] hw/char/sh_serial: Rename type sh_serial_state to SHSerialState, BALATON Zoltan, 2021/10/29
- [PATCH v6 06/30] hw/sh4: Fix typos in a comment, BALATON Zoltan, 2021/10/29
- [PATCH v6 01/30] hw/sh4: Coding style: Remove tabs, BALATON Zoltan, 2021/10/29
- [PATCH v6 02/30] hw/sh4: Coding style: Fix multi-line comments, BALATON Zoltan, 2021/10/29
- [PATCH v6 11/30] hw/char/sh_serial: Embed QEMUTimer in state struct,
BALATON Zoltan <=
- [PATCH v6 13/30] hw/char/sh_serial: QOM-ify, BALATON Zoltan, 2021/10/29
- [PATCH v6 17/30] hw/intc/sh_intc: Rename iomem region, BALATON Zoltan, 2021/10/29
- [PATCH v6 19/30] hw/intc/sh_intc: Move sh_intc_register() closer to its only user, BALATON Zoltan, 2021/10/29
- [PATCH v6 15/30] hw/intc/sh_intc: Use existing macro instead of local one, BALATON Zoltan, 2021/10/29
- [PATCH v6 03/30] hw/sh4: Coding style: White space fixes, BALATON Zoltan, 2021/10/29
- [PATCH v6 20/30] hw/intc/sh_intc: Remove excessive parenthesis, BALATON Zoltan, 2021/10/29
- [PATCH v6 16/30] hw/intc/sh_intc: Turn some defines into an enum, BALATON Zoltan, 2021/10/29