Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit db8e7847 authored by Shardar Shariff Md's avatar Shardar Shariff Md Committed by Greg Kroah-Hartman
Browse files

serial: tegra: check the count and read if any from dma



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: default avatarShardar Shariff Md <smohammed@nvidia.com>
[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: default avatarJon Hunter <jonathanh@nvidia.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 11e71007
Loading
Loading
Loading
Loading
+6 −4
Original line number Original line Diff line number Diff line
@@ -554,6 +554,10 @@ static void tegra_uart_copy_rx_to_tty(struct tegra_uart_port *tup,
{
{
	int copied;
	int copied;


	/* If count is zero, then there is no data to be copied */
	if (!count)
		return;

	tup->uport.icount.rx += count;
	tup->uport.icount.rx += count;
	if (!tty) {
	if (!tty) {
		dev_err(tup->uport.dev, "No tty port\n");
		dev_err(tup->uport.dev, "No tty port\n");
@@ -588,7 +592,6 @@ static void tegra_uart_rx_dma_complete(void *args)
		set_rts(tup, false);
		set_rts(tup, false);


	/* If we are here, DMA is stopped */
	/* 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);
	tegra_uart_handle_rx_pio(tup, port);
@@ -626,7 +629,6 @@ static void tegra_uart_handle_rx_dma(struct tegra_uart_port *tup,
	count = tup->rx_bytes_requested - state.residue;
	count = tup->rx_bytes_requested - state.residue;


	/* If we are here, DMA is stopped */
	/* 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);
	tegra_uart_handle_rx_pio(tup, port);