From b68e956abe2ad0a1ecf53868e0bf1a61b418ded8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Fri, 21 Oct 2016 20:49:37 +0300 Subject: char: move callbacks in CharDriver MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes the code more declarative, and avoids duplicating the information on all instances. Signed-off-by: Marc-André Lureau Reviewed-by: Eric Blake Signed-off-by: Paolo Bonzini --- backends/testdev.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'backends/testdev.c') 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); } -- cgit v1.2.3