From patchwork Tue Dec 29 05:27:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Yilun X-Patchwork-Id: 11991993 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 859BFC433DB for ; Tue, 29 Dec 2020 05:33:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 461D62220F for ; Tue, 29 Dec 2020 05:33:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726260AbgL2FdQ (ORCPT ); Tue, 29 Dec 2020 00:33:16 -0500 Received: from mga18.intel.com ([134.134.136.126]:18331 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725832AbgL2FdP (ORCPT ); Tue, 29 Dec 2020 00:33:15 -0500 IronPort-SDR: N/YoS4JcLs7Jkjkg0bF+Nv8KSTZlyzUtffqt0mwYjM4r0EWOxPm85SQGibAHYhRaoc5sUyUCrL FZU1hmwmC0vg== X-IronPort-AV: E=McAfee;i="6000,8403,9848"; a="164170715" X-IronPort-AV: E=Sophos;i="5.78,457,1599548400"; d="scan'208";a="164170715" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Dec 2020 21:32:22 -0800 IronPort-SDR: wYUKWdjiIGe7lfoob99IpQgmWqox1+/F5B5dBO+wlfSk9+Dh1F4C3/DyDGGn+DCF5qmMB35JqO 936D53M2RgVw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,457,1599548400"; d="scan'208";a="395307700" Received: from yilunxu-optiplex-7050.sh.intel.com ([10.239.159.141]) by fmsmga002.fm.intel.com with ESMTP; 28 Dec 2020 21:32:20 -0800 From: Xu Yilun To: broonie@kernel.org, linux-spi@vger.kernel.org Cc: trix@redhat.com, lgoncalv@redhat.com, yilun.xu@intel.com, hao.wu@intel.com, matthew.gerlach@linux.intel.com, russell.h.weight@intel.com, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] spi: altera: fix return value for altera_spi_txrx() Date: Tue, 29 Dec 2020 13:27:41 +0800 Message-Id: <1609219662-27057-2-git-send-email-yilun.xu@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1609219662-27057-1-git-send-email-yilun.xu@intel.com> References: <1609219662-27057-1-git-send-email-yilun.xu@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org This patch fixes the return value for altera_spi_txrx. It should return 1 for interrupt transfer mode, and return 0 for polling transfer mode. The altera_spi_txrx() implements the spi_controller.transfer_one callback. According to the spi-summary.rst, the transfer_one should return 0 when transfer is finished, return 1 when transfer is still in progress. Signed-off-by: Xu Yilun --- drivers/spi/spi-altera.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/drivers/spi/spi-altera.c b/drivers/spi/spi-altera.c index 809bfff..cbc4c28 100644 --- a/drivers/spi/spi-altera.c +++ b/drivers/spi/spi-altera.c @@ -189,24 +189,26 @@ static int altera_spi_txrx(struct spi_master *master, /* send the first byte */ altera_spi_tx_word(hw); - } else { - while (hw->count < hw->len) { - altera_spi_tx_word(hw); - for (;;) { - altr_spi_readl(hw, ALTERA_SPI_STATUS, &val); - if (val & ALTERA_SPI_STATUS_RRDY_MSK) - break; + return 1; + } + + while (hw->count < hw->len) { + altera_spi_tx_word(hw); - cpu_relax(); - } + for (;;) { + altr_spi_readl(hw, ALTERA_SPI_STATUS, &val); + if (val & ALTERA_SPI_STATUS_RRDY_MSK) + break; - altera_spi_rx_word(hw); + cpu_relax(); } - spi_finalize_current_transfer(master); + + altera_spi_rx_word(hw); } + spi_finalize_current_transfer(master); - return t->len; + return 0; } static irqreturn_t altera_spi_irq(int irq, void *dev)