[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 22/41] char: make null_chr_write() the default method
From: |
Marc-André Lureau |
Subject: |
[Qemu-devel] [PULL 22/41] char: make null_chr_write() the default method |
Date: |
Tue, 31 Jan 2017 20:21:03 +0400 |
All chardev must implement chr_write(), but parallel and null chardev
both use null_chr_write(). Move it to the base class, so we don't need
to export the function when splitting the chardev in respective files.
Signed-off-by: Marc-André Lureau <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
---
chardev/char.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/chardev/char.c b/chardev/char.c
index 15f4a853bc..ee6ceb3471 100644
--- a/chardev/char.c
+++ b/chardev/char.c
@@ -522,6 +522,18 @@ static void char_init(Object *obj)
qemu_mutex_init(&chr->chr_write_lock);
}
+static int null_chr_write(Chardev *chr, const uint8_t *buf, int len)
+{
+ return len;
+}
+
+static void char_class_init(ObjectClass *oc, void *data)
+{
+ ChardevClass *cc = CHARDEV_CLASS(oc);
+
+ cc->chr_write = null_chr_write;
+}
+
static void char_finalize(Object *obj)
{
Chardev *chr = CHARDEV(obj);
@@ -545,13 +557,9 @@ static const TypeInfo char_type_info = {
.instance_finalize = char_finalize,
.abstract = true,
.class_size = sizeof(ChardevClass),
+ .class_init = char_class_init,
};
-static int null_chr_write(Chardev *chr, const uint8_t *buf, int len)
-{
- return len;
-}
-
static void null_chr_open(Chardev *chr,
ChardevBackend *backend,
bool *be_opened,
@@ -565,7 +573,6 @@ static void char_null_class_init(ObjectClass *oc, void
*data)
ChardevClass *cc = CHARDEV_CLASS(oc);
cc->open = null_chr_open;
- cc->chr_write = null_chr_write;
}
static const TypeInfo char_null_type_info = {
@@ -4712,10 +4719,8 @@ static void char_parallel_class_init(ObjectClass *oc,
void *data)
cc->parse = qemu_chr_parse_parallel;
cc->open = qmp_chardev_open_parallel;
#if defined(__linux__)
- cc->chr_write = null_chr_write;
cc->chr_ioctl = pp_ioctl;
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) ||
defined(__DragonFly__)
- cc->chr_write = null_chr_write;
cc->chr_ioctl = pp_ioctl;
#endif
}
--
2.11.0.295.gd7dffce1c.dirty
- [Qemu-devel] [PULL 11/41] char-stdio: convert to finalize, (continued)
- [Qemu-devel] [PULL 11/41] char-stdio: convert to finalize, Marc-André Lureau, 2017/01/31
- [Qemu-devel] [PULL 12/41] char-win-stdio: convert to finalize, Marc-André Lureau, 2017/01/31
- [Qemu-devel] [PULL 13/41] char-win: do not override chr_free, Marc-André Lureau, 2017/01/31
- [Qemu-devel] [PULL 14/41] char-win: convert to finalize, Marc-André Lureau, 2017/01/31
- [Qemu-devel] [PULL 15/41] char-fd: convert to finalize, Marc-André Lureau, 2017/01/31
- [Qemu-devel] [PULL 16/41] char: remove chr_free, Marc-André Lureau, 2017/01/31
- [Qemu-devel] [PULL 18/41] char: rename remaining CharDriver to Chardev, Marc-André Lureau, 2017/01/31
- [Qemu-devel] [PULL 17/41] char: get rid of CharDriver, Marc-André Lureau, 2017/01/31
- [Qemu-devel] [PULL 19/41] char: remove class kind field, Marc-André Lureau, 2017/01/31
- [Qemu-devel] [PULL 20/41] char: move to chardev/, Marc-André Lureau, 2017/01/31
- [Qemu-devel] [PULL 22/41] char: make null_chr_write() the default method,
Marc-André Lureau <=
- [Qemu-devel] [PULL 21/41] char: create chardev-obj-y, Marc-André Lureau, 2017/01/31
- [Qemu-devel] [PULL 23/41] char: move null chardev to its own file, Marc-André Lureau, 2017/01/31
- [Qemu-devel] [PULL 24/41] char: move mux to its own file, Marc-André Lureau, 2017/01/31
- [Qemu-devel] [PULL 25/41] char: move ringbuf/memory to its own file, Marc-André Lureau, 2017/01/31
- [Qemu-devel] [PULL 26/41] char: rename and move to header CHR_READ_BUF_LEN, Marc-André Lureau, 2017/01/31
- [Qemu-devel] [PULL 27/41] char: remove unused READ_RETRIES, Marc-André Lureau, 2017/01/31
- [Qemu-devel] [PULL 28/41] char: move QIOChannel-related stuff to char-io.h, Marc-André Lureau, 2017/01/31
- [Qemu-devel] [PULL 29/41] char: move fd chardev in its own file, Marc-André Lureau, 2017/01/31
- [Qemu-devel] [PULL 30/41] char: move win chardev base class in its own file, Marc-André Lureau, 2017/01/31
- [Qemu-devel] [PULL 31/41] char: move win-stdio into its own file, Marc-André Lureau, 2017/01/31