Received: from eggs.gnu.org ([2001:4830:134:3::10]:55796) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dPXAi-0003CI-7d for qemu-devel@nongnu.org; Mon, 26 Jun 2017 12:47:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dPXAe-0003Dg-WC for qemu-devel@nongnu.org; Mon, 26 Jun 2017 12:47:32 -0400 Received: from mail-eopbgr50101.outbound.protection.outlook.com ([40.107.5.101]:27580 helo=EUR03-VE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dPXAe-0003D5-H0 for qemu-devel@nongnu.org; Mon, 26 Jun 2017 12:47:28 -0400 From: Anton Nefedov Date: Mon, 26 Jun 2017 19:45:49 +0300 Message-ID: <1498495550-72357-13-git-send-email-anton.nefedov@virtuozzo.com> In-Reply-To: <1498495550-72357-1-git-send-email-anton.nefedov@virtuozzo.com> References: <1498495550-72357-1-git-send-email-anton.nefedov@virtuozzo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH v4 12/13] serial: move TIOCM update to a separate function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: den@virtuozzo.com, pbonzini@redhat.com, marcandre.lureau@redhat.com, Anton Nefedov , "Michael S . Tsirkin" will be used by the following patch Signed-off-by: Anton Nefedov Reviewed-by: Vladimir Sementsov-Ogievskiy CC: Michael S. Tsirkin CC: Paolo Bonzini Reviewed-by: Marc-Andr=C3=A9 Lureau --- hw/char/serial.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/hw/char/serial.c b/hw/char/serial.c index ab14ca4..e47f0b6 100644 --- a/hw/char/serial.c +++ b/hw/char/serial.c @@ -312,6 +312,24 @@ static void serial_write_fcr(SerialState *s, uint8_t v= al) } } =20 +static void serial_update_tiocm(SerialState *s) +{ + int flags; + + qemu_chr_fe_ioctl(&s->chr, CHR_IOCTL_SERIAL_GET_TIOCM, &flags); + + flags &=3D ~(CHR_TIOCM_RTS | CHR_TIOCM_DTR); + + if (s->mcr & UART_MCR_RTS) { + flags |=3D CHR_TIOCM_RTS; + } + if (s->mcr & UART_MCR_DTR) { + flags |=3D CHR_TIOCM_DTR; + } + + qemu_chr_fe_ioctl(&s->chr, CHR_IOCTL_SERIAL_SET_TIOCM, &flags); +} + static void serial_ioport_write(void *opaque, hwaddr addr, uint64_t val, unsigned size) { @@ -426,24 +444,13 @@ static void serial_ioport_write(void *opaque, hwaddr = addr, uint64_t val, break; case 4: { - int flags; int old_mcr =3D s->mcr; s->mcr =3D val & 0x1f; if (val & UART_MCR_LOOP) break; =20 if (s->poll_msl >=3D 0 && old_mcr !=3D s->mcr) { - - qemu_chr_fe_ioctl(&s->chr, CHR_IOCTL_SERIAL_GET_TIOCM, &fl= ags); - - flags &=3D ~(CHR_TIOCM_RTS | CHR_TIOCM_DTR); - - if (val & UART_MCR_RTS) - flags |=3D CHR_TIOCM_RTS; - if (val & UART_MCR_DTR) - flags |=3D CHR_TIOCM_DTR; - - qemu_chr_fe_ioctl(&s->chr, CHR_IOCTL_SERIAL_SET_TIOCM, &fl= ags); + serial_update_tiocm(s); /* Update the modem status after a one-character-send wait= -time, since there may be a response from the device/computer at the other end of the serial= line */ timer_mod(s->modem_status_poll, qemu_clock_get_ns(QEMU_CLO= CK_VIRTUAL) + s->char_transmit_time); --=20 2.7.4