Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp594984imm; Wed, 6 Jun 2018 02:51:10 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJo6KG+VCc7KyG1r9BIo0T9XDoc1myYBTwBEVCiML3NU37jq8cZVycb8sQI83cCrRq/X9dZ X-Received: by 2002:a17:902:a717:: with SMTP id w23-v6mr2518932plq.130.1528278670118; Wed, 06 Jun 2018 02:51:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528278670; cv=none; d=google.com; s=arc-20160816; b=v0ScszvLu/pMqIHaStu/P8/ec+xaXBJtDN0TFqecdbMdBX6zOaZYYjLhM8Wpq65K9P dQfmIUDyT41VkcaCh2hLJrcV1OI4O425jyV9UrKT1Dd09HtLfjM9t7TUn7t5Vlw8D008 9deOfy6w2wJ9IZrNKYP5OOthnwlzJT8SZ1mOL9LDDh2ymjnP5Pymg2xG1TRFdRucRFHZ kLpIm4prPju5acDo2zbW/KiTTvfws+PdXX+T9c6a6C8YjTEEh2WteD76ez9AevsHMsFo kmh3lMqQK3j3wtY7/cUVMU/T1W3HGi070OJtM89UPTqvqorzCrnxuVfKFlSZ7VCtLpzg fYjg== 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=uQtDEXVUuaSabr6UuFtFV3bn39MNirbHlrgp1OVmiDA=; b=b3l9kpXc8h96QwsBaa0s+Z8u+rg89qm1ZCy2lDlfKwMNxvGa0vUFjY1gBo8MNGceBc Bn2DmhAWxPEMtzYekpffZioIHts/8q3o+v4jyDdfHbCF7dYIqakrSTRooOnWapLWAzEl TsF62MECaWxtq4uJ2iRrRWlyJAXVzy3gHRsbCa/5d5VMwebAgJfz8SpLodzf0MI4bF6B 0jro6/11A9UEdDjFoREAGFunfiU0iR+GyyNTkH8AFxSjjhsTADFcOW+QOupT2qn7tsSG Z3WySr5BHm4l3mWukO3cVjMlxQqh9jHxsRD4OFsSlEosoCV4bi62yP8r3XsOsKTnOISV IEQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@micronovasrl.com header.s=dkim header.b=RwZg/WS0; 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 c7-v6si17412323pfg.77.2018.06.06.02.50.55; Wed, 06 Jun 2018 02:51:10 -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=RwZg/WS0; 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 S932525AbeFFJuL (ORCPT + 99 others); Wed, 6 Jun 2018 05:50:11 -0400 Received: from mail.micronovasrl.com ([212.103.203.10]:55582 "EHLO mail.micronovasrl.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932378AbeFFJuH (ORCPT ); Wed, 6 Jun 2018 05:50:07 -0400 Received: from mail.micronovasrl.com (mail.micronovasrl.com [127.0.0.1]) by mail.micronovasrl.com (Postfix) with ESMTP id 29307B00800 for ; Wed, 6 Jun 2018 11:50:06 +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=1528278605; x=1529142606; bh=ic y4aTKu/6u4MlrfWhDQRNZrhHlzrQ02srIr/LZdOv4=; b=RwZg/WS0tOG/IeWlXG zFThYWnqAVM9hbDJHaUlLaaYK8b/usAZMRQmv+JMyUb7QHJPHGbgBcxjSZvrNn7S +KEqanh7HPX4HN4RJO4df/ERFtu5y9LGeQkKV9BYGQhluKRi8Adi8J1XSwO+JGYX Ki8AXBnS0672HAtzS98pcTiMA= 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 Io2zHM9-JnQs for ; Wed, 6 Jun 2018 11:50:05 +0200 (CEST) Received: from localhost.localdomain (unknown [87.18.119.93]) by mail.micronovasrl.com (Postfix) with ESMTPSA id 0563EB002BC; Wed, 6 Jun 2018 11:50:03 +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 , Aaron Sierra , Tomas Melin , Sean Wang , Rafael Gago , Joel Stanley , linux-serial@vger.kernel.org (open list:SERIAL DRIVERS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 3/4] serial: 8250: Make em485_rts_after_send() set mctrl according to rts state. Date: Wed, 6 Jun 2018 11:49:38 +0200 Message-Id: <20180606094942.71190-2-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 When rs485 enabled and RTS_AFTER_SEND set on startup, need to preserve mctrl status, because later functions will call set_mctrl passing port->mctrl=0 overriding rts status, resulting in rts pin in transmission when idle. Make mctrl reflect rts pin state. Signed-off-by: Giulio Benetti --- drivers/tty/serial/8250/8250_port.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c index 95833cbc4338..c8c10b5ec6d6 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -562,10 +562,13 @@ static inline void serial8250_em485_rts_after_send(struct uart_8250_port *p) { unsigned char mcr = serial8250_in_MCR(p); - if (p->port.rs485.flags & SER_RS485_RTS_AFTER_SEND) + if (p->port.rs485.flags & SER_RS485_RTS_AFTER_SEND) { mcr |= UART_MCR_RTS; - else + p->port.mctrl |= TIOCM_RTS; + } else { mcr &= ~UART_MCR_RTS; + p->port.mctrl &= ~TIOCM_RTS; + } serial8250_out_MCR(p, mcr); } -- 2.17.1