Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2993266AbbEEQGO (ORCPT ); Tue, 5 May 2015 12:06:14 -0400 Received: from hqemgate16.nvidia.com ([216.228.121.65]:11577 "EHLO hqemgate16.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2993148AbbEEOSR (ORCPT ); Tue, 5 May 2015 10:18:17 -0400 X-PGP-Universal: processed; by hqnvupgp07.nvidia.com on Tue, 05 May 2015 07:16:52 -0700 From: Jon Hunter To: Laxman Dewangan , Greg Kroah-Hartman , Jiri Slaby CC: , , , Shardar Shariff Md , Jon Hunter Subject: [PATCH 3/8] serial: tegra: check the count and read if any from dma Date: Tue, 5 May 2015 15:17:54 +0100 Message-ID: <1430835479-6613-4-git-send-email-jonathanh@nvidia.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1430835479-6613-1-git-send-email-jonathanh@nvidia.com> References: <1430835479-6613-1-git-send-email-jonathanh@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2212 Lines: 63 From: Shardar Shariff Md It is only necessary to read data from the dma buffer when the count value is non-zero and hence, tegra_uart_copy_rx_to_tty() so only be called when this is the case. Although, this was being tested for in two places, there is a third place where this was not tested. However, instead of adding another if-statement prior to calling tegra_uart_copy_rx_to_tty(), move the test inside the function. Signed-off-by: Shardar Shariff Md [jonathanh@nvidia.com: Re-worked patch to move the check for the count value inside the function tegra_uart_copy_rx_to_tty(). Updated changelog with more commentary.] Signed-off-by: Jon Hunter --- drivers/tty/serial/serial-tegra.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/tty/serial/serial-tegra.c b/drivers/tty/serial/serial-tegra.c index 0d9d7ceb1dbb..a53899c47e60 100644 --- a/drivers/tty/serial/serial-tegra.c +++ b/drivers/tty/serial/serial-tegra.c @@ -554,6 +554,10 @@ static void tegra_uart_copy_rx_to_tty(struct tegra_uart_port *tup, { int copied; + /* If count is zero, then there is no data to be copied */ + if (!count) + return; + tup->uport.icount.rx += count; if (!tty) { dev_err(tup->uport.dev, "No tty port\n"); @@ -588,8 +592,7 @@ static void tegra_uart_rx_dma_complete(void *args) set_rts(tup, false); /* If we are here, DMA is stopped */ - if (count) - tegra_uart_copy_rx_to_tty(tup, port, count); + tegra_uart_copy_rx_to_tty(tup, port, count); tegra_uart_handle_rx_pio(tup, port); if (tty) { @@ -626,8 +629,7 @@ static void tegra_uart_handle_rx_dma(struct tegra_uart_port *tup, count = tup->rx_bytes_requested - state.residue; /* If we are here, DMA is stopped */ - if (count) - tegra_uart_copy_rx_to_tty(tup, port, count); + tegra_uart_copy_rx_to_tty(tup, port, count); tegra_uart_handle_rx_pio(tup, port); if (tty) { -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/