From patchwork Wed Jul 22 06:52:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Lin X-Patchwork-Id: 11677503 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C003513B6 for ; Wed, 22 Jul 2020 07:00:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A55CE2080D for ; Wed, 22 Jul 2020 07:00:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728734AbgGVHAJ (ORCPT ); Wed, 22 Jul 2020 03:00:09 -0400 Received: from lucky1.263xmail.com ([211.157.147.132]:39830 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728649AbgGVHAJ (ORCPT ); Wed, 22 Jul 2020 03:00:09 -0400 X-Greylist: delayed 416 seconds by postgrey-1.27 at vger.kernel.org; Wed, 22 Jul 2020 03:00:08 EDT Received: from localhost (unknown [192.168.167.16]) by lucky1.263xmail.com (Postfix) with ESMTP id 20E1CEC62E; Wed, 22 Jul 2020 14:53:07 +0800 (CST) X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-ADDR-CHECKED4: 1 X-ANTISPAM-LEVEL: 2 X-ABS-CHECKED: 0 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (postfix) whith ESMTP id P18585T140686821160704S1595400779440716_; Wed, 22 Jul 2020 14:53:06 +0800 (CST) X-IP-DOMAINF: 1 X-UNIQUE-TAG: <74157f8dcec066b87f683519ea3632cb> X-RL-SENDER: jon.lin@rock-chips.com X-SENDER: jon.lin@rock-chips.com X-LOGIN-NAME: jon.lin@rock-chips.com X-FST-TO: broonie@kernel.org X-SENDER-IP: 58.22.7.114 X-ATTACHMENT-NUM: 0 X-DNS-TYPE: 0 X-System-Flag: 0 From: Jon Lin To: broonie@kernel.org Cc: heiko@sntech.de, linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, Jon Lin Subject: [PATCH v1 3/3] spi: rockchip: Fix error in SPI slave pio read Date: Wed, 22 Jul 2020 14:52:57 +0800 Message-Id: <20200722065257.17943-3-jon.lin@rock-chips.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200722065257.17943-1-jon.lin@rock-chips.com> References: <20200722065257.17943-1-jon.lin@rock-chips.com> Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org The RXFLR is possible larger than rx_left in Rockchip SPI, fix it. Signed-off-by: Jon Lin Reviewed-by: Heiko Stuebner --- drivers/spi/spi-rockchip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c index a451dacab5cf..1f5e613b67d9 100644 --- a/drivers/spi/spi-rockchip.c +++ b/drivers/spi/spi-rockchip.c @@ -291,7 +291,7 @@ static void rockchip_spi_pio_writer(struct rockchip_spi *rs) static void rockchip_spi_pio_reader(struct rockchip_spi *rs) { u32 words = readl_relaxed(rs->regs + ROCKCHIP_SPI_RXFLR); - u32 rx_left = rs->rx_left - words; + u32 rx_left = rs->rx_left > words ? rs->rx_left - words : 0; /* the hardware doesn't allow us to change fifo threshold * level while spi is enabled, so instead make sure to leave