From patchwork Tue Jul 17 04:33:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 10528103 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 82F176020A for ; Tue, 17 Jul 2018 04:34:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 79D432522B for ; Tue, 17 Jul 2018 04:34:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6D7F7280FC; Tue, 17 Jul 2018 04:34:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 125C42522B for ; Tue, 17 Jul 2018 04:34:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726871AbeGQFEi (ORCPT ); Tue, 17 Jul 2018 01:04:38 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:45683 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726805AbeGQFEh (ORCPT ); Tue, 17 Jul 2018 01:04:37 -0400 Received: by mail-pf0-f195.google.com with SMTP id i26-v6so15972578pfo.12; Mon, 16 Jul 2018 21:33:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=AGNgRg8aDtRLLaXwMD+ZgahrOOM+jS0eTUlWzkM0Xxc=; b=jaaxZRFX+vhW4bGNew6Wc9iqSkKujFObpMF45jQkssnwo6xaZ2th2CmLuU88Ohpg1g JRn1NTJr6LA3a0BumDGr67aHHLcinmJdv87rQQDFxBVPSiKQ6pRQn/PRzvOqgcB5VbV5 9t5UzkuFjfTaU4DyvbcRqQ2hDfTV31jMLazcQFDZTWbDH9p2JjVw3qNwZ6mh+OBw4gzL TDYokB3+IRQtzVVl+gPUvDFVs1xkZlnc9qoBiowgEUCZyMALcyfpvP+u1O7bxZg8OON1 o83EyaYHzai8M1gwjEgJiTgnbDx1KmrD4RduwKLtY/OOW4MBKF/QGrl+juX2Gyf8e7B7 ShPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=AGNgRg8aDtRLLaXwMD+ZgahrOOM+jS0eTUlWzkM0Xxc=; b=t1ET3X5zbWWMe7A+AQ26xa+eEJkSUJqPIRRMdkdTlE62NqMmQczxsFqgaaTcpE4687 5tukFclhezeuajqsTum4vvFoA4Vn9SZwcXBvFZQVEqO+Xu0ak3VZOnPnUDE6Pbz3NqRa nQEHPTtk+QSYdUfneSkSV6SUnU44Mt16VfpXwsAt9okGkqhYMooBICUrEE89D5QJp7K7 hTIPMrGlBZB99WEpj2+pYYB4CXJQQtDhsYPg97HkJimjoSph1KdbZPz77Icnorq/4Svk sje0kQ0TMmwOt1WiJMB7K/0Ns3HKZy8Zowj+ZCX5lRJxRl4+5KDfvSQgoPxRR3+aTZuf qldw== X-Gm-Message-State: AOUpUlFQaaB4HX2GROc8zbWwOZHWgZFzUjgCQuezI1hNe9Nm315hu17+ 3HXF2C1JgZIVJjmb9qK4T50iOvrI X-Google-Smtp-Source: AAOMgpcSMExBOX3VzCe8o1v1Ky+1WNB9s41xBZVt/vVoPuYXtM2ru55AkzeYm52+zBOxu33YTYuV6Q== X-Received: by 2002:a62:9849:: with SMTP id q70-v6mr55832pfd.178.1531802039347; Mon, 16 Jul 2018 21:33:59 -0700 (PDT) Received: from squirtle.lan (c-24-22-235-96.hsd1.wa.comcast.net. [24.22.235.96]) by smtp.gmail.com with ESMTPSA id j75-v6sm35316904pfj.102.2018.07.16.21.33.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Jul 2018 21:33:58 -0700 (PDT) From: Andrey Smirnov To: Mark Brown Cc: Andrey Smirnov , Sanchayan Maity , Stefan Agner , cphealy@gmail.com, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] spi: spi-fsl-dspi: Fill actual_length when doing DMA transfer Date: Mon, 16 Jul 2018 21:33:29 -0700 Message-Id: <20180717043329.4209-1-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.17.1 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Upper layer users of SPI device drivers may rely on 'actual_length', so it is important that information is correctly reported. One such example is spi_mem_exec_op() function that will fail if 'actual_length' of the data transferred is not what was requested. Add necessary code to populate 'actual_length. Cc: Mark Brown Cc: Sanchayan Maity Cc: Stefan Agner Cc: cphealy@gmail.com Cc: linux-spi@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Andrey Smirnov --- Changes since [v1] - Patch rebase on for-next branch of SPI sybsytem's git tree [v1] lkml.kernel.org/r/20180716062508.7726-1-andrew.smirnov@gmail.com drivers/spi/spi-fsl-dspi.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c index 89a1e7a4fe5d..9e598642ca66 100644 --- a/drivers/spi/spi-fsl-dspi.c +++ b/drivers/spi/spi-fsl-dspi.c @@ -358,6 +358,7 @@ static int dspi_dma_xfer(struct fsl_dspi *dspi) { struct fsl_dspi_dma *dma = dspi->dma; struct device *dev = &dspi->pdev->dev; + struct spi_message *message = dspi->cur_msg; int curr_remaining_bytes; int bytes_per_buffer; int ret = 0; @@ -377,8 +378,10 @@ static int dspi_dma_xfer(struct fsl_dspi *dspi) goto exit; } else { - curr_remaining_bytes -= dma->curr_xfer_len - * dspi->bytes_per_word; + const int len = + dma->curr_xfer_len * dspi->bytes_per_word; + curr_remaining_bytes -= len; + message->actual_length += len; if (curr_remaining_bytes < 0) curr_remaining_bytes = 0; }