Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4602505pxj; Wed, 12 May 2021 09:03:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZoQpe+YIdj9TntAJ0xE8CO2jCXO99jYViLoxRJMz/16DWjMEO6IH+lg4dtKTVbs1iaEU/ X-Received: by 2002:aa7:de9a:: with SMTP id j26mr21536192edv.269.1620835404332; Wed, 12 May 2021 09:03:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620835404; cv=none; d=google.com; s=arc-20160816; b=bTa1c14zegjObGCi3khlvkvtMzMh95inAcD14mwyaOT/cRsO/trFX/31T11hiBwEPB G3HxCecXFeX6qX+j7Goy/wYPByNQdulMLWcrz0jD+gw4VezQtGfPSAilg5lFhjxTOSG5 IvKz2WfvyMRn6yglHr7rNBkXKuONTXakZIVuXEwlR+1SYRruhp5lbBnp2YEPsnxMt6GX cP31TwjnVvywgSgFfMvur+RKV2xbbAqGI7YsxQpbV+FyKrsAtYi1Rhbpv+vLg91ujKrh Wln0HZxVoJSMmkSEO6DcJn1awLLPfYkE4iy7NmI0Hwu/fOS8mNU7I0IDN7Cx/hxgWtOr +exw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hESPNhYQ4RIfGHyc962l1mTwwY/kl8GJgnC5GqAgLhQ=; b=GbE5eMa9wVUr1aK7mjtVUU5hNGv88JijjlA/FvJpW+QU2Up/LDlMASaQjoT0Omqnqw 6Fqp0jp7wZoSRTTB7i3CoT9YON3RyONmnsCbe4tLvF/l1CRJesHz1QjdlijtaLfIJedx hikmeeZZqHW6e72wj5JumICcOg+SXOUN/mT1GMUVUfWWcxHNsDVnPK+zJkcUsaWNXKa6 p59n8k+a0oNVeig/zvOP9eXPSjXp5+OqLDCn3kAACjT2Q05eQXxbKb0zhTy8LTrBQG0k 1OgHVN8QCzFlGUJXuUdF+9q/dkHDljYGePWUGwCD9KtEYAIlNbaSpPfeseJbS/bS3IcT ma2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RrRKwmF6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w7si158193edd.50.2021.05.12.09.03.00; Wed, 12 May 2021 09:03:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RrRKwmF6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234884AbhELQDL (ORCPT + 99 others); Wed, 12 May 2021 12:03:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:44544 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235538AbhELP21 (ORCPT ); Wed, 12 May 2021 11:28:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D9D1161C1F; Wed, 12 May 2021 15:13:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832420; bh=Z7UpVIIgP+lykhV2bZrezUVTgmrS023NBScq3t5tHfg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RrRKwmF6mmB0oYJ8uJWe63s2xsDi+juMoirESf+r1Ag0BydN3YKRhZT5lH+f6KX8l OywzrrL+t646ebsstj/8RkFm0tiiADDkgLisIqdkg3ugJyp60u58GZiWMgIgo1Z1Xk Vp+Q3eDhealaVu9nKFvAtthD07h+i/EEM5WqPoNs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dario Binacchi , Sasha Levin Subject: [PATCH 5.10 273/530] serial: omap: dont disable rs485 if rts gpio is missing Date: Wed, 12 May 2021 16:46:23 +0200 Message-Id: <20210512144828.780568131@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dario Binacchi [ Upstream commit 45f6b6db53c80787b79044629b062dfcf2da71ec ] There are rs485 transceivers (e.g. MAX13487E/MAX13488E) which automatically disable or enable the driver and receiver to keep the bus in the correct state. In these cases we don't need a GPIO for flow control. Fixes: 4a0ac0f55b18 ("OMAP: add RS485 support") Signed-off-by: Dario Binacchi Link: https://lore.kernel.org/r/20210415210945.25863-1-dariobin@libero.it Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/serial/omap-serial.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c index 76b94d0ff586..1583e93b2202 100644 --- a/drivers/tty/serial/omap-serial.c +++ b/drivers/tty/serial/omap-serial.c @@ -302,7 +302,8 @@ static void serial_omap_stop_tx(struct uart_port *port) serial_out(up, UART_OMAP_SCR, up->scr); res = (port->rs485.flags & SER_RS485_RTS_AFTER_SEND) ? 1 : 0; - if (gpiod_get_value(up->rts_gpiod) != res) { + if (up->rts_gpiod && + gpiod_get_value(up->rts_gpiod) != res) { if (port->rs485.delay_rts_after_send > 0) mdelay( port->rs485.delay_rts_after_send); @@ -411,7 +412,7 @@ static void serial_omap_start_tx(struct uart_port *port) /* if rts not already enabled */ res = (port->rs485.flags & SER_RS485_RTS_ON_SEND) ? 1 : 0; - if (gpiod_get_value(up->rts_gpiod) != res) { + if (up->rts_gpiod && gpiod_get_value(up->rts_gpiod) != res) { gpiod_set_value(up->rts_gpiod, res); if (port->rs485.delay_rts_before_send > 0) mdelay(port->rs485.delay_rts_before_send); @@ -1407,18 +1408,13 @@ serial_omap_config_rs485(struct uart_port *port, struct serial_rs485 *rs485) /* store new config */ port->rs485 = *rs485; - /* - * Just as a precaution, only allow rs485 - * to be enabled if the gpio pin is valid - */ if (up->rts_gpiod) { /* enable / disable rts */ val = (port->rs485.flags & SER_RS485_ENABLED) ? SER_RS485_RTS_AFTER_SEND : SER_RS485_RTS_ON_SEND; val = (port->rs485.flags & val) ? 1 : 0; gpiod_set_value(up->rts_gpiod, val); - } else - port->rs485.flags &= ~SER_RS485_ENABLED; + } /* Enable interrupts */ up->ier = mode; -- 2.30.2