From patchwork Thu Feb 22 10:13:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Fietkau X-Patchwork-Id: 876557 X-Patchwork-Delegate: cyrille.pitchen@atmel.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="MR0tXmOz"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=nbd.name header.i=@nbd.name header.b="OhONzu1W"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zn9FL0zq9z9s7T for ; Thu, 22 Feb 2018 21:14:30 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date:Subject:To: From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=4/IT6zpqMLHGzb+0K8ZtPyOn6vIVKhUQ8EvpcQqKumo=; b=MR0tXmOzHMstH2 bcQiX7MyOO7e9vcBKMagRHAm0KXpi10B51Jtuz/yxpUqsRj2qsZAUVbPElIetDw8W9vlmrhlH3qLy fPRYmWt4GFcS4Y/pV5QNt6z/r7FUKVflTQhsXVLa7tBzbV+AAwOhoJfuAOso78a+D2+/iBqI2rIRU reBY/rWo/3TWnBN+i/5fZhx6hinT8h8kRWYNTp85eFMfq78rLXWYbgoYD6RCI1QUd1DTiUgroVWQY vZvjn6jUpVtjSh5LXuVK2LXBnUE8FrkoIdPXaTI9jAy9JrTjppqN2iilfkk+l4CcNmw4CT5KGVNa4 kZDjINdttLJ1Z/m+C8cw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eontH-0000kc-KM; Thu, 22 Feb 2018 10:14:15 +0000 Received: from nbd.name ([2a01:4f8:221:3d45::2]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eontE-0000hj-4b for linux-mtd@lists.infradead.org; Thu, 22 Feb 2018 10:14:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Ix6ZFn46oGLu242TYeN4GOKuDSeSZt6/zfdudTml7O8=; b=OhONzu1Wl/zlM6wFDMPTO55eOM h1gTC7sJyLD78RoVnGAa4oGzYiz4rgyTwZ0wLfNyZ8gRhKiPp6a/RENgA7vyv7WlNzJbvJ1JxRfql afreMXA6wsUEO3gmKPrfX8/vRNkQpnxxbC3AJUpjTes1hw7WykChUxAkEjtKwXQ6waZk=; Received: by maeck.lan (Postfix, from userid 501) id EEAEF1370D82; Thu, 22 Feb 2018 11:13:58 +0100 (CET) From: Felix Fietkau To: linux-mtd@lists.infradead.org Subject: [PATCH] mtd: spi-nor: allow NOR driver to write fewer bytes than requested Date: Thu, 22 Feb 2018 11:13:58 +0100 Message-Id: <20180222101358.20035-1-nbd@nbd.name> X-Mailer: git-send-email 2.14.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180222_021412_346220_E2F70216 X-CRM114-Status: UNSURE ( 8.67 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -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_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The write size can be constrained by the maximum message/transfer size of the SPI controller. Only check for ret = 0 to avoid an infinite loop. Signed-off-by: Felix Fietkau --- drivers/mtd/spi-nor/spi-nor.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index 61de4cc3bd7f..c60802eb6aa3 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -1392,7 +1392,7 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len, write_enable(nor); ret = nor->write(nor, addr, page_remain, buf + i); - if (ret < 0) + if (ret <= 0) goto write_err; written = ret; @@ -1401,13 +1401,6 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len, goto write_err; *retlen += written; i += written; - if (written != page_remain) { - dev_err(nor->dev, - "While writing %zu bytes written %zd bytes\n", - page_remain, written); - ret = -EIO; - goto write_err; - } } write_err: