Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp4372394img; Tue, 26 Mar 2019 08:11:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqxi/d4K6mJ3GbNWvrr/Ad5yuhB5QhShNWF0Zl6sOCcMR/vSlFHgQqPtUxZxj3FelEodbVzy X-Received: by 2002:a17:902:7c8c:: with SMTP id y12mr12683047pll.209.1553613076210; Tue, 26 Mar 2019 08:11:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553613076; cv=none; d=google.com; s=arc-20160816; b=Drb7vvgulVu+xY8+j8ciGMWpx180j7k1RDvON7xqPRgmmxaKwR7ZAz9QHcUpftUol0 NiHxd4vqs8nj7Xx5C0u4eUUypwYloj4c59+yPsaLpzSkFaBOo4vfDnPdI4tBys3jjiQ2 l2ChQeGATMZrngLAHahXnDMN2dcrphEsnNoUnxLsJBRRrLMgXgSj6T/n29K0BtY/jLAF E92+JLIQ7yEnS1CmFAmxjhTOGvpgdXXEf4nDJf1X9gvLTU/hxlQ6+7R+85WxoroKdoMD 6x7Ead/f4/+/4eByIvHIxwDASpTM+xx1u7fZ+doFPP7Y/J3D08jbYTrxoI82hBru884z iCQw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=HisE3WnUxvIS/6b7BYZU7b1kfdcSL/t2jA7Ar4ResOY=; b=J7NxaBVPsmiW8p+0hlHTBZR/FzlajE6HtMJCPNWHC3n/tQdFxZjn5TRrVTgtbLrSP+ 6erYJnfqt13YpR00ZavkKf0IqKCZJuBZ7xhgU0v71CRb90CJp+FhSpaH7q+8iGBGo+ZF HnxjU+804AE6dOBJR/xnmdxJbJRHvXyF9M4c1PPwRRLFCjDBoI4sZ5H6pmuTMbEReo5/ AoPT1tjPNc8J8Sx5CxPxtQM9nQyzWQaJqDGqWzAY2+T/hfiEYdH/L2088p2sdJMNzFVl 3GwD4JVjk6GJzg5Qi0nEuDDDGvvZIRlfPJOYrLIDX3d3BgVmBgjUFmPt4CcCh9KSpcB8 kkdQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 25si10070001pgm.137.2019.03.26.08.11.00; Tue, 26 Mar 2019 08:11:16 -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; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731599AbfCZPKW (ORCPT + 99 others); Tue, 26 Mar 2019 11:10:22 -0400 Received: from mout02.posteo.de ([185.67.36.142]:45453 "EHLO mout02.posteo.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726175AbfCZPKW (ORCPT ); Tue, 26 Mar 2019 11:10:22 -0400 Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id 8974D2400FC for ; Tue, 26 Mar 2019 16:10:19 +0100 (CET) Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 44TF1P5wS9z9rxR; Tue, 26 Mar 2019 16:10:17 +0100 (CET) Subject: Re: [PATCH v2 1/2] tty/serial: atmel: Add is_half_duplex helper To: Razvan Stefanescu , Greg Kroah-Hartman , Jiri Slaby Cc: Gil Weber , Nicolas Ferre , Alexandre Belloni , Ludovic Desroches , linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20190319132035.18481-1-razvan.stefanescu@microchip.com> <20190319132035.18481-2-razvan.stefanescu@microchip.com> From: Richard Genoud Message-ID: Date: Tue, 26 Mar 2019 16:10:17 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: <20190319132035.18481-2-razvan.stefanescu@microchip.com> Content-Type: text/plain; charset=utf-8 Content-Language: fr Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 19/03/2019 à 14:20, Razvan Stefanescu a écrit : > 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") > Signed-off-by: Razvan Stefanescu Acked-by: Richard Genoud NB: backport on kernel older than 4.20 will fail because of the SER_ISO7816_ENABLED flag. > --- > Changelog: > v2: > - remove extra check > - add fix info > > drivers/tty/serial/atmel_serial.c | 24 ++++++++++++------------ > 1 file changed, 12 insertions(+), 12 deletions(-) > > diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c > index 05147fe24343..b4b89a16a41b 100644 > --- a/drivers/tty/serial/atmel_serial.c > +++ b/drivers/tty/serial/atmel_serial.c > @@ -231,6 +231,13 @@ static inline void atmel_uart_write_char(struct uart_port *port, u8 value) > __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)) || > + (port->iso7816.flags & SER_ISO7816_ENABLED); > +} > + > #ifdef CONFIG_SERIAL_ATMEL_PDC > static bool atmel_use_pdc_rx(struct uart_port *port) > { > @@ -608,10 +615,9 @@ static void atmel_stop_tx(struct uart_port *port) > /* 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)) || > - port->iso7816.flags & SER_ISO7816_ENABLED) > + if (atmel_uart_is_half_duplex(port)) > atmel_start_rx(port); > + > } > > /* > @@ -628,9 +634,7 @@ static void atmel_start_tx(struct uart_port *port) > 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)) || > - port->iso7816.flags & SER_ISO7816_ENABLED) > + if (atmel_uart_is_half_duplex(port)) > atmel_stop_rx(port); > > if (atmel_use_pdc_tx(port)) > @@ -928,9 +932,7 @@ static void atmel_complete_tx_dma(void *arg) > */ > 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)) || > - port->iso7816.flags & SER_ISO7816_ENABLED) { > + else if (atmel_uart_is_half_duplex(port)) { > /* DMA done, stop TX, start RX for RS485 */ > atmel_start_rx(port); > } > @@ -1508,9 +1510,7 @@ static void atmel_tx_pdc(struct uart_port *port) > 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)) || > - port->iso7816.flags & SER_ISO7816_ENABLED) { > + if (atmel_uart_is_half_duplex(port)) { > /* DMA done, stop TX, start RX for RS485 */ > atmel_start_rx(port); > } >