diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2016-10-21 23:44:44 +0300 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2017-01-27 18:07:59 +0100 |
commit | 41ac54b253f41df924c350ef63564df8e1d8ad88 (patch) | |
tree | a6d8fdcb913b558c4f5ecc698bd82ae1a195705c /hw/bt | |
parent | 5ebd67030c4e4bc702d07a3e10c909be4520f170 (diff) |
char: allocate CharDriverState as a single object
Use a single allocation for CharDriverState, this avoids extra
allocations & pointers, and is a step towards more object-oriented
CharDriver.
Gtk console is a bit peculiar, gd_vc_chr_set_echo() used to have a
temporary VirtualConsole to save the echo bit. Instead now, we consider
whether vcd->console is set or not, and restore the echo bit saved in
VCDriverState when calling gd_vc_vte_init().
The casts added are temporary, they are replaced with QOM type-safe
macros in a later patch in this series.
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>
Diffstat (limited to 'hw/bt')
-rw-r--r-- | hw/bt/hci-csr.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/hw/bt/hci-csr.c b/hw/bt/hci-csr.c index 9c3fb3c8f9..bf2deb0497 100644 --- a/hw/bt/hci-csr.c +++ b/hw/bt/hci-csr.c @@ -28,11 +28,11 @@ #include "hw/bt.h" struct csrhci_s { + CharDriverState chr; int enable; qemu_irq *pins; int pin_state; int modem_state; - CharDriverState chr; #define FIFO_LEN 4096 int out_start; int out_len; @@ -314,7 +314,7 @@ static void csrhci_ready_for_next_inpkt(struct csrhci_s *s) static int csrhci_write(struct CharDriverState *chr, const uint8_t *buf, int len) { - struct csrhci_s *s = (struct csrhci_s *) chr->opaque; + struct csrhci_s *s = (struct csrhci_s *)chr; int total = 0; if (!s->enable) @@ -387,7 +387,7 @@ static void csrhci_out_hci_packet_acl(void *opaque, static int csrhci_ioctl(struct CharDriverState *chr, int cmd, void *arg) { QEMUSerialSetParams *ssp; - struct csrhci_s *s = (struct csrhci_s *) chr->opaque; + struct csrhci_s *s = (struct csrhci_s *) chr; int prev_state = s->modem_state; switch (cmd) { @@ -455,7 +455,7 @@ static void csrhci_pins(void *opaque, int line, int level) qemu_irq *csrhci_pins_get(CharDriverState *chr) { - struct csrhci_s *s = (struct csrhci_s *) chr->opaque; + struct csrhci_s *s = (struct csrhci_s *) chr; return s->pins; } @@ -463,6 +463,7 @@ qemu_irq *csrhci_pins_get(CharDriverState *chr) CharDriverState *uart_hci_init(void) { static const CharDriver hci_driver = { + .instance_size = sizeof(struct csrhci_s), .kind = -1, .chr_write = csrhci_write, .chr_ioctl = csrhci_ioctl, @@ -470,7 +471,6 @@ CharDriverState *uart_hci_init(void) struct csrhci_s *s = (struct csrhci_s *) g_malloc0(sizeof(struct csrhci_s)); - s->chr.opaque = s; s->chr.driver = &hci_driver; s->hci = qemu_next_hci(); |