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

Commit 9b9e8bc9 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "serial: msm_serial_hs: Add extra delay during close with pending tx"

parents dbf87d1e d64c7bb0
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@
#include <linux/kernel.h>
#include <linux/timer.h>
#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/dma-mapping.h>
@@ -1237,16 +1238,27 @@ static void msm_hs_set_termios(struct uart_port *uport,
unsigned int msm_hs_tx_empty(struct uart_port *uport)
{
	unsigned int data;
	unsigned int isr;
	unsigned int ret = 0;
	struct msm_hs_port *msm_uport = UARTDM_TO_MSM(uport);

	msm_hs_resource_vote(msm_uport);
	data = msm_hs_read(uport, UART_DM_SR);
	isr = msm_hs_read(uport, UART_DM_ISR);
	msm_hs_resource_unvote(msm_uport);
	MSM_HS_DBG("%s(): SR Reg Read 0x%x", __func__, data);
	MSM_HS_INFO("%s(): SR:0x%x ISR:0x%x ", __func__, data, isr);

	if (data & UARTDM_SR_TXEMT_BMSK)
	if (data & UARTDM_SR_TXEMT_BMSK) {
		ret = TIOCSER_TEMT;
	} else
		/*
		 * Add an extra sleep here because sometimes the framework's
		 * delay (based on baud rate) isn't good enough.
		 * Note that this won't happen during every port close, only
		 * on select occassions when the userspace does back to back
		 * write() and close().
		 */
		usleep_range(5000, 7000);

	return ret;
}