hw/char/sh_serial: Embed QEMUTimer in state struct
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> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-Id: <fd01eb3720ec32dab06e03019f72f3e177033679.1635541329.git.balaton@eik.bme.hu> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
This commit is contained in:
parent
2f6df13748
commit
5b344b02e1
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user