char: move callbacks in CharDriver

This makes the code more declarative, and avoids duplicating the
information on all instances.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Marc-André Lureau 2016-10-21 20:49:37 +03:00 committed by Paolo Bonzini
parent a1698bf183
commit b68e956abe
10 changed files with 381 additions and 260 deletions

View file

@ -462,12 +462,16 @@ qemu_irq *csrhci_pins_get(CharDriverState *chr)
CharDriverState *uart_hci_init(void)
{
static const CharDriver hci_driver = {
.kind = -1,
.chr_write = csrhci_write,
.chr_ioctl = csrhci_ioctl,
};
struct csrhci_s *s = (struct csrhci_s *)
g_malloc0(sizeof(struct csrhci_s));
s->chr.opaque = s;
s->chr.chr_write = csrhci_write;
s->chr.chr_ioctl = csrhci_ioctl;
s->chr.driver = &hci_driver;
s->hci = qemu_next_hci();
s->hci->opaque = s;