Received: by 2002:a17:90a:88:0:0:0:0 with SMTP id a8csp4562639pja; Thu, 21 Nov 2019 21:55:42 -0800 (PST) X-Google-Smtp-Source: APXvYqwGi+gJXuUi2fbCzq8YrPjb83oDqUKu+6VkWhr8tpDR5WISxijgIA/1H9paqY71sVNV2Wg7 X-Received: by 2002:a17:906:3d2:: with SMTP id c18mr19593562eja.111.1574402142696; Thu, 21 Nov 2019 21:55:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574402142; cv=none; d=google.com; s=arc-20160816; b=vKhfdn92wAvnqqNqJ4F+VwBIZtKOt9TOofFM51vGlQ5Xrw/yTKhV9/RdGhp8x5Kd2O qH9XDfex8cLjqKswyU+RtDbObJ8C3Ec4LYzuGbAhOcCRM16xTFDKeeswFyXhT3DoS8D+ lZjQ3dABu86CwnKDlzXXihEJXYkPBuDZSf4KvVDeD2emx5rp/2x72dOrMSJTl5MI1XQu i59SgOGn9q4qnegNHW1Wuskuje/9lLadc6YK29G9Q7+nPNx/536q6si9eX61tNcpN08p kNUkqrvwibmt+UsHOGQn9QICnQZWT+X8g23Rqy67GkCmgcRIV7eMGLvc3RRi4Qn4Fqzo tw7g== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ieY04VQ48uATvBRVH8UW3fWvd2/E4bJmqs9YDtPfCgY=; b=HM2moueMvhaVuA6+hA9X4DhRNJ50q1ZPX/+bxDEopXcbAWuJNktg/5Zr0DpUbOS0uq pPoUMrhU1+96M4yiE3kuNFp8rD/+S+lwMNakQxwF8PrGR0rwQnemC8JhiuVQRocRSw7R 38/hLZtpQuG7ogfejcTqU4rix6SbF3ctybAVOUuEh+HfS4x+RGEl0gF4jzhDBTCJhIb/ TgXrxjBu9mn4yghXU0qYmJQubiRvMwGbEExjXtI9/N1h+7qBSxushnYKDSsFk7LlPhGd CjPngvW/kXSXRuvoujHmUP4eQRtuvGfSHVJ9YHIMDnmORvcq/Znh10wR/xF9a+GhhnsD gP6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=avvIwrxF; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k27si2560528edk.319.2019.11.21.21.55.17; Thu, 21 Nov 2019 21:55:42 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=avvIwrxF; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728123AbfKVFvZ (ORCPT + 99 others); Fri, 22 Nov 2019 00:51:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:56200 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728064AbfKVFvP (ORCPT ); Fri, 22 Nov 2019 00:51:15 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5089520726; Fri, 22 Nov 2019 05:51:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574401875; bh=El87W87gUKdjkEIOxGKkTeim2N3L71k5D8CTxcsCHFc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=avvIwrxFIydr4B/XC+5jVyws4fvaKrr67//slw3Pd5wSzi/SQZ44xz54JSbabvfn5 UgCaF32KupFjR7NvyOgbPr5Jh3LQhXxE0j2VvXDRmnOtR0cRdzsUNpGLI0lnPsMTHY yj0OWJhIkTN6um24B7vWDlwKNAWKShW9lSoystMc= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Alexander Shiyan , Greg Kroah-Hartman , Sasha Levin , linux-serial@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 110/219] serial: max310x: Fix tx_empty() callback Date: Fri, 22 Nov 2019 00:47:22 -0500 Message-Id: <20191122054911.1750-103-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191122054911.1750-1-sashal@kernel.org> References: <20191122054911.1750-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexander Shiyan [ Upstream commit a8da3c7873ea57acb8f9cea58c0af477522965aa ] Function max310x_tx_empty() accesses the IRQSTS register, which is cleared by IC when reading, so if there is an interrupt status, we will lose it. This patch implement the transmitter check only by the current FIFO level. Signed-off-by: Alexander Shiyan Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/serial/max310x.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c index bd3e6cf81af5c..0c35c3c5e3734 100644 --- a/drivers/tty/serial/max310x.c +++ b/drivers/tty/serial/max310x.c @@ -844,12 +844,9 @@ static void max310x_wq_proc(struct work_struct *ws) static unsigned int max310x_tx_empty(struct uart_port *port) { - unsigned int lvl, sts; + u8 lvl = max310x_port_read(port, MAX310X_TXFIFOLVL_REG); - lvl = max310x_port_read(port, MAX310X_TXFIFOLVL_REG); - sts = max310x_port_read(port, MAX310X_IRQSTS_REG); - - return ((sts & MAX310X_IRQ_TXEMPTY_BIT) && !lvl) ? TIOCSER_TEMT : 0; + return lvl ? 0 : TIOCSER_TEMT; } static unsigned int max310x_get_mctrl(struct uart_port *port) -- 2.20.1