From patchwork Tue Jan 15 13:46:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 155669 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4910564jaa; Tue, 15 Jan 2019 05:47:34 -0800 (PST) X-Google-Smtp-Source: ALg8bN6xJ36phuGimWA869XxonaG0atWuf47Q2xuLDqMkJfUQQMDPzE8K8RWR53Cy2h2BKmUhGnB X-Received: by 2002:a63:557:: with SMTP id 84mr3821704pgf.411.1547560054166; Tue, 15 Jan 2019 05:47:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547560054; cv=none; d=google.com; s=arc-20160816; b=kSZ0v+mesOxQHsh6u8PH3YvNP5sIRHO6CHlgq+d8gjNO4juGrvLR+e7mbibUnKGGbs LoJs319Tsc0O4dv6uLU39ddLz2SWwVcYuL14Kns1DiMZ1T6hCSBeuHx/T6PJUeOmh2oO R6S8BJsfkos+JKf8Kjtt2UkxW1Ctj0ohEx1RxdHYpOzJNp8pgQWY2XNtw+DiLlyEyGsu m2EjWT5DMqY9WzzjZeIAkH0XMH3mXuHYsA2Kodyn6Ftn0hvyijlKavqdfC2WVHHzb5wH O+TTCGevJV7f3fJfWtyeNkTnxyklgE780eWkgoNf1RBcTq+wCjz/Qf0/4Iwnzcr1gT1h fqbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=iJghhK3Ea6pnQ7EyMrgiOwYdRz+yXPK9qPAyKingmVg=; b=ewNkX4/0tUSVK/PikuR1JeqzpklQOx4kngU+9Pab5VBO91cSGQfEetwBiz/5gqRhsn 2BdwSL3Q6keoDgCBmXKpwt+vlG4ZSXSAmpE4PbSwoZhIeJjnu5tN3eze55XUKvyOPw/K 54Syvy9661FgP53cwz8mTOhlUMsMregyDhGojHddaW9nPmZzCBZ6XDBbw9d2nAnLhEsq LOcsq0wIc4uDYVvSPcS961fgT/85/1X7IWX7EFwhPSKHrszgTmwdojBHipJbkvzb6Kzu St0rcsZ8dF7nYls0SOpRjMm/MbkxcDmLuhmzMs/3qP1wan0IOSUmQ6ykrn8Q3U0kGHB4 iaYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JFyW2Ngv; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g83si3455036pfb.278.2019.01.15.05.47.33; Tue, 15 Jan 2019 05:47:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JFyW2Ngv; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728437AbfAONrd (ORCPT + 7 others); Tue, 15 Jan 2019 08:47:33 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:33099 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727036AbfAONrc (ORCPT ); Tue, 15 Jan 2019 08:47:32 -0500 Received: by mail-pl1-f196.google.com with SMTP id z23so1335614plo.0 for ; Tue, 15 Jan 2019 05:47:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=iJghhK3Ea6pnQ7EyMrgiOwYdRz+yXPK9qPAyKingmVg=; b=JFyW2Ngva1MEGl5CSZA9zej4PRgkR2zxRydccPGGi39cRrIlXpZV5LpQJJ8Iw91xpe gnYDGJIJPDn5YomZAbLU/4xUwd5FhY1agHUl+GeVMoWGkbBpSbgT9h2lPe1tE+MdD+t8 bUXu2f/mvfYWsoJatf0b3EfzoA6hnt1PA47AE= 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=iJghhK3Ea6pnQ7EyMrgiOwYdRz+yXPK9qPAyKingmVg=; b=rLP2UvJ3E7RLFNmgi6HqAbz5LQuIXUrqqinMw1uGaqYKZ6QU5UjZ0XnSV3+FmaJtYy qPZSfwnVRVEaJFR99TpmLdygatgWOa3SRadU32n4P3pNTXF1n2BibXQn1KtLP1nTl9Jl U4PezyOtwGTGJbVMDFoQm9OgDqsCYwAcAjpOQL/T5YFU/2LfbSrAL8S1uNvlXPMKvH0u wpmAc5dKTfzsnOVm+/E7JYPw6L3pEQ3WZ1fQY/4s+upm63YL+xs84vxYAi4mY4AHFXge /IuEq9pYMcvBIFjSFXDcZdNlW163FfKop/bl9zFLGePUx+yJuuXG05QTC02mTXBJaCYz Qy0Q== X-Gm-Message-State: AJcUukf+7kTzJthcMj2RprJRjxULA4O2qIRtgAUdTbb9JAUjBsZqvJ+T BeuydxAwueImtppSbEiqFXJCSw== X-Received: by 2002:a17:902:aa4c:: with SMTP id c12mr4261453plr.48.1547560052298; Tue, 15 Jan 2019 05:47:32 -0800 (PST) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id y71sm5979422pfi.123.2019.01.15.05.47.29 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 15 Jan 2019 05:47:31 -0800 (PST) From: Baolin Wang To: broonie@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com Cc: orsonzhai@gmail.com, zhang.lyra@gmail.com, lanqing.liu@unisoc.com, baolin.wang@linaro.org, linux-spi@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/4] spi: sprd: Fix the error data length in SPI read-only mode Date: Tue, 15 Jan 2019 21:46:50 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Lanqing Liu In SPI read-only mode, we will always return the writing length, which is always the power of "bits_per_word", but the length unit using by users is byte. Thus this patch fixes the returning length by getting from read_bufs() function to get the correct length. Signed-off-by: Lanqing Liu Signed-off-by: Baolin Wang --- drivers/spi/spi-sprd.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) -- 1.7.9.5 diff --git a/drivers/spi/spi-sprd.c b/drivers/spi/spi-sprd.c index 8daa24e..fa324ce 100644 --- a/drivers/spi/spi-sprd.c +++ b/drivers/spi/spi-sprd.c @@ -380,7 +380,7 @@ static int sprd_spi_txrx_bufs(struct spi_device *sdev, struct spi_transfer *t) { struct sprd_spi *ss = spi_controller_get_devdata(sdev->controller); u32 trans_len = ss->trans_len, len; - int ret, write_size = 0; + int ret, write_size = 0, read_size = 0; while (trans_len) { len = trans_len > SPRD_SPI_FIFO_SIZE ? SPRD_SPI_FIFO_SIZE : @@ -416,13 +416,15 @@ static int sprd_spi_txrx_bufs(struct spi_device *sdev, struct spi_transfer *t) goto complete; if (ss->trans_mode & SPRD_SPI_RX_MODE) - ss->read_bufs(ss, len); + read_size += ss->read_bufs(ss, len); trans_len -= len; } - ret = write_size; - + if (ss->trans_mode & SPRD_SPI_TX_MODE) + ret = write_size; + else + ret = read_size; complete: sprd_spi_enter_idle(ss);