Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1027470yba; Thu, 4 Apr 2019 02:45:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqxy8ji2JoT/WDUnFJ/Sok+HzF18affjYrQcHu2G6b8n5nITEusdYSR40t49dwASe1X843sG X-Received: by 2002:a63:fb16:: with SMTP id o22mr4531527pgh.209.1554371125398; Thu, 04 Apr 2019 02:45:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554371125; cv=none; d=google.com; s=arc-20160816; b=VA0ceFlIOeanutSTBFK2pAPaZjyxH+ZANaNCZN4OpOmB/W21XRN3Y4dl1yuftgYKHi 4khA6ZE4yrvS10wDImuMbfllGVmLN7Nxhd5ok17hCJ+COnhthUUAvOX7ug2zGJwa/nfh R9j1KnMFH0q4dkvgwoU4CUdMPWMTQTsBYbRfj1atKkl9jDcguaCrA4lwmTM4u+ruMmqD mMvgl7D+foy1ey4jGlRR2znGx6zYmn/ayjoSwsVVAhebdQoXr9whUuPwlPSG6eD27rCi rMnzmrHkOs79mQhy8NKq+ssZvgcwbDEUJQTLswvnR58ZMowZETAjH4OvsDLKEqRV1fZM p+4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=24+FyfClv0x4/h5a4CfoBSAYavvum+5IE4QV1uEdc50=; b=LgpELQUETY9/7/U+GBadwm+DVWn9CwiAs2YgPt5M7KEHuYURiWaXRB2J05ycq+rrfB z3IG+DRUWuOmbuiAaiB507y5OsklpFBCWt4lubEj6ikkZd8plCuuXy0e/erGBuXosnQz 8FJXoSXj4mahrgFEW7HGw5wrFrFjweWXvOVjBeC6ngUe04plcqe/DaXjp4MygHa37APg GsO9aX6BnmWi3XQB7rHkemG/y35tADyh+TFHq/y5Of67A9WE1uFlf3S1lWdTxo2pXe6Q E58QKq9XwRoyvrDR6emB2x6LDuG06WsQkBMdz2VXlu9Rxk1n5uFZZfk+gUTabHoskg/p 8Yaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rLaym5OK; 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 74si14810757pgb.203.2019.04.04.02.45.10; Thu, 04 Apr 2019 02:45:25 -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=pass header.i=@kernel.org header.s=default header.b=rLaym5OK; 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 S1730543AbfDDI7m (ORCPT + 99 others); Thu, 4 Apr 2019 04:59:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:36092 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731108AbfDDI7k (ORCPT ); Thu, 4 Apr 2019 04:59:40 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 749D920652; Thu, 4 Apr 2019 08:59:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554368380; bh=jSfbDRBJTcVDcYUM5/94gF+Vsl1cRMW8o6nevomE220=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rLaym5OK2v0hQtFJZOxzoZt/+Rd7apthueyBVxgVEiCZ7VfDCP/l6l1+rk1zbB9Qs T+JIK6/E55GaL3A3g6PKsqixK+LmlThA1ynI04ylN6UCLimRjNIeBTgu0bE0vH5Ate KcMvtBbd+cNBKfIItBHys+FOtEV4hmLPofgi3Ce0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Razvan Stefanescu , Richard Genoud Subject: [PATCH 4.19 003/187] tty/serial: atmel: Add is_half_duplex helper Date: Thu, 4 Apr 2019 10:45:40 +0200 Message-Id: <20190404084603.265124773@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084603.119654039@linuxfoundation.org> References: <20190404084603.119654039@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Razvan Stefanescu commit f3040983132bf3477acd45d2452a906e67c2fec9 upstream. Use a helper function to check that a port needs to use half duplex communication, replacing several occurrences of multi-line bit checking. Fixes: b389f173aaa1 ("tty/serial: atmel: RS485 half duplex w/DMA: enable RX after TX is done") Cc: stable Signed-off-by: Razvan Stefanescu Acked-by: Richard Genoud Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/atmel_serial.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) --- a/drivers/tty/serial/atmel_serial.c +++ b/drivers/tty/serial/atmel_serial.c @@ -225,6 +225,12 @@ static inline void atmel_uart_write_char __raw_writeb(value, port->membase + ATMEL_US_THR); } +static inline int atmel_uart_is_half_duplex(struct uart_port *port) +{ + return (port->rs485.flags & SER_RS485_ENABLED) && + !(port->rs485.flags & SER_RS485_RX_DURING_TX); +} + #ifdef CONFIG_SERIAL_ATMEL_PDC static bool atmel_use_pdc_rx(struct uart_port *port) { @@ -481,9 +487,9 @@ static void atmel_stop_tx(struct uart_po /* Disable interrupts */ atmel_uart_writel(port, ATMEL_US_IDR, atmel_port->tx_done_mask); - if ((port->rs485.flags & SER_RS485_ENABLED) && - !(port->rs485.flags & SER_RS485_RX_DURING_TX)) + if (atmel_uart_is_half_duplex(port)) atmel_start_rx(port); + } /* @@ -500,8 +506,7 @@ static void atmel_start_tx(struct uart_p return; if (atmel_use_pdc_tx(port) || atmel_use_dma_tx(port)) - if ((port->rs485.flags & SER_RS485_ENABLED) && - !(port->rs485.flags & SER_RS485_RX_DURING_TX)) + if (atmel_uart_is_half_duplex(port)) atmel_stop_rx(port); if (atmel_use_pdc_tx(port)) @@ -799,8 +804,7 @@ static void atmel_complete_tx_dma(void * */ if (!uart_circ_empty(xmit)) atmel_tasklet_schedule(atmel_port, &atmel_port->tasklet_tx); - else if ((port->rs485.flags & SER_RS485_ENABLED) && - !(port->rs485.flags & SER_RS485_RX_DURING_TX)) { + else if (atmel_uart_is_half_duplex(port)) { /* DMA done, stop TX, start RX for RS485 */ atmel_start_rx(port); } @@ -1377,8 +1381,7 @@ static void atmel_tx_pdc(struct uart_por atmel_uart_writel(port, ATMEL_US_IER, atmel_port->tx_done_mask); } else { - if ((port->rs485.flags & SER_RS485_ENABLED) && - !(port->rs485.flags & SER_RS485_RX_DURING_TX)) { + if (atmel_uart_is_half_duplex(port)) { /* DMA done, stop TX, start RX for RS485 */ atmel_start_rx(port); }