aboutsummaryrefslogtreecommitdiff
path: root/backends/testdev.c
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2016-10-21 20:49:37 +0300
committerPaolo Bonzini <pbonzini@redhat.com>2017-01-27 18:07:58 +0100
commitb68e956abe2ad0a1ecf53868e0bf1a61b418ded8 (patch)
tree2d25f219ee74ed5671959e92f9018ccd408cd35a /backends/testdev.c
parenta1698bf183a2fc05ff980e06c798408d5898bc48 (diff)
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>
Diffstat (limited to 'backends/testdev.c')
-rw-r--r--backends/testdev.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/backends/testdev.c b/backends/testdev.c
index cd25094f86..233969391b 100644
--- a/backends/testdev.c
+++ b/backends/testdev.c
@@ -109,7 +109,8 @@ static void testdev_free(struct CharDriverState *chr)
g_free(testdev);
}
-static CharDriverState *chr_testdev_init(const char *id,
+static CharDriverState *chr_testdev_init(const CharDriver *driver,
+ const char *id,
ChardevBackend *backend,
ChardevReturn *ret,
bool *be_opened,
@@ -121,9 +122,8 @@ static CharDriverState *chr_testdev_init(const char *id,
testdev = g_new0(TestdevCharState, 1);
testdev->chr = chr = g_new0(CharDriverState, 1);
+ chr->driver = driver;
chr->opaque = testdev;
- chr->chr_write = testdev_write;
- chr->chr_free = testdev_free;
return chr;
}
@@ -133,6 +133,8 @@ static void register_types(void)
static const CharDriver driver = {
.kind = CHARDEV_BACKEND_KIND_TESTDEV,
.create = chr_testdev_init,
+ .chr_write = testdev_write,
+ .chr_free = testdev_free,
};
register_char_driver(&driver);
}