Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp333760ybh; Wed, 22 Jul 2020 01:40:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzePm5AH5nucY9SPUboNtV4O4TfmuVxLshCaAWe0fJrZVk7CBeF5ciuIoDsFDJpEKtdnxPH X-Received: by 2002:a17:906:b345:: with SMTP id cd5mr4540090ejb.131.1595407229783; Wed, 22 Jul 2020 01:40:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595407229; cv=none; d=google.com; s=arc-20160816; b=qw3zKDoZfm4JNq4pf6KEOmb/prknFGjRciUFZDrDB7n0hoU9qnIq0okLM8QH/uUxvO GENob4AfrZ2q9oIGj8wkgGf4jobD6KAZ+2DeEQpt3HIdrpQYt9WdTQtnetuisqbrEBmj bCezY9PO0OC5LXQcPZJcsHlcqXPlYb270AChejbiWuDW5muoALe5lnm4rY288d20wxoR ZehLhTgxZcJZlnqv+zbr+8zq03qX3qzxumLiFD+c9SaEYJ6OqzScMFlIo5ZL7a13Mi+3 xC4TrnE3IF9FbD2MVPJJ9viEuOJ8WSP1BhLeZqD9muZ9I0MhQFVz0W04E9KNqrotxPSG qguw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=+90SxQlLalWASCjWOBfLTxeKDTPIh/lauGxAbLjzlwA=; b=JUGWr5II0W2+YKT72MXIExG+Va5iLl/ZSOyKUj2pWLhFDDaSD1YDtP+S8vmUbN7zF5 VZLkEcNLYilahRHm2MifM6A0301WHDn5GiD1sm2R/HybivFnT3rdP6IYXk1O6VcRwO8t 0Gj6BYMIFYujC46E5sSUiqW+Sq6RYc4MlIhkS/65+247FDTRI1sOkMb1ZekkOLHJwEV4 pzH2vSf0qFzfadWZjRIaHmwCYsAeRa5S6L2yNNLFLcPxHVmrBSpz3WUSqb4WhwQS1PWt cZyTiyCyLKiRjFH3RnYXwASQXu5i0/bF2Q4LmXJyVN9DQjpSAmArVg1XkTn8f8Y6s2PO BpnQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s24si14677125ejd.737.2020.07.22.01.40.06; Wed, 22 Jul 2020 01:40:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728930AbgGVIhx (ORCPT + 99 others); Wed, 22 Jul 2020 04:37:53 -0400 Received: from lucky1.263xmail.com ([211.157.147.130]:35594 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726638AbgGVIhx (ORCPT ); Wed, 22 Jul 2020 04:37:53 -0400 Received: from localhost (unknown [192.168.167.69]) by lucky1.263xmail.com (Postfix) with ESMTP id 50338CAA67; Wed, 22 Jul 2020 16:37:48 +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 P18496T139713711163136S1595407061138531_; Wed, 22 Jul 2020 16:37:47 +0800 (CST) X-IP-DOMAINF: 1 X-UNIQUE-TAG: 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 v2 3/3] spi: rockchip: Fix error in SPI slave pio read Date: Wed, 22 Jul 2020 16:37:37 +0800 Message-Id: <20200722083737.8820-3-jon.lin@rock-chips.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200722083737.8820-1-jon.lin@rock-chips.com> References: <20200722083737.8820-1-jon.lin@rock-chips.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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..75a8a9428ff8 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 -- 2.17.1