From patchwork Wed Jan 24 22:49:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 10183231 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 9CC1D60233 for ; Wed, 24 Jan 2018 22:49:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 81BE92877B for ; Wed, 24 Jan 2018 22:49:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 75701287B2; Wed, 24 Jan 2018 22:49:58 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6E1E82877B for ; Wed, 24 Jan 2018 22:49:57 +0000 (UTC) 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:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=WGaIG1+ohyWrMoYRX/vEJQjabxJiI7JBpWFieAh5JFA=; b=Vrt lt8xb4dB68hRqQhuQKt2jxQ8d9uz6lbkpBTi6kLbObmiYyQoir3zfWL6c6M65ejbt2TB9KqGgvAFj j2yY7SyI7TUKEKYok6qOAY4XKfPhgYKmigJpvKoZsRx+O1QF8xVJjgImsZIV8i2VQ8aw9OPY1Mszr t/wDgi7RJXPQJRvVqjUO+iCuRk1CClk1QaTmTa1n0E/EF0ejTlTBdxsxvNNr1W64ub3Ud38UZq4rg FXecKsLe18EvaB8qa5WfvBf5ta+aQ8LP+ch1hgaFFburDRD/g1zXqFld+8812zghuphJ2VORKEB3/ 2XrdDCHQOpw17EdHH/Rt2D+5evDQL5g==; 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 1eeTre-00037F-0c; Wed, 24 Jan 2018 22:49:54 +0000 Received: from mail.free-electrons.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eeTra-0002om-32; Wed, 24 Jan 2018 22:49:52 +0000 Received: by mail.free-electrons.com (Postfix, from userid 110) id D46992075C; Wed, 24 Jan 2018 23:49:38 +0100 (CET) Received: from localhost.localdomain (unknown [91.224.148.103]) by mail.free-electrons.com (Postfix) with ESMTPSA id 397A0203B4; Wed, 24 Jan 2018 23:49:38 +0100 (CET) From: Miquel Raynal To: Boris Brezillon , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Cyrille Pitchen , Maxime Ripard , Chen-Yu Tsai Subject: [PATCH] mtd: nand: sunxi: Fix ECC strength choice Date: Wed, 24 Jan 2018 23:49:31 +0100 Message-Id: <20180124224931.14392-1-miquel.raynal@free-electrons.com> X-Mailer: git-send-email 2.11.0 X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mtd@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Miquel Raynal MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP When the requested ECC strength does not exactly match the strengths supported by the ECC engine, the driver is selecting the closest strength meeting the 'selected_strength > requested_strength' constraint. Fix the fact that, in this particular case, ecc->strength value was not updated to match the 'selected_strength'. For instance, one can encounter this issue when no ECC requirement is filled in the device tree while the NAND chip minimum requirement is not a strength/step_size combo natively supported by the ECC engine. Suggested-by: Boris Brezillon Signed-off-by: Miquel Raynal --- drivers/mtd/nand/sunxi_nand.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c index 82244be3e766..958974821582 100644 --- a/drivers/mtd/nand/sunxi_nand.c +++ b/drivers/mtd/nand/sunxi_nand.c @@ -1853,8 +1853,14 @@ static int sunxi_nand_hw_common_ecc_ctrl_init(struct mtd_info *mtd, /* Add ECC info retrieval from DT */ for (i = 0; i < ARRAY_SIZE(strengths); i++) { - if (ecc->strength <= strengths[i]) + if (ecc->strength <= strengths[i]) { + /* + * Update ecc->strength value with the actual strength + * that will be used by the ECC engine. + */ + ecc->strength = strengths[i]; break; + } } if (i >= ARRAY_SIZE(strengths)) {