mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 15:23:53 -06:00
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>
This commit is contained in:
parent
a1698bf183
commit
b68e956abe
10 changed files with 381 additions and 260 deletions
|
@ -148,7 +148,8 @@ static QemuInputHandler msmouse_handler = {
|
|||
.sync = msmouse_input_sync,
|
||||
};
|
||||
|
||||
static CharDriverState *qemu_chr_open_msmouse(const char *id,
|
||||
static CharDriverState *qemu_chr_open_msmouse(const CharDriver *driver,
|
||||
const char *id,
|
||||
ChardevBackend *backend,
|
||||
ChardevReturn *ret,
|
||||
bool *be_opened,
|
||||
|
@ -158,13 +159,10 @@ static CharDriverState *qemu_chr_open_msmouse(const char *id,
|
|||
MouseState *mouse;
|
||||
CharDriverState *chr;
|
||||
|
||||
chr = qemu_chr_alloc(common, errp);
|
||||
chr = qemu_chr_alloc(driver, common, errp);
|
||||
if (!chr) {
|
||||
return NULL;
|
||||
}
|
||||
chr->chr_write = msmouse_chr_write;
|
||||
chr->chr_free = msmouse_chr_free;
|
||||
chr->chr_accept_input = msmouse_chr_accept_input;
|
||||
*be_opened = false;
|
||||
|
||||
mouse = g_new0(MouseState, 1);
|
||||
|
@ -182,6 +180,9 @@ static void register_types(void)
|
|||
static const CharDriver driver = {
|
||||
.kind = CHARDEV_BACKEND_KIND_MSMOUSE,
|
||||
.create = qemu_chr_open_msmouse,
|
||||
.chr_write = msmouse_chr_write,
|
||||
.chr_accept_input = msmouse_chr_accept_input,
|
||||
.chr_free = msmouse_chr_free,
|
||||
};
|
||||
register_char_driver(&driver);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue