From patchwork Fri Dec 19 08:01:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 5517881 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7DC13BEEA8 for ; Fri, 19 Dec 2014 08:01:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B05572012D for ; Fri, 19 Dec 2014 08:01:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CB65220131 for ; Fri, 19 Dec 2014 08:01:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752035AbaLSIBo (ORCPT ); Fri, 19 Dec 2014 03:01:44 -0500 Received: from mail-pa0-f45.google.com ([209.85.220.45]:37979 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751003AbaLSIBn (ORCPT ); Fri, 19 Dec 2014 03:01:43 -0500 Received: by mail-pa0-f45.google.com with SMTP id lf10so709555pab.32 for ; Fri, 19 Dec 2014 00:01:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:subject:from:to:cc:date:content-type :mime-version:content-transfer-encoding; bh=WUpzdUY28EKv1sEuXx4/SDQA5AJHrxr2VQWlfSLfCvM=; b=Kz3aE3hjzH6Rhbt7m4mExDKXBv42DgXfr1eHlqDFjENtHSpbirYi81nn/M8jdkCzK/ wm50PKw/lVMpZfB47MxomNMSkZWrg+cj1DqLXGOYQiDwlPbcT2wi9+scQkcNmjf6auls UC7OqgV4VEORXC2ERWPGtRcUSo7YnaTi/PNeLrpJqe4ehypGoSZ/9LTG6CNWLpmIGzZx M7NDWr0hDpoMprABgTXO2Wup0X+AXUHu+1qTyzUMMgeuw/oKBGN6C/Se2+1UXJnHBi4R MAqqqrvwGmbQbaku0K/ih4f1O0Mk5reFL9+3sxkhKFbAVjAv76T6+bIpdUkhVlQhMXVa 8+oA== X-Gm-Message-State: ALoCoQlhB4RTcMHuaat49W/k8adgdjFCGeyLgX+tr29KO0TYsNdEgG4sI0bXk0Lhd/84sTs+jP4n X-Received: by 10.70.88.47 with SMTP id bd15mr10606165pdb.54.1418976103081; Fri, 19 Dec 2014 00:01:43 -0800 (PST) Received: from [192.168.0.104] (218-164-103-208.dynamic.hinet.net. [218.164.103.208]) by mx.google.com with ESMTPSA id p1sm8779255pdp.42.2014.12.19.00.01.40 (version=TLSv1.2 cipher=AES128-GCM-SHA256 bits=128/128); Fri, 19 Dec 2014 00:01:42 -0800 (PST) Message-ID: <1418976099.23257.4.camel@phoenix> Subject: [PATCH RFT] spi: dw: Fix off-by-one for checking fifo depth From: Axel Lin To: Mark Brown Cc: Thor Thayer , Andy Shevchenko , Feng Tang , Stefan Roese , linux-spi Date: Fri, 19 Dec 2014 16:01:39 +0800 X-Mailer: Evolution 3.10.4-0ubuntu2 Mime-Version: 1.0 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The fifo depth could be from 2 to 256 from HW spec, so fix off-by-one for checking fifo depth. Without this patch, fifo is 258 after for loop iteration for the "no-match" case. So below line does not catch the "no-match" case. dws->fifo_len = (fifo == 257) ? 0 : fifo; Signed-off-by: Axel Lin --- Hi, I don't have this hardware handy, so please test it. BTW, I'm wondering if it make sense to set dws->fifo_len to 0. Isn't it suppose to be 2 ~ 256? Thanks. drivers/spi/spi-dw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c index d0d5542..74b27479 100644 --- a/drivers/spi/spi-dw.c +++ b/drivers/spi/spi-dw.c @@ -621,7 +621,7 @@ static void spi_hw_init(struct dw_spi *dws) if (!dws->fifo_len) { u32 fifo; - for (fifo = 2; fifo <= 257; fifo++) { + for (fifo = 2; fifo <= 256; fifo++) { dw_writew(dws, DW_SPI_TXFLTR, fifo); if (fifo != dw_readw(dws, DW_SPI_TXFLTR)) break;