From patchwork Mon Aug 1 14:23:00 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 107757 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8D57CB708F for ; Tue, 2 Aug 2011 00:24:02 +1000 (EST) Received: from localhost ([::1]:44348 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QntPN-0001mJ-8g for incoming@patchwork.ozlabs.org; Mon, 01 Aug 2011 10:23:53 -0400 Received: from eggs.gnu.org ([140.186.70.92]:40440) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QntOp-0000WM-G0 for qemu-devel@nongnu.org; Mon, 01 Aug 2011 10:23:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QntOn-0004zv-Vq for qemu-devel@nongnu.org; Mon, 01 Aug 2011 10:23:19 -0400 Received: from e3.ny.us.ibm.com ([32.97.182.143]:56484) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QntOn-0004zd-Kz for qemu-devel@nongnu.org; Mon, 01 Aug 2011 10:23:17 -0400 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by e3.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id p71DxSaW008689 for ; Mon, 1 Aug 2011 09:59:28 -0400 Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p71ENG6p134736 for ; Mon, 1 Aug 2011 10:23:17 -0400 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p71AN3cl016985 for ; Mon, 1 Aug 2011 07:23:03 -0300 Received: from titi.austin.rr.com (sig-9-76-195-114.mts.ibm.com [9.76.195.114]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p71AN0qB016760; Mon, 1 Aug 2011 07:23:03 -0300 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Mon, 1 Aug 2011 09:23:00 -0500 Message-Id: <1312208590-25502-3-git-send-email-aliguori@us.ibm.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1312208590-25502-1-git-send-email-aliguori@us.ibm.com> References: <1312208590-25502-1-git-send-email-aliguori@us.ibm.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 32.97.182.143 Cc: Amit Shah , Hans de Goede , Anthony Liguori Subject: [Qemu-devel] [PATCH 02/12] char: rename qemu_chr_[can_]read() to qemu_chr_be_[can_]write(). X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org To be clear about who calls this function and for what purpose. Signed-off-by: Anthony Liguori --- console.c | 4 ++-- gdbstub.c | 2 +- hw/baum.c | 12 ++++++------ hw/msmouse.c | 2 +- qemu-char.c | 38 +++++++++++++++++++------------------- qemu-char.h | 4 ++-- spice-qemu-char.c | 4 ++-- 7 files changed, 33 insertions(+), 33 deletions(-) diff --git a/console.c b/console.c index 242086c..489c74c 100644 --- a/console.c +++ b/console.c @@ -1123,14 +1123,14 @@ static void kbd_send_chars(void *opaque) int len; uint8_t buf[16]; - len = qemu_chr_can_read(s->chr); + len = qemu_chr_be_can_write(s->chr); if (len > s->out_fifo.count) len = s->out_fifo.count; if (len > 0) { if (len > sizeof(buf)) len = sizeof(buf); qemu_fifo_read(&s->out_fifo, buf, len); - qemu_chr_read(s->chr, buf, len); + qemu_chr_be_write(s->chr, buf, len); } /* characters are pending: we send them a bit later (XXX: horrible, should change char device API) */ diff --git a/gdbstub.c b/gdbstub.c index d6c362e..058c626 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -2194,7 +2194,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) hextomem(mem_buf, p + 5, len); len = len / 2; mem_buf[len++] = 0; - qemu_chr_read(s->mon_chr, mem_buf, len); + qemu_chr_be_write(s->mon_chr, mem_buf, len); put_packet(s, "OK"); break; } diff --git a/hw/baum.c b/hw/baum.c index 33a22a7..244eee5 100644 --- a/hw/baum.c +++ b/hw/baum.c @@ -223,7 +223,7 @@ static void baum_accept_input(struct CharDriverState *chr) if (!baum->out_buf_used) return; - room = qemu_chr_can_read(chr); + room = qemu_chr_be_can_write(chr); if (!room) return; if (room > baum->out_buf_used) @@ -231,12 +231,12 @@ static void baum_accept_input(struct CharDriverState *chr) first = BUF_SIZE - baum->out_buf_ptr; if (room > first) { - qemu_chr_read(chr, baum->out_buf + baum->out_buf_ptr, first); + qemu_chr_be_write(chr, baum->out_buf + baum->out_buf_ptr, first); baum->out_buf_ptr = 0; baum->out_buf_used -= first; room -= first; } - qemu_chr_read(chr, baum->out_buf + baum->out_buf_ptr, room); + qemu_chr_be_write(chr, baum->out_buf + baum->out_buf_ptr, room); baum->out_buf_ptr += room; baum->out_buf_used -= room; } @@ -250,16 +250,16 @@ static void baum_write_packet(BaumDriverState *baum, const uint8_t *buf, int len while (len--) if ((*cur++ = *buf++) == ESC) *cur++ = ESC; - room = qemu_chr_can_read(baum->chr); + room = qemu_chr_be_can_write(baum->chr); len = cur - io_buf; if (len <= room) { /* Fits */ - qemu_chr_read(baum->chr, io_buf, len); + qemu_chr_be_write(baum->chr, io_buf, len); } else { int first; uint8_t out; /* Can't fit all, send what can be, and store the rest. */ - qemu_chr_read(baum->chr, io_buf, room); + qemu_chr_be_write(baum->chr, io_buf, room); len -= room; cur = io_buf + room; if (len > BUF_SIZE - baum->out_buf_used) { diff --git a/hw/msmouse.c b/hw/msmouse.c index 67c6cd4..fbed80b 100644 --- a/hw/msmouse.c +++ b/hw/msmouse.c @@ -50,7 +50,7 @@ static void msmouse_event(void *opaque, /* We always send the packet of, so that we do not have to keep track of previous state of the middle button. This can potentially confuse some very old drivers for two button mice though. */ - qemu_chr_read(chr, bytes, 4); + qemu_chr_be_write(chr, bytes, 4); } static int msmouse_chr_write (struct CharDriverState *s, const uint8_t *buf, int len) diff --git a/qemu-char.c b/qemu-char.c index fe5b28e..795a3cc 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -151,14 +151,14 @@ int qemu_chr_ioctl(CharDriverState *s, int cmd, void *arg) return s->chr_ioctl(s, cmd, arg); } -int qemu_chr_can_read(CharDriverState *s) +int qemu_chr_be_can_write(CharDriverState *s) { if (!s->chr_can_read) return 0; return s->chr_can_read(s->handler_opaque); } -void qemu_chr_read(CharDriverState *s, uint8_t *buf, int len) +void qemu_chr_be_write(CharDriverState *s, uint8_t *buf, int len) { s->chr_read(s->handler_opaque, buf, len); } @@ -565,7 +565,7 @@ static int fd_chr_read_poll(void *opaque) CharDriverState *chr = opaque; FDCharDriver *s = chr->opaque; - s->max_size = qemu_chr_can_read(chr); + s->max_size = qemu_chr_be_can_write(chr); return s->max_size; } @@ -589,7 +589,7 @@ static void fd_chr_read(void *opaque) return; } if (size > 0) { - qemu_chr_read(chr, buf, size); + qemu_chr_be_write(chr, buf, size); } } @@ -699,8 +699,8 @@ static int stdio_read_poll(void *opaque) CharDriverState *chr = opaque; /* try to flush the queue if needed */ - if (term_fifo_size != 0 && qemu_chr_can_read(chr) > 0) { - qemu_chr_read(chr, term_fifo, 1); + if (term_fifo_size != 0 && qemu_chr_be_can_write(chr) > 0) { + qemu_chr_be_write(chr, term_fifo, 1); term_fifo_size = 0; } /* see if we can absorb more chars */ @@ -724,8 +724,8 @@ static void stdio_read(void *opaque) return; } if (size > 0) { - if (qemu_chr_can_read(chr) > 0) { - qemu_chr_read(chr, buf, 1); + if (qemu_chr_be_can_write(chr) > 0) { + qemu_chr_be_write(chr, buf, 1); } else if (term_fifo_size == 0) { term_fifo[term_fifo_size++] = buf[0]; } @@ -890,7 +890,7 @@ static int pty_chr_read_poll(void *opaque) CharDriverState *chr = opaque; PtyCharDriver *s = chr->opaque; - s->read_bytes = qemu_chr_can_read(chr); + s->read_bytes = qemu_chr_be_can_write(chr); return s->read_bytes; } @@ -914,7 +914,7 @@ static void pty_chr_read(void *opaque) } if (size > 0) { pty_chr_state(chr, 1); - qemu_chr_read(chr, buf, size); + qemu_chr_be_write(chr, buf, size); } } @@ -1602,7 +1602,7 @@ static int win_chr_read_poll(CharDriverState *chr) { WinCharState *s = chr->opaque; - s->max_size = qemu_chr_can_read(chr); + s->max_size = qemu_chr_be_can_write(chr); return s->max_size; } @@ -1624,7 +1624,7 @@ static void win_chr_readfile(CharDriverState *chr) } if (size > 0) { - qemu_chr_read(chr, buf, size); + qemu_chr_be_write(chr, buf, size); } } @@ -1840,15 +1840,15 @@ static int udp_chr_read_poll(void *opaque) CharDriverState *chr = opaque; NetCharDriver *s = chr->opaque; - s->max_size = qemu_chr_can_read(chr); + s->max_size = qemu_chr_be_can_write(chr); /* If there were any stray characters in the queue process them * first */ while (s->max_size > 0 && s->bufptr < s->bufcnt) { - qemu_chr_read(chr, &s->buf[s->bufptr], 1); + qemu_chr_be_write(chr, &s->buf[s->bufptr], 1); s->bufptr++; - s->max_size = qemu_chr_can_read(chr); + s->max_size = qemu_chr_be_can_write(chr); } return s->max_size; } @@ -1867,9 +1867,9 @@ static void udp_chr_read(void *opaque) s->bufptr = 0; while (s->max_size > 0 && s->bufptr < s->bufcnt) { - qemu_chr_read(chr, &s->buf[s->bufptr], 1); + qemu_chr_be_write(chr, &s->buf[s->bufptr], 1); s->bufptr++; - s->max_size = qemu_chr_can_read(chr); + s->max_size = qemu_chr_be_can_write(chr); } } @@ -1963,7 +1963,7 @@ static int tcp_chr_read_poll(void *opaque) TCPCharDriver *s = chr->opaque; if (!s->connected) return 0; - s->max_size = qemu_chr_can_read(chr); + s->max_size = qemu_chr_be_can_write(chr); return s->max_size; } @@ -2109,7 +2109,7 @@ static void tcp_chr_read(void *opaque) if (s->do_telnetopt) tcp_chr_process_IAC_bytes(chr, s, buf, &size); if (size > 0) - qemu_chr_read(chr, buf, size); + qemu_chr_be_write(chr, buf, size); } } diff --git a/qemu-char.h b/qemu-char.h index 90f0c41..bcd413c 100644 --- a/qemu-char.h +++ b/qemu-char.h @@ -97,8 +97,8 @@ void qemu_chr_add_handlers(CharDriverState *s, void *opaque); int qemu_chr_ioctl(CharDriverState *s, int cmd, void *arg); void qemu_chr_generic_open(CharDriverState *s); -int qemu_chr_can_read(CharDriverState *s); -void qemu_chr_read(CharDriverState *s, uint8_t *buf, int len); +int qemu_chr_be_can_write(CharDriverState *s); +void qemu_chr_be_write(CharDriverState *s, uint8_t *buf, int len); int qemu_chr_get_msgfd(CharDriverState *s); void qemu_chr_accept_input(CharDriverState *s); int qemu_chr_add_client(CharDriverState *s, int fd); diff --git a/spice-qemu-char.c b/spice-qemu-char.c index 95bf6b6..3d06ac4 100644 --- a/spice-qemu-char.c +++ b/spice-qemu-char.c @@ -36,10 +36,10 @@ static int vmc_write(SpiceCharDeviceInstance *sin, const uint8_t *buf, int len) while (len > 0) { last_out = MIN(len, VMC_MAX_HOST_WRITE); - if (qemu_chr_can_read(scd->chr) < last_out) { + if (qemu_chr_be_can_write(scd->chr) < last_out) { break; } - qemu_chr_read(scd->chr, p, last_out); + qemu_chr_be_write(scd->chr, p, last_out); out += last_out; len -= last_out; p += last_out;