Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp545686imm; Fri, 1 Jun 2018 05:42:05 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKHMInwFs3A2fs3yFiBA2rHdMYj6KC6xNIiFBJy/Eb6kdL0ZDcvTXcTp5H8lMoVF7PY1owb X-Received: by 2002:a17:902:d706:: with SMTP id w6-v6mr11108000ply.142.1527856925436; Fri, 01 Jun 2018 05:42:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527856925; cv=none; d=google.com; s=arc-20160816; b=SfMFKfX6kAe8NxLTJP7kXret4sP6x5DsTm50QmH4X53JYRq2oWfTeaoRGihMnrJwbM 5v+CMT7OkOurGGAP/6UlGHQkEm0mPf6xyl022I9S98xdascWLL60a4UhVtxK9hK4Gz5s QMnvElLVJ11aci9aPxwFzuFDkY3aZsGEruZzmAuTFLz3HHTbf7Oz0MphAAjBSBh88uLe 8CiMo+5Id+SfF/9R2PrImjQzq6tuddlA5kKucOWaI8YcOBBU1lfTQpcvAyekPP7ndjAZ G4gGbcI87Kl0QWe+Fuig+HLJjfKlsa7uXRFIJgjhLw8cw2Q7gBZI5srBx7u3UVuD13We Rb4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=SvjWoC159KRwskkTE5QamV9wCOA8YpQ842IMsl8Z7Jg=; b=iA7l0l1A9AF1t6AYBVynFA3aK281IAMhFy+zxAp1Dujlg6bzNvdn67xljXtndnRNIs /oq9q7yIdQSmOp3ZTg2VxrMSbb3AhY294h32zhcQ+Nxf7B+pP9QI1WqgR4bfyq3bSRby nxyKniE41yIvNHJjaguXwJz5bDqkcZPW4TrjCziu+SbcgD/alcGrxJMZK4+IZjodtouv QYoKvkCe3Cb2Ze9iu2Ubto29swt68mDON1kSSS9NJu54yIEBHsTDuSuW+vRVoN7TepGV XWcb65UaJ2E82wU9h/X/NR0ZtkgjoW4cAJojO1yGdIWVjxu7EqNgs1NHRuwB8dFt8mU0 glqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@micronovasrl.com header.s=dkim header.b=BbZ10lhG; 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 q2-v6si39540294plh.136.2018.06.01.05.41.51; Fri, 01 Jun 2018 05:42:05 -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=BbZ10lhG; 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 S1752467AbeFAMlA (ORCPT + 99 others); Fri, 1 Jun 2018 08:41:00 -0400 Received: from mail.micronovasrl.com ([212.103.203.10]:39496 "EHLO mail.micronovasrl.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752276AbeFAMky (ORCPT ); Fri, 1 Jun 2018 08:40:54 -0400 Received: from mail.micronovasrl.com (mail.micronovasrl.com [127.0.0.1]) by mail.micronovasrl.com (Postfix) with ESMTP id 3EC22B0094A for ; Fri, 1 Jun 2018 14:40:53 +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=1527856852; x=1528720853; bh=7T twpQ66UFAXpETrKAVUJTbpOD5zkX5ZdtLP5H0WoB4=; b=BbZ10lhGC418VBDtmM 9L/b8zalC7zitdgUdiz9yCX4JTb89jW4bQufYNxz7m0sYOT/73ZsM7XIbUHiSu6w vXXYGWvSw/kwbF7KUw1gWKswFcehtkjc0utwBmJKTv5nOfROSB0sXCUlq6KNB2No LjP5IcltPh12ip/5xofAT8a1I= 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 2ccfYiNdD73n for ; Fri, 1 Jun 2018 14:40:52 +0200 (CEST) Received: from localhost.localdomain (unknown [87.18.119.93]) by mail.micronovasrl.com (Postfix) with ESMTPSA id 2359AB00725; Fri, 1 Jun 2018 14:40:39 +0200 (CEST) From: Giulio Benetti To: Greg Kroah-Hartman Cc: Jiri Slaby , Andy Shevchenko , Kees Cook , Matthias Brugger , Allen Pais , Sean Young , Ed Blake , Stefan Potyra , Philipp Zabel , Joshua Scott , Vignesh R , Rolf Evers-Fischer , Aaron Sierra , Rafael Gago , Joel Stanley , Sean Wang , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Giulio Benetti Subject: [PATCH 8/8] serial: core: Mask mctrl with TIOCM_RTS too if rs485 on and RTS_AFTER_SEND set. Date: Fri, 1 Jun 2018 14:40:21 +0200 Message-Id: <20180601124021.102970-9-giulio.benetti@micronovasrl.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601124021.102970-1-giulio.benetti@micronovasrl.com> References: <20180601124021.102970-1-giulio.benetti@micronovasrl.com> 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.0