[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 38/38] bt: use qemu_chr_alloc()
From: |
Marc-André Lureau |
Subject: |
[Qemu-devel] [PATCH 38/38] bt: use qemu_chr_alloc() |
Date: |
Sat, 22 Oct 2016 13:16:40 +0300 |
Use common allocator for CharDriverState.
Signed-off-by: Marc-André Lureau <address@hidden>
---
hw/bt/hci-csr.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/hw/bt/hci-csr.c b/hw/bt/hci-csr.c
index bf2deb0..e2c78b8 100644
--- a/hw/bt/hci-csr.c
+++ b/hw/bt/hci-csr.c
@@ -26,9 +26,10 @@
#include "hw/irq.h"
#include "sysemu/bt.h"
#include "hw/bt.h"
+#include "qapi/error.h"
struct csrhci_s {
- CharDriverState chr;
+ CharDriverState parent;
int enable;
qemu_irq *pins;
int pin_state;
@@ -78,7 +79,8 @@ enum {
static inline void csrhci_fifo_wake(struct csrhci_s *s)
{
- CharBackend *be = s->chr.be;
+ CharDriverState *chr = (CharDriverState *)s;
+ CharBackend *be = chr->be;
if (!s->enable || !s->out_len)
return;
@@ -468,10 +470,15 @@ CharDriverState *uart_hci_init(void)
.chr_write = csrhci_write,
.chr_ioctl = csrhci_ioctl,
};
- struct csrhci_s *s = (struct csrhci_s *)
- g_malloc0(sizeof(struct csrhci_s));
+ Error *err = NULL;
+ ChardevCommon common = { 0, };
+ CharDriverState *chr = qemu_chr_alloc(&hci_driver, &common, &err);
+ struct csrhci_s *s = (struct csrhci_s *)chr;
- s->chr.driver = &hci_driver;
+ if (err) {
+ error_report_err(err);
+ return NULL;
+ }
s->hci = qemu_next_hci();
s->hci->opaque = s;
@@ -482,5 +489,5 @@ CharDriverState *uart_hci_init(void)
s->pins = qemu_allocate_irqs(csrhci_pins, s, __csrhci_pins);
csrhci_reset(s);
- return &s->chr;
+ return chr;
}
--
2.10.0
- [Qemu-devel] [PATCH 30/38] char: remove explicit_be_open from CharDriverState, (continued)
- [Qemu-devel] [PATCH 30/38] char: remove explicit_be_open from CharDriverState, Marc-André Lureau, 2016/10/22
- [Qemu-devel] [PATCH 31/38] char: use a const CharDriver, Marc-André Lureau, 2016/10/22
- [Qemu-devel] [PATCH 32/38] char: use a static array for backends, Marc-André Lureau, 2016/10/22
- [Qemu-devel] [PATCH 33/38] char: move callbacks in CharDriver, Marc-André Lureau, 2016/10/22
- [Qemu-devel] [PATCH 34/38] char: fold single-user functions in caller, Marc-André Lureau, 2016/10/22
- [Qemu-devel] [PATCH 35/38] char: introduce generic qemu_chr_get_kind(), Marc-André Lureau, 2016/10/22
- [Qemu-devel] [PATCH 36/38] char: use a feature bit for replay, Marc-André Lureau, 2016/10/22
- [Qemu-devel] [PATCH 37/38] char: allocate CharDriverState as a single object, Marc-André Lureau, 2016/10/22
- Re: [Qemu-devel] [PATCH 00/38] char: fixes and improvements (was "[PATCH 0/9] Fix mux regression"), Paolo Bonzini, 2016/10/23