Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp282760ybh; Wed, 22 Jul 2020 00:00:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8i66+GmimKK7NoHqIwTsbcq00jKHN35c5AjiVrLXRz7peUNJGJu6Vz08AzAxcfANQvL2w X-Received: by 2002:a17:906:ca56:: with SMTP id jx22mr27868620ejb.494.1595401257149; Wed, 22 Jul 2020 00:00:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595401257; cv=none; d=google.com; s=arc-20160816; b=HcRSo+ApIYLX+X1yqr8gzsqlVG26I/J9mqvDduJYk40rSg0yi/hTHNmH0ZKjSF1a1w S6LfE96Q2DDoLwjRBmlKBhje5eSZJhZx7wLlDH1KfO66A4+7DW+rUpr64BQGOg2FC1r8 NZ3AqWbjRjdFhg7c/g9C20ST8mJ4gya2x2SCh9pSrQ0sRVxqH8asaCNQBY6mYf2Yuk2w cZ/IMNog9Hq2tv6p0X95Jf/7H2VUXQ+kimDC0LcHm3CSXK8QLkU+IdEch9ajSUwIa+qK oo3+bO2sNYb2RHp1sjwH1apQ6FCdkZthwUWyxUrUKBhgksKxgvAt6aQ5LLE2v8czhHmv vFZQ== 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=/xeUyOVP2rf92ox72wKwyHw0Ls8NwOUQZF0sC7k3BV4=; b=gBJqpLdvRgq+8tTzKFeFqlfJN9cwVohemvz1eD21U2KCgzsf5CyZMxU4TzJU8QJVnq MjbBRw91FqovT1pVCSV/I7PTmXbJFqb2DxsC9mLkuuZlqUG3AYX45ovmK0cjCyGBZOKy 2GEtSCCG+15Nn0NEThtlTUzLV6Nh3lHrrQCRWlxRe6YrHaeHJCwfzXZ5xQ1xoUuXUtnh WbfuxVQwKVpjQ3UhjhDhkaxpWgDItdBIGNiI1MosF5qRGq/vsd+eKeoB8M4GF/M0ogQL sSTYWsno8X7FkOLT9k5kBperF2xd1Jzvchz3b6tdl42dtSw72Td+vrRUssyapzahGuL/ IvOg== 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 de21si13519761edb.510.2020.07.22.00.00.32; Wed, 22 Jul 2020 00:00:57 -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 S1730436AbgGVHAL (ORCPT + 99 others); Wed, 22 Jul 2020 03:00:11 -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-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 --- 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 -- 2.17.1