Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp596123imm; Wed, 6 Jun 2018 02:52:34 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIHsJotRIT0pvcHCTgDus0ofJmzSib7QNxvcbEJpCkltouXTgoj7E3K6SMKB5dJ3ycz9QRl X-Received: by 2002:a17:902:380c:: with SMTP id l12-v6mr2545687plc.19.1528278754368; Wed, 06 Jun 2018 02:52:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528278754; cv=none; d=google.com; s=arc-20160816; b=zOqhSucpIitVf60IY5O3BZS5nIwTxE55UGZEncJMxwuqzYzR0us0ZmZI2LSDCf9ifO da+rG4SzlBgHUtMWSDjeTXJgMpuwvBu+G7dttfKKFB0M5LgLecpcpQyu8XudIfgChZxw adrHbvtwqqqtB9/oNZoAaM/BgqK0WmazK6m8KDCfxG5OTTpNUlGzTTtpDIHLmHjusfnu JqhYUxeooZ8tKeNQqzMm7E+8JznvBIxnXDI/tfU1+ADC+ESWLEYOIDt6KTDRf9LPeO1w n0murvW8Xu88HTkiwlTfnDnHkH2HOVQI13R2YldtU6nYwAxs19ppfKoATMlK4sBZo25B PyNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:in-reply-to:message-id:date :subject:cc:from:dkim-signature:arc-authentication-results; bh=0PFenjxU6GsyM2/mYA6R+qm2ME3d7Mnj/ebzzNWiRNs=; b=iC51l9I/ZNlOKPgHcfpwthbmEgfr0muw2ZkHvRkXvq9VFBXC3JGpj87ZsuuRebcCU3 R1Bm1KabJC/MXuPfJ0EEkgBL97cTvj+QoYQ6910jxU/CHNHnXsHGUXATQj9XODOGphb5 l85cxyDF+XQ6zT3IYJXHMaEle6EzUx6OaW3sKPtFB3VPReU1R3UMBMhPywIDLyTrQFIx U2i2szpSH68uPG9OLkfK+ebsJExX8Q8pK1wE/W0e6QqnJ9otLUxHUHxtlqxxP5DGYyoC sgradOdWJ1JvA6Bssh7lQlJBXiucDkDz0aLJ6i1/nYCbOJlEeZQdQtuI1TnZj4xL2Ky6 D2QA== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@micronovasrl.com header.s=dkim header.b=lS8sIbFu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k82-v6si19143166pfa.53.2018.06.06.02.52.20; Wed, 06 Jun 2018 02:52:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=temperror (no key for signature) header.i=@micronovasrl.com header.s=dkim header.b=lS8sIbFu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752338AbeFFJuc (ORCPT + 99 others); Wed, 6 Jun 2018 05:50:32 -0400 Received: from mail.micronovasrl.com ([212.103.203.10]:55658 "EHLO mail.micronovasrl.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932441AbeFFJuK (ORCPT ); Wed, 6 Jun 2018 05:50:10 -0400 Received: from mail.micronovasrl.com (mail.micronovasrl.com [127.0.0.1]) by mail.micronovasrl.com (Postfix) with ESMTP id 66938B00816 for ; Wed, 6 Jun 2018 11:50:09 +0200 (CEST) Authentication-Results: mail.micronovasrl.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=micronovasrl.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=micronovasrl.com; h=references:in-reply-to:x-mailer:message-id:date:date:subject :subject:to:from:from; s=dkim; t=1528278608; x=1529142609; bh=CU KmWG/BNtJ6Fuqit0aZQ8QzHD1R+WJ0SpTz3R+yxQg=; b=lS8sIbFumejwBnRGUe QbqZuHjQkDFCBp4Y4Vdu3WenQZegJDN1xaD50N8BCAzUeXx4+PjSINBDyVRV9184 6h9Px4fEsSiIFVqB5Z3AH1Ng4mtiRoK/QJ81pGPJAl/5RgdPsvqcYdMi+Y2zn212 YZK4Xfm4A9uEK5lW8qLx6zc54= X-Virus-Scanned: Debian amavisd-new at mail.micronovasrl.com X-Spam-Flag: NO X-Spam-Score: -2.9 X-Spam-Level: X-Spam-Status: No, score=-2.9 tagged_above=-10 required=4.5 tests=[ALL_TRUSTED=-1, BAYES_00=-1.9] autolearn=unavailable autolearn_force=no Received: from mail.micronovasrl.com ([127.0.0.1]) by mail.micronovasrl.com (mail.micronovasrl.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id ttU3MilOx6iY for ; Wed, 6 Jun 2018 11:50:08 +0200 (CEST) Received: from localhost.localdomain (unknown [87.18.119.93]) by mail.micronovasrl.com (Postfix) with ESMTPSA id 55EABB00777; Wed, 6 Jun 2018 11:50:07 +0200 (CEST) From: Giulio Benetti Cc: matwey.kornilov@gmail.com, Giulio Benetti , Greg Kroah-Hartman , Jiri Slaby , Andy Shevchenko , Matthias Brugger , Kees Cook , Sean Young , linux-serial@vger.kernel.org (open list:SERIAL DRIVERS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 4/4] serial: core: Mask mctrl with TIOCM_RTS too if rs485 on and RTS_AFTER_SEND set. Date: Wed, 6 Jun 2018 11:49:39 +0200 Message-Id: <20180606094942.71190-3-giulio.benetti@micronovasrl.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180606094942.71190-1-giulio.benetti@micronovasrl.com> References: <20180606094942.71190-1-giulio.benetti@micronovasrl.com> To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If rs485 is enabled and RTS_AFTER_SEND is set on startup need to keep TIOCM_RTS asserted to keep rs485 transceiver in RX when idle. Check if rs485 is on and RTS_AFTER_SEND is set and mask port->mctrl with TIOCM_RTS too and not only TIOCM_DTR. Signed-off-by: Giulio Benetti --- drivers/tty/serial/serial_core.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 0466f9f08a91..06d9441f6d20 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -2288,6 +2288,16 @@ uart_configure_port(struct uart_driver *drv, struct uart_state *state, if (port->type != PORT_UNKNOWN) { unsigned long flags; + int rs485_on = port->rs485_config && + (port->rs485.flags & SER_RS485_ENABLED); + int RTS_after_send = !!(port->rs485.flags & + SER_RS485_RTS_AFTER_SEND); + int mctrl; + + if (rs485_on && RTS_after_send) + mctrl = port->mctrl & (TIOCM_DTR | TIOCM_RTS); + else + mctrl = port->mctrl & TIOCM_DTR; uart_report_port(drv, port); @@ -2300,7 +2310,7 @@ uart_configure_port(struct uart_driver *drv, struct uart_state *state, * We probably don't need a spinlock around this, but */ spin_lock_irqsave(&port->lock, flags); - port->ops->set_mctrl(port, port->mctrl & TIOCM_DTR); + port->ops->set_mctrl(port, mctrl); spin_unlock_irqrestore(&port->lock, flags); /* -- 2.17.1