From patchwork Fri May 6 00:31:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 619105 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3r1CTh2zlfz9t74 for ; Fri, 6 May 2016 10:34:48 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=e2cXRD0V; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ayThb-0006ph-PC; Fri, 06 May 2016 00:33:07 +0000 Received: from mail-pa0-x22a.google.com ([2607:f8b0:400e:c03::22a]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ayThR-0006La-VO for linux-mtd@lists.infradead.org; Fri, 06 May 2016 00:32:58 +0000 Received: by mail-pa0-x22a.google.com with SMTP id iv1so41145780pac.2 for ; Thu, 05 May 2016 17:32:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xurYbQbFNZsj3mpjVMafYnljFY9JS2roon3T0z/wBW8=; b=e2cXRD0VftKHgKb/vzqFo9CwReFdPOOLe+GfPDjSGU8IyGrc7DmHl0yc2dXK8pAyhH PRn4wf+70PNo30+fw9OukTJmvLcLymj5CZss4dU58DOksvOhf/o46pxcuIC8tD7Iogej ZkLDnMzlsn36F0u7TMnG1JjJpwqMpNdHXgDSLe1x1vk2xug4JwC3cm/X5AMXAto8n7a0 G+aLknRmzkcRJrhEvsW2klPa0vk0qltVn1F782ILAByWf84MERxOLpymE9ze8MYw9vAk yUClNN3VXMMogtvlLkRGkfJ+tcF3BtP/KKtIkf45VywmUZhLnoiAq1rq1eL7fFQe87Q/ /9ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xurYbQbFNZsj3mpjVMafYnljFY9JS2roon3T0z/wBW8=; b=H05lKaXa5GOVRgPmIwKmZaAg0RsVWaC5HeD46rnMOUZZy68WIsJjpefIedZusYbT42 SHI4tLX8KOvyI+2knDrsVZ7LB5Ey02wKx2DBmy830SVo45IDi0oCZXFOyjjQ1TykNVv+ 0LVFvvPXlhotVkX0fv/JI6d/Q6ue2iXrx2UkQVmR7g1NDFWFIYupFphHZpxS4UZZXPYI 5pDdbhympDU4HNxvusWqOC2c3P/FfndQpvirGq6e/eqyQ/P49Pt5Xg7uuVgseaLRmmFB QoQcbDvL5K1fSsLL+avAQ69Nv0Q3npxNy3TgT1UFKsKoQc2HzREOKzMlqAquH3cpTt+U b0UA== X-Gm-Message-State: AOPr4FXgGYWDQx6eP17RNlR1ayCM0Q+r73LbtK1EFDXnRg0TmRz3b0aeiP0AdgBpPdrXhQ== X-Received: by 10.66.90.196 with SMTP id by4mr24939183pab.117.1462494757276; Thu, 05 May 2016 17:32:37 -0700 (PDT) Received: from ban.mtv.corp.google.com ([172.22.64.120]) by smtp.gmail.com with ESMTPSA id n10sm16337821pax.18.2016.05.05.17.32.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 May 2016 17:32:36 -0700 (PDT) From: Brian Norris To: Subject: [PATCH v7 03/10] mtd: fsl-quadspi: return amount of data read/written or error Date: Thu, 5 May 2016 17:31:49 -0700 Message-Id: <1462494716-95312-4-git-send-email-computersforpeace@gmail.com> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: <1462494716-95312-1-git-send-email-computersforpeace@gmail.com> References: <1462494716-95312-1-git-send-email-computersforpeace@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160505_173258_043313_742E8A6A X-CRM114-Status: GOOD ( 13.20 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (computersforpeace[at]gmail.com) -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2607:f8b0:400e:c03:0:0:0:22a listed in] [list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Boris Brezillon , Michal Suchanek , Gabor Juhos , Bean Huo , Rafal Milecki , linux-kernel@vger.kernel.org, Bayi Cheng , "Andrew F. Davis" , Javier Martinez Canillas , Jagan Teki , Han Xu , Cyrille Pitchen , Brian Norris , Mika Westerberg , Joachim Eastwood , Heiner Kallweit MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Michal Suchanek Return amount of data read/written or error as read(2)/write(2) does. Signed-off-by: Michal Suchanek Signed-off-by: Brian Norris --- v6 -> v7: * moved some *retlen changes to patch 7 to preserve bisectability drivers/mtd/spi-nor/fsl-quadspi.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/mtd/spi-nor/fsl-quadspi.c b/drivers/mtd/spi-nor/fsl-quadspi.c index 74dc155e1b3b..ea296769f015 100644 --- a/drivers/mtd/spi-nor/fsl-quadspi.c +++ b/drivers/mtd/spi-nor/fsl-quadspi.c @@ -618,7 +618,7 @@ static inline void fsl_qspi_invalid(struct fsl_qspi *q) qspi_writel(q, reg, q->iobase + QUADSPI_MCR); } -static int fsl_qspi_nor_write(struct fsl_qspi *q, struct spi_nor *nor, +static ssize_t fsl_qspi_nor_write(struct fsl_qspi *q, struct spi_nor *nor, u8 opcode, unsigned int to, u32 *txbuf, unsigned count, size_t *retlen) { @@ -647,8 +647,11 @@ static int fsl_qspi_nor_write(struct fsl_qspi *q, struct spi_nor *nor, /* Trigger it */ ret = fsl_qspi_runcmd(q, opcode, to, count); - if (ret == 0 && retlen) - *retlen += count; + if (ret == 0) { + if (retlen) + *retlen += count; + return count; + } return ret; } @@ -860,6 +863,8 @@ static int fsl_qspi_write_reg(struct spi_nor *nor, u8 opcode, u8 *buf, int len) } else if (len > 0) { ret = fsl_qspi_nor_write(q, nor, opcode, 0, (u32 *)buf, len, NULL); + if (ret > 0) + return 0; } else { dev_err(q->dev, "invalid cmd %d\n", opcode); ret = -EINVAL; @@ -873,12 +878,12 @@ static ssize_t fsl_qspi_write(struct spi_nor *nor, loff_t to, { struct fsl_qspi *q = nor->priv; - fsl_qspi_nor_write(q, nor, nor->program_opcode, to, + ssize_t ret = fsl_qspi_nor_write(q, nor, nor->program_opcode, to, (u32 *)buf, len, retlen); /* invalid the data in the AHB buffer. */ fsl_qspi_invalid(q); - return 0; + return ret; } static ssize_t fsl_qspi_read(struct spi_nor *nor, loff_t from, @@ -925,7 +930,7 @@ static ssize_t fsl_qspi_read(struct spi_nor *nor, loff_t from, len); *retlen += len; - return 0; + return len; } static int fsl_qspi_erase(struct spi_nor *nor, loff_t offs)