Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp443282img; Mon, 18 Mar 2019 06:42:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqzOttx1BUF94PXhrsOwwYQn00r+r1z8GsRE48WI2XTSdvqPnHIam7md3CqE581KjqSI4nDu X-Received: by 2002:a63:1156:: with SMTP id 22mr17048551pgr.357.1552916554756; Mon, 18 Mar 2019 06:42:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552916554; cv=none; d=google.com; s=arc-20160816; b=zMYlmFsreRL8n29W6Uyjr8gimntr+mvhC1fPqEwXtbPV+TgbN8G0G2ptvUV23uOBnN OXmgkJowIuDeNeD+W1s4cPBiNJWOihC1HXTBEwZaGUlA05anftOQUh5+BB3Lv77cll0L 8Tx6bJwpnAgaqiUsoA7+3joWccZxihwdzMRuULsUlu/WoNhF3SROWz6cX/aPrd6qR8rU GHVshYFc9xPqJipOpE3P0X0c/lRojYSR/bv7ZIc7KCIMY99BKjzk/qf2etzua0sWc4v+ r1Tah0lNIlYpb2Jg6Sdma9LjZaOFrzcpCh0PLufLuCCBFMV1BpUkCVQdf25sjGCOhl9y Flgg== 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=ldy4aJA4rJTOuyR2eMmW5w7bi82bcAWWFN11z3Uv9vg=; b=0+kGwsIzRkiyyAGpUN8G3jlAlHliuM8dXCuNvPaNl7as75UdGpy+zu7lqpwEJakBMa z6mYVAwtq6hj5htuwH9QoOHx1/ZXDdt2jAP8t0ahBU3ojVhbvyALHNjuQKgTuoUJ+bTp qp/tUEX3ZBiutK03fD0FUULvJd8vMnv3o5ZqJoc6qv7O1aRRQdH7DRusB3H7UfQgjmtN Y6698cYPCvbwlqzclsQeFnIF5V6kbHyxwB4VeAWfUiTWUALfCt5eK5nca34mw/KsCCb+ 4njrBWh5XOuziFOKduwc2X7wBCdrSTjRrlKy1sDYwcrxFgEvOe3dcxe/4v1TK1T04Vt7 E6Qw== 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 v7si9125383pgk.464.2019.03.18.06.42.18; Mon, 18 Mar 2019 06:42:34 -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 S1726926AbfCRNlo (ORCPT + 99 others); Mon, 18 Mar 2019 09:41:44 -0400 Received: from mout02.posteo.de ([185.67.36.142]:36951 "EHLO mout02.posteo.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726740AbfCRNlo (ORCPT ); Mon, 18 Mar 2019 09:41:44 -0400 Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id 88ED82400E5 for ; Mon, 18 Mar 2019 14:41:41 +0100 (CET) Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 44NHQq2zpLz9rxR; Mon, 18 Mar 2019 14:41:38 +0100 (CET) Subject: Re: [PATCH 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: <20190315092334.13246-1-razvan.stefanescu@microchip.com> <20190315092334.13246-2-razvan.stefanescu@microchip.com> From: Richard Genoud Message-ID: Date: Mon, 18 Mar 2019 14:41:35 +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: <20190315092334.13246-2-razvan.stefanescu@microchip.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ adding Gil Weber in Cc: ] Le 15/03/2019 à 10:23, 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. > > Signed-off-by: Razvan Stefanescu > --- > drivers/tty/serial/atmel_serial.c | 27 ++++++++++++++------------- > 1 file changed, 14 insertions(+), 13 deletions(-) > > diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c > index 05147fe24343..a6577b1c4461 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,10 @@ 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) > - atmel_start_rx(port); > + if (atmel_uart_is_half_duplex(port)) > + if (!atomic_read(&atmel_port->tasklet_shutdown)) This check wasn't there before. If it's really needed, please insert it in another patch and explain why it's needed. > + atmel_start_rx(port); > + > } > > /* > @@ -628,9 +635,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 +933,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 +1511,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); > } >