From: "Marc-André Lureau" <marcandre.lureau@redhat.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, eblake@redhat.com,
"Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: [Qemu-devel] [PATCH v2 12/20] bt: use qemu_chr_alloc()
Date: Tue, 10 Jan 2017 18:48:02 +0100 [thread overview]
Message-ID: <20170110174810.17748-13-marcandre.lureau@redhat.com> (raw)
In-Reply-To: <20170110174810.17748-1-marcandre.lureau@redhat.com>
Use common allocator for CharDriverState.
Rename the now untouched parent field.
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>
---
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 bf2deb0497..e2c78b8720 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.11.0
next prev parent reply other threads:[~2017-01-10 17:48 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-10 17:47 [Qemu-devel] [PATCH v2 00/20] chardev: qom-ify Marc-André Lureau
2017-01-10 17:47 ` [Qemu-devel] [PATCH v2 01/20] tests: fix linking test-char on win32 Marc-André Lureau
2017-01-10 17:47 ` [Qemu-devel] [PATCH v2 02/20] qemu-options: stdio is available " Marc-André Lureau
2017-01-10 17:47 ` [Qemu-devel] [PATCH v2 03/20] char: add qemu_chr_fe_add_watch() Returns description Marc-André Lureau
2017-01-10 17:47 ` [Qemu-devel] [PATCH v2 04/20] doc: fix spelling Marc-André Lureau
2017-01-10 17:47 ` [Qemu-devel] [PATCH v2 05/20] char: use a const CharDriver Marc-André Lureau
2017-01-10 18:01 ` Eric Blake
2017-01-10 17:47 ` [Qemu-devel] [PATCH v2 06/20] char: use a static array for backends Marc-André Lureau
2017-01-10 18:03 ` Eric Blake
2017-01-10 17:47 ` [Qemu-devel] [PATCH v2 07/20] char: move callbacks in CharDriver Marc-André Lureau
2017-01-10 17:47 ` [Qemu-devel] [PATCH v2 08/20] char: fold single-user functions in caller Marc-André Lureau
2017-01-10 17:47 ` [Qemu-devel] [PATCH v2 09/20] char: introduce generic qemu_chr_get_kind() Marc-André Lureau
2017-01-10 17:48 ` [Qemu-devel] [PATCH v2 10/20] char: use a feature bit for replay Marc-André Lureau
2017-01-10 17:48 ` [Qemu-devel] [PATCH v2 11/20] char: allocate CharDriverState as a single object Marc-André Lureau
2017-01-10 17:48 ` Marc-André Lureau [this message]
2017-01-10 17:48 ` [Qemu-devel] [PATCH v2 13/20] char: rename CharDriverState Chardev Marc-André Lureau
2017-01-10 17:48 ` [Qemu-devel] [PATCH v2 14/20] char: rename TCPChardev and NetChardev Marc-André Lureau
2017-01-10 17:48 ` [Qemu-devel] [PATCH v2 15/20] spice-char: improve error reporting Marc-André Lureau
2017-01-10 17:48 ` [Qemu-devel] [PATCH v2 16/20] char: use error_report() Marc-André Lureau
2017-01-10 17:48 ` [Qemu-devel] [PATCH v2 17/20] gtk: overwrite the console.c char driver Marc-André Lureau
2017-01-10 17:48 ` [Qemu-devel] [PATCH v2 18/20] baum: use a common prefix for chr callbacks Marc-André Lureau
2017-01-10 17:48 ` [Qemu-devel] [PATCH v2 19/20] vc: " Marc-André Lureau
2017-01-10 17:48 ` [Qemu-devel] [PATCH v2 20/20] chardev: qom-ify Marc-André Lureau
2017-01-11 21:27 ` Eric Blake
2017-01-12 15:19 ` Marc-André Lureau
2017-01-24 13:59 ` [Qemu-devel] [PATCH v2 00/20] " Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170110174810.17748-13-marcandre.lureau@redhat.com \
--to=marcandre.lureau@redhat.com \
--cc=eblake@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).