From 0ec7b3e7f21caf6bfde404528928d600b661ea8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Wed, 7 Dec 2016 16:20:22 +0300 Subject: char: rename CharDriverState Chardev MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pick a uniform chardev type name. Signed-off-by: Marc-André Lureau Reviewed-by: Eric Blake Signed-off-by: Paolo Bonzini --- backends/baum.c | 56 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 27 deletions(-) (limited to 'backends/baum.c') diff --git a/backends/baum.c b/backends/baum.c index 4b48cf02b9..23d3c4aeaa 100644 --- a/backends/baum.c +++ b/backends/baum.c @@ -85,7 +85,7 @@ #define BUF_SIZE 256 typedef struct { - CharDriverState parent; + Chardev parent; brlapi_handle_t *brlapi; int brlapi_fd; @@ -98,7 +98,7 @@ typedef struct { uint8_t out_buf_used, out_buf_ptr; QEMUTimer *cellCount_timer; -} BaumDriverState; +} BaumChardev; /* Let's assume NABCC by default */ enum way { @@ -223,7 +223,7 @@ static const uint8_t nabcc_translation[2][256] = { }; /* The guest OS has started discussing with us, finish initializing BrlAPI */ -static int baum_deferred_init(BaumDriverState *baum) +static int baum_deferred_init(BaumChardev *baum) { int tty = BRLAPI_TTY_DEFAULT; QemuConsole *con; @@ -253,9 +253,9 @@ static int baum_deferred_init(BaumDriverState *baum) } /* The serial port can receive more of our data */ -static void baum_accept_input(struct CharDriverState *chr) +static void baum_accept_input(struct Chardev *chr) { - BaumDriverState *baum = (BaumDriverState *)chr; + BaumChardev *baum = (BaumChardev *)chr; int room, first; if (!baum->out_buf_used) @@ -279,9 +279,9 @@ static void baum_accept_input(struct CharDriverState *chr) } /* We want to send a packet */ -static void baum_write_packet(BaumDriverState *baum, const uint8_t *buf, int len) +static void baum_write_packet(BaumChardev *baum, const uint8_t *buf, int len) { - CharDriverState *chr = (CharDriverState *)baum; + Chardev *chr = (Chardev *)baum; uint8_t io_buf[1 + 2 * len], *cur = io_buf; int room; *cur++ = ESC; @@ -322,14 +322,14 @@ static void baum_write_packet(BaumDriverState *baum, const uint8_t *buf, int len /* Called when the other end seems to have a wrong idea of our display size */ static void baum_cellCount_timer_cb(void *opaque) { - BaumDriverState *baum = opaque; + BaumChardev *baum = opaque; uint8_t cell_count[] = { BAUM_RSP_CellCount, baum->x * baum->y }; DPRINTF("Timeout waiting for DisplayData, sending cell count\n"); baum_write_packet(baum, cell_count, sizeof(cell_count)); } /* Try to interpret a whole incoming packet */ -static int baum_eat_packet(BaumDriverState *baum, const uint8_t *buf, int len) +static int baum_eat_packet(BaumChardev *baum, const uint8_t *buf, int len) { const uint8_t *cur = buf; uint8_t req = 0; @@ -470,9 +470,9 @@ static int baum_eat_packet(BaumDriverState *baum, const uint8_t *buf, int len) } /* The other end is writing some data. Store it and try to interpret */ -static int baum_write(CharDriverState *chr, const uint8_t *buf, int len) +static int baum_write(Chardev *chr, const uint8_t *buf, int len) { - BaumDriverState *baum = (BaumDriverState *)chr; + BaumChardev *baum = (BaumChardev *)chr; int tocopy, cur, eaten, orig_len = len; if (!len) @@ -511,14 +511,16 @@ static int baum_write(CharDriverState *chr, const uint8_t *buf, int len) } /* Send the key code to the other end */ -static void baum_send_key(BaumDriverState *baum, uint8_t type, uint8_t value) { +static void baum_send_key(BaumChardev *baum, uint8_t type, uint8_t value) +{ uint8_t packet[] = { type, value }; DPRINTF("writing key %x %x\n", type, value); baum_write_packet(baum, packet, sizeof(packet)); } -static void baum_send_key2(BaumDriverState *baum, uint8_t type, uint8_t value, - uint8_t value2) { +static void baum_send_key2(BaumChardev *baum, uint8_t type, uint8_t value, + uint8_t value2) +{ uint8_t packet[] = { type, value, value2 }; DPRINTF("writing key %x %x\n", type, value); baum_write_packet(baum, packet, sizeof(packet)); @@ -527,7 +529,7 @@ static void baum_send_key2(BaumDriverState *baum, uint8_t type, uint8_t value, /* We got some data on the BrlAPI socket */ static void baum_chr_read(void *opaque) { - BaumDriverState *baum = opaque; + BaumChardev *baum = opaque; brlapi_keyCode_t code; int ret; if (!baum->brlapi) @@ -611,9 +613,9 @@ static void baum_chr_read(void *opaque) } } -static void baum_free(struct CharDriverState *chr) +static void baum_free(struct Chardev *chr) { - BaumDriverState *baum = (BaumDriverState *)chr; + BaumChardev *baum = (BaumChardev *)chr; timer_free(baum->cellCount_timer); if (baum->brlapi) { @@ -622,23 +624,23 @@ static void baum_free(struct CharDriverState *chr) } } -static CharDriverState *chr_baum_init(const CharDriver *driver, - const char *id, - ChardevBackend *backend, - ChardevReturn *ret, - bool *be_opened, - Error **errp) +static Chardev *chr_baum_init(const CharDriver *driver, + const char *id, + ChardevBackend *backend, + ChardevReturn *ret, + bool *be_opened, + Error **errp) { ChardevCommon *common = backend->u.braille.data; - BaumDriverState *baum; - CharDriverState *chr; + BaumChardev *baum; + Chardev *chr; brlapi_handle_t *handle; chr = qemu_chr_alloc(driver, common, errp); if (!chr) { return NULL; } - baum = (BaumDriverState *)chr; + baum = (BaumChardev *)chr; handle = g_malloc0(brlapi_getHandleSize()); baum->brlapi = handle; @@ -666,7 +668,7 @@ fail_handle: static void register_types(void) { static const CharDriver driver = { - .instance_size = sizeof(BaumDriverState), + .instance_size = sizeof(BaumChardev), .kind = CHARDEV_BACKEND_KIND_BRAILLE, .create = chr_baum_init, .chr_write = baum_write, -- cgit v1.2.3