From patchwork Fri May 19 12:47:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Anton Nefedov X-Patchwork-Id: 9737157 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2BFB96034C for ; Fri, 19 May 2017 12:55:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F01C2892F for ; Fri, 19 May 2017 12:55:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0FFAF28933; Fri, 19 May 2017 12:55:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6E2082892F for ; Fri, 19 May 2017 12:55:21 +0000 (UTC) Received: from localhost ([::1]:58652 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBhRA-0005yQ-AC for patchwork-qemu-devel@patchwork.kernel.org; Fri, 19 May 2017 08:55:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46903) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBhK1-0000ds-QU for qemu-devel@nongnu.org; Fri, 19 May 2017 08:48:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dBhK0-0004LL-LA for qemu-devel@nongnu.org; Fri, 19 May 2017 08:47:57 -0400 Received: from mail-eopbgr00136.outbound.protection.outlook.com ([40.107.0.136]:31167 helo=EUR02-AM5-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 1dBhK0-0004AG-Dp for qemu-devel@nongnu.org; Fri, 19 May 2017 08:47:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=DrXMR7Sdipw4haMa2nMBJbNvyduAUzAb3KYUHLOmSwk=; b=Mrg0X/32a34JTftupBlOtjGlMArMJG00b2OXALqs7W87nVAJ0Y6+p+IGQpbI+4PP/JJub+kc8P/KSwCmGPExEHUJhP72/D0OEr3jUbQk4oUafqZJp5gzPtdRjfcItGxjZKiZ+muU9+i3Vxjed8h4iIrBFALjBknpcYspj48q3d4= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from xantnef-ws.sw.ru (195.214.232.6) by DB6PR0801MB1989.eurprd08.prod.outlook.com (10.168.85.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1101.14; Fri, 19 May 2017 12:47:53 +0000 From: Anton Nefedov To: Date: Fri, 19 May 2017 15:47:20 +0300 Message-ID: <1495198042-124203-8-git-send-email-anton.nefedov@virtuozzo.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1495198042-124203-1-git-send-email-anton.nefedov@virtuozzo.com> References: <1495198042-124203-1-git-send-email-anton.nefedov@virtuozzo.com> MIME-Version: 1.0 X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: DB6PR1001CA0002.EURPRD10.PROD.OUTLOOK.COM (10.171.79.12) To DB6PR0801MB1989.eurprd08.prod.outlook.com (10.168.85.150) X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB6PR0801MB1989: X-MS-Office365-Filtering-Correlation-Id: 5238bb09-7b7f-4bc8-f324-08d49eb54474 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131423075)(201703031133081); SRVR:DB6PR0801MB1989; X-Microsoft-Exchange-Diagnostics: 1; DB6PR0801MB1989; 3:do24fnXYwaa2Ko3COIaBx8Oq9PnQ0udalOcM4vcRYa+0aUY/qdBamWZUiquFK8aORtGXl76gjfixZMQ8cNhua9sWvYrzYB5PrJ7y/I5kAPzZanI9sfzRAxNfTQxHFBwBBJB1f9DF/OlMiuned6mRDxP/YDIjuOqQqSZw/kmGwOCknPraFMtM7IldnFh04GFcAFfKXITWNrMJxtG285Yf4MPz/3ntuvhtPhodH7o24YzPUcY8rIecjaa1mH2nKSz6pk22iodV3ZWsdosTibpSbefG+eVRT5n+bjJJWyusWoUpRvMjK9p0daoDB+DLgDXQYOlXESqxh2jw79IEydBsNg==; 25:HUsfj/klPkTTa9lm5Lpx14B+WIwtf9ejIxG3FkZRlyhxt3R9A2nZ+SBtS+A/jHduYICwZpaMrk2u6Xi6u3owkAuw97TWTlLAFBrcOLtAkldQtknwx7Hs3p4tx+4riDjiw9ZgKcbHeJdCyOC+80ycPKPiXwghCgieKihbrmLtHmdKRSKnyNJnCAUfCSdyYek1YZb/rx9lyNu700Dn7NwRjJz00HojhkT2aiMpb9sY07kRfxct04vesJK6ZwcR1ScTEE6PA31zV3GHcwQIkcDoQ/qTndXv+NOrf8EEwkYef9TM8NeIazBslcvSsdLnegllj++xTMv0sc3ngQut+VZQ0Tbavqi8kk8aZgQu3ulDhck0bVi9CusWRAeASJ3sp32KKoJgrxz/YkU6206N5wQGh3DS0733KSAx/c9iQTaFtSfRCRczDxCdUd1yinPug00rp3vjJ0aowQ//IJ5Suatx5T+Ua0wzkfc5Q2NMe0TWosg= X-Microsoft-Exchange-Diagnostics: 1; DB6PR0801MB1989; 31:ekmpWW4kHaSaZ7bT3noryU6hlRRlX88f94/9097YEBH/mHj2OS3PCi288TirrKDkUYzDTsG7vgKQGCaOS8KimBb7Uyy9qLRnBWC9hWCZAmHjSz/JjrZyNnXM8mIHfRiwm+m2WMiMABxwiOM3gTLRe5ho1ltDrpepbXuv6d1AEC9krp+QtwoUmgEZuIsnZhlufeovu6xKNXi+5NVgikUI7XclULPXMmGgPQ6A4CGf4C4=; 20:6OdiLNKcf/8K3VUmCOxII5uXLTu6McBLyaOsBEtgJh92SEtDlWvMY9JaLJmIFjnsF3aW9SyMziAEPwiyjMi8apBCSUx8NtaGpefR6c++poobAsnzkxjApTu2fttJRNFTeCltgGxJgxqMXnnHEpRRc3oKO6RN2dx1peGP79dqZZgPL51ajY0gz9TrVjMebFEJM+mdwvqVDmpZT1qKUDx++L8S0nX/rPsJ16/ZyQVa6LPseHpL5quw2g4b1jmAQ/C/YvbzCV9QK/b7NslI3LBCmTA+4JZgKhZx3ASd54Ob+Uhdlab5dsSR39FoSB3S9BfJ/6DYjTHJDKgwP+mtxodGiQoDgJ80YcnkgxQkHu4NrHvn2XD487Jm2ozT8UeQzpcoGavOfQGRzABh/EJjVBDD6OGE3UN29SHO34XBpGkFmWw= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(10201501046)(93006095)(93001095)(3002001)(6041248)(20161123560025)(20161123555025)(20161123558100)(20161123562025)(20161123564025)(201703131423075)(201703061421075)(6072148); SRVR:DB6PR0801MB1989; BCL:0; PCL:0; RULEID:; SRVR:DB6PR0801MB1989; X-Microsoft-Exchange-Diagnostics: 1; DB6PR0801MB1989; 4:e5lDhUWPExOwX1l9VsUG1r8/SOHvKeCb7nWwbWEKE1fVK4gnbO7jAxmSUOuI2QpY8jG0uG69xzeMIRz6vTuJIn4Wt7Tft+Ub7XHm6f5E+5TT2Xnk5HUxycTLtWIZY87zjP0ZwsxRywB4vART6VRH8gKIlhzRCQcAzC+/EgvmMvQQSBqKVi7NRDM2Q5wlsaZsTqvLg7Zns1S3xrc5ciaD2LN26KQ/tEKu3rT5TZ3STyDj2RI0ZyC6Z4hQGGmDi1iXK2my5O8svfzyXOhpfgYwJBzEnEZl/JZexCbpUngGMXMGCFuTBVm9OpTBpZH8Inzucp205BvY2+qRyLvyeHLZUujoPHwDlGrOGOh1FhpxqWMXpvVKQYPs0Ub0auPcT5yFyvNoqm+iBZ8Mx5ftPoOSUuMFz10kgYo2Z3xF9KElD//Y+3M1gvM9REYjRjITSNhjWlXjYIE2LCOIoKYShfJRo0duw4T52N+tBvOtpXf6T9QRscO1CId3u3HchI/dcoXls3VNDDVAPpSmnouduesziORWt1RWijNQFfSorT19CChYirqImHco53ufDRlydXHTZTK7qEM+cGqnZ2qJbm54Hl7sbjwmAZdy3asEa9bEfevx6wRlrc9NpRVvfEWGp2Jrbi2e5t4y+Dkw5daZcnEBCyXbCAuAEqAAra14gLeU2c73z6RCZCZgGeohtRFcZBuxN2gTeHG+l3yGaJmLotKcPw== X-Forefront-PRVS: 031257FE13 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(39400400002)(39450400003)(33646002)(48376002)(15650500001)(5003940100001)(53936002)(38730400002)(25786009)(2351001)(6506006)(6486002)(4326008)(110136004)(5660300001)(36756003)(7736002)(6916009)(2950100002)(305945005)(6666003)(66066001)(2906002)(189998001)(50226002)(50466002)(54906002)(508600001)(86362001)(6512007)(81166006)(8676002)(50986999)(53416004)(3846002)(76176999)(42186005); DIR:OUT; SFP:1102; SCL:1; SRVR:DB6PR0801MB1989; H:xantnef-ws.sw.ru; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DB6PR0801MB1989; 23:6xKwZ1fzfSAyOk/PlDGfNaXxk8u1Amft11V9+X5?= =?us-ascii?Q?qG3NNpa3Zf/C7xVZocYnJhSS3sm9a5VbxsYTLP+aceFNeHtP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iTtbm9JTyTKS/zgujqT/rGE6b/HjR0fTeTwyBkzRDL2?= =?us-ascii?Q?/Noo=3D?= X-Microsoft-Exchange-Diagnostics: 1; DB6PR0801MB1989; 6:lSmHb96hs8WXrZhPiFyfMMp4+avuEwGRQ28jAxuFiBRdpSEKFMIqKd/JuPBTmj9U+nWa18iMDPPaCbNNkj0MPo/gPV9r8bP5zddEKIlIzuFldJT9I0pW9pe1RNZYj6ZmwecqklEBXEyCJ2KMWJZTjcHpZCdMdrQv1NhuwwAYge8w2Hn3lmuYR1adFAc7mz1fRW5fLz83D+adH/NB13bwfgnJksDWAWdcABOsLh8FJQQFH3cQJep/rsc0rHe3GSnGstV6gJtTaAfY7imqLic5Ru3wgEgk779wlbJeuo/h9fn9tklVWK67m1httCz12aW++9cJyA5pIbsyOEh/HZ0cByL0pCF+lV8Ny9cb8WO08QhqWetQNgO7tbt9ad3bSNbj9YJ5MRPczdUwdaSOiFBOZLLLll+7gLyYcxF6vKK6ooCRzAqXbrqe8z/kqOy3cJKIsBB9x+ZtY2MzNUxfYsmmax6X8Z4yJ8gTl0AhviKTL53b7YW5CkBzYLamWsIILBGN8zikw3KDzm3R7DpF7IbHbg==; 5:D7IathfNpPL3nWcvw4vrX7P1kON08utNA1Xj66gD+aBaQvDxCGu/tJVpacFw/U8Ivs4dFemoEWJUPUY5aqE61cAKNLwYygoQdXPK7krpAOrs1VRDCVFxhf+mAv/YGwUmdihiE+xT5MEY2AhpUefbig==; 24:te/vnwUS9UKhg0LAMNgDBluaBapeyU432VYHRv9vE9LmAnX50om1ORLRBqQYYfsN7S+iOKOj5w7kf/NnJVXUi/44aj0FF/DafHrhR8uhkDM= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DB6PR0801MB1989; 7:OCbsZxjC6bswd+4sHHVyUHaGFiUg8kkQ8E9usbqbH+qb/Bvevwpn8A+cmz8/eNAkn9aVSLOGGH+Ee9YFLm60zzcEwEBoLH566J6c/kjYkUR7UjEGe0HvLfRTGHiCpxg9xj4IRzm9M9OxSyKm4bgEnYLvXq4WNUy+8F2LCM3CLu3nB+DyWm6NSXYJVSDmww6iorrTkX5tgoG+bS2Uuw3yaARLpUIZ3VjeA588H4g9gIbIcK0wi2lw1Xtuv5n5mkApQNRswcfFvzVk4khLRLdgB0JPsvsvhwbCaoE6Pi7Z5tE7TSBtt0NcoDkU8Wl3hHYLi38Ac/b2JkSuxn4hpXwFsQ==; 20:kLyjeuCZ3sQYUHYlGChwlzh2+DTDwAxOhjV2zOJwtav4DYoTntKP7eIjBeGA2H27NdrVboRTgO7y0OveaTSH1DncMRulBDL0o90iZYLORIctHuR+tQvxoGXqMvRj6DhKv4vC099USAnqfH93S+8gMbpTS2EIYiEnJom6ZIxye0o= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2017 12:47:53.5752 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB1989 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.0.136 Subject: [Qemu-devel] [PATCH v2 7/9] serial: move TIOCM update to a separate function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, Anton Nefedov , "Michael S . Tsirkin" , den@virtuozzo.com, marcandre.lureau@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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é 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 d8d34d0..1e6bdeb 100644 --- a/hw/char/serial.c +++ b/hw/char/serial.c @@ -312,6 +312,24 @@ static void serial_write_fcr(SerialState *s, uint8_t val) } } +static void serial_update_tiocm(SerialState *s) +{ + int flags; + + qemu_chr_fe_ioctl(&s->chr, CHR_IOCTL_SERIAL_GET_TIOCM, &flags); + + flags &= ~(CHR_TIOCM_RTS | CHR_TIOCM_DTR); + + if (s->mcr & UART_MCR_RTS) { + flags |= CHR_TIOCM_RTS; + } + if (s->mcr & UART_MCR_DTR) { + flags |= 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 = s->mcr; s->mcr = val & 0x1f; if (val & UART_MCR_LOOP) break; if (s->poll_msl >= 0 && old_mcr != s->mcr) { - - qemu_chr_fe_ioctl(&s->chr, CHR_IOCTL_SERIAL_GET_TIOCM, &flags); - - flags &= ~(CHR_TIOCM_RTS | CHR_TIOCM_DTR); - - if (val & UART_MCR_RTS) - flags |= CHR_TIOCM_RTS; - if (val & UART_MCR_DTR) - flags |= CHR_TIOCM_DTR; - - qemu_chr_fe_ioctl(&s->chr, CHR_IOCTL_SERIAL_SET_TIOCM, &flags); + 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_CLOCK_VIRTUAL) + s->char_transmit_time);