Message ID | 20221229181526.53766-5-samuel@sholland.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2529919wrt; Thu, 29 Dec 2022 10:16:52 -0800 (PST) X-Google-Smtp-Source: AMrXdXuV+KCV6RJTc5iV0mThhteUutOQPpScNlUznCjc3br+w3p2EqBL+PHUlRfNEQzMtYW8SeEj X-Received: by 2002:a05:6a20:d909:b0:a7:8919:3312 with SMTP id jd9-20020a056a20d90900b000a789193312mr36708493pzb.29.1672337811780; Thu, 29 Dec 2022 10:16:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672337811; cv=none; d=google.com; s=arc-20160816; b=wUw3D0zSnwZxct9jbwIfraQnQJtxRRATBvthR+6jPoqz3YErIxAzYnuC2MWdJLV81R j4d/SvUQH5RbQpYC+1SioCW7SSAL/lRGYiwlmt1kCgkoYyw8vy+LghwMNVPdfe0bcZM8 a94VVwH27ana+qa6OZkczcIfL3YPLvXrng5TGKeFqp9xOJAwk2rnq0ni2NO4RfqJ6FXp 5E7+u9YhriEpf226oG+CO4nhAKaHE9ZPkTiAZ92dO4QFiyIv+JxaXKftxU3jw6c9MR/Y w+DTy0SATZiVEe21KbyrRgNFb52Ss6gGN2Ob7aJnT2i7qnOeYCxF4LZNIvj83WLHD2Jf xzPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :feedback-id:dkim-signature:dkim-signature; bh=+yowLKRJXG5KC8guU+L3zS9PmXyXPUwHqs5jAcrH1n8=; b=FSoynPNHeCXF3A6vRpwWNSQdr2xVxxP+GGjC9qg3GUSu1dQZhx/xNayiigjj2vwFqX TX+G9vpSwFW8dUmENcVMyMUJn5+CYqLnoo8v46/q3ZO5QvA4OnrABEEWci6sd2VCRji3 XINpDEu7x/R+rzyh/9KEx+Enex9q0y0yFHnNUdAdc7w2axR1USgFpCb+LSFykyN40ASt I8AKOcPZL5W7I7oJ3aGxBmykHkGF+O8FnrnCUduHqRlYP8LCaZTXHq/AExmmBZWEYHEr UzpgoKVhOfP7ysrekManMvTfWuf+TfUyA9lNMfETRdhsLpG/uRCDHc8BYONPwDcADqZL x1zA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sholland.org header.s=fm3 header.b=NjMFxRZ+; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=HsRR2B5a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sholland.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j4-20020a170902758400b00186dcc37df6si14721996pll.616.2022.12.29.10.16.39; Thu, 29 Dec 2022 10:16:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@sholland.org header.s=fm3 header.b=NjMFxRZ+; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=HsRR2B5a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sholland.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233685AbiL2SPx (ORCPT <rfc822;eddaouddi.ayoub@gmail.com> + 99 others); Thu, 29 Dec 2022 13:15:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233880AbiL2SPl (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 29 Dec 2022 13:15:41 -0500 Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10D8615F00 for <linux-kernel@vger.kernel.org>; Thu, 29 Dec 2022 10:15:40 -0800 (PST) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id B11983200900; Thu, 29 Dec 2022 13:15:39 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Thu, 29 Dec 2022 13:15:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1672337739; x=1672424139; bh=+y owLKRJXG5KC8guU+L3zS9PmXyXPUwHqs5jAcrH1n8=; b=NjMFxRZ+QZD9UGucgT 3k9PuEN2/mDP+IB9eAtBS4ykWeu3aXi6YvfZnOxMtUnM1k7dgBKbNZizRiniCreK mPgqELgFWGEJClE7k5a87NVie2KGW6aAQx40LpRKUqa+kzRcsIBF23tlE774DSi4 cZMcDQqCclZaElXyCMWYL3wVALtaHcsN/YDTCd959c934SQbP4LFWvtyc6oy09Oo v89h0GCKI0H7jlEALyIbgE2JSjFVr0yL7ys6pPfMh9tw81UI3OI9rDhzRttOsqgd sGw4Wre5b8ZronJeofJjKupxEyPgIfYzOiJ7UDD7d+YtSguUM7XH1PGI9S5WF3KP JDnQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1672337739; x=1672424139; bh=+yowLKRJXG5KC 8guU+L3zS9PmXyXPUwHqs5jAcrH1n8=; b=HsRR2B5aqf2cMTQNa8s3obOULDCwU bI7/qnGSV02TRSrCAgVe0N4/6UQ8h4pFful0gd4Wqyeg9+p+huQOvV9XziiHe112 F4xzeVVR2DMMxF6PARc5xNGmRwBpt2y5I1e4ZZPalrc1AtF4ntbp8tZYIx4v2a/e rF7HBzuUW907QMkL+f3PHYX8EYs8HSMl7NZBm89ofI33eD4e7d2Ixi17/i6CwCNQ 3csDvmhGvWlNn+dd0gY1HbSdeZHL7PHak6q8tfoJZvbzrVqRRqA+dX02KXwYR/V+ MDF/WNpCxdZ7JfOTgruRnXw7smsOMFdaIL70xsFVsBEPqqpKVRkixbinQ== X-ME-Sender: <xms:StmtYwrokwmQYuQy44RdrPQnpemGll52UZdE7k_4OFJcjRh4olNNBg> <xme:StmtY2rkoNORgELQHLdoDBOV6Jyk2aavF8THhVx7yBgneN4FEtwdxp3XN0i_-Q45w ZadEQjVZjBPK-YaBA> X-ME-Received: <xmr:StmtY1PV0B2ld1tNQCnJYXmWeGmGZcmzNFuqA7aBUVk_XH7n85J5_hMfMM-AU2D1mKaMaj1tIGFNmA_3QXD4ryuCm_sxD0-aa7HBvgBvjiliFOXbYHEOpgYT3PCCSet1u_xXpw> X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrieeggdduudduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepufgrmhhu vghlucfjohhllhgrnhguuceoshgrmhhuvghlsehshhholhhlrghnugdrohhrgheqnecugg ftrfgrthhtvghrnhepudekteeuudehtdelteevgfduvddvjefhfedulefgudevgeeghefg udefiedtveetnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homhepshgrmhhuvghlsehshhholhhlrghnugdrohhrgh X-ME-Proxy: <xmx:StmtY37S-jgSBf96ObzW9Qrf94pnqgrt6P_IfhoGGTjZVH1FpMmyJg> <xmx:StmtY_6XVCh8lHyOxISSUzSUfMMAugtijEMmdMD-qPfmHCYwKle5_A> <xmx:StmtY3iHoQ-ocKnp_4-JlU9O20lPycZAuWvgUonrUPHWlLbYCcwipA> <xmx:S9mtY8wlKZb7T76vtWdv6SPaoaOeJ46WGHncgTwEok1NDYIMGFjWmQ> Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 29 Dec 2022 13:15:38 -0500 (EST) From: Samuel Holland <samuel@sholland.org> To: Miquel Raynal <miquel.raynal@bootlin.com>, Richard Weinberger <richard@nod.at>, Vignesh Raghavendra <vigneshr@ti.com>, Chen-Yu Tsai <wens@csie.org>, Jernej Skrabec <jernej.skrabec@gmail.com> Cc: Boris Brezillon <bbrezillon@kernel.org>, Samuel Holland <samuel@sholland.org>, Brian Norris <computersforpeace@gmail.com>, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: [PATCH 4/7] mtd: rawnand: sunxi: Fix ECC strength maximization Date: Thu, 29 Dec 2022 12:15:23 -0600 Message-Id: <20221229181526.53766-5-samuel@sholland.org> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221229181526.53766-1-samuel@sholland.org> References: <20221229181526.53766-1-samuel@sholland.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753573293091182980?= X-GMAIL-MSGID: =?utf-8?q?1753573293091182980?= |
Series |
mtd: rawnand: sunxi: Bug fixes and cleanup
|
|
Commit Message
Samuel Holland
Dec. 29, 2022, 6:15 p.m. UTC
This is already accounted for in the subtraction for OOB, since the BBM
overlaps the first OOB dword. With this change, the driver picks the
same ECC strength as the vendor driver.
Fixes: 4796d8655915 ("mtd: nand: sunxi: Support ECC maximization")
Signed-off-by: Samuel Holland <samuel@sholland.org>
---
drivers/mtd/nand/raw/sunxi_nand.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
Comments
Hi Samuel, samuel@sholland.org wrote on Thu, 29 Dec 2022 12:15:23 -0600: > This is already accounted for in the subtraction for OOB, since the BBM > overlaps the first OOB dword. With this change, the driver picks the > same ECC strength as the vendor driver. > > Fixes: 4796d8655915 ("mtd: nand: sunxi: Support ECC maximization") > Signed-off-by: Samuel Holland <samuel@sholland.org> > --- > > drivers/mtd/nand/raw/sunxi_nand.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c > index 1bddeb1be66f..1ecf2cee343b 100644 > --- a/drivers/mtd/nand/raw/sunxi_nand.c > +++ b/drivers/mtd/nand/raw/sunxi_nand.c > @@ -1643,8 +1643,7 @@ static int sunxi_nand_hw_ecc_ctrl_init(struct nand_chip *nand, > ecc->size = 1024; > nsectors = mtd->writesize / ecc->size; > > - /* Reserve 2 bytes for the BBM */ > - bytes = (mtd->oobsize - 2) / nsectors; > + bytes = mtd->oobsize / nsectors; I'm sorry but I don't think we can make this work. This change would break all existing users... > > /* 4 non-ECC bytes are added before each ECC bytes section */ > bytes -= 4; Thanks, Miquèl
Hi Miquèl, On 1/2/23 03:11, Miquel Raynal wrote: > Hi Samuel, > > samuel@sholland.org wrote on Thu, 29 Dec 2022 12:15:23 -0600: > >> This is already accounted for in the subtraction for OOB, since the BBM >> overlaps the first OOB dword. With this change, the driver picks the >> same ECC strength as the vendor driver. >> >> Fixes: 4796d8655915 ("mtd: nand: sunxi: Support ECC maximization") >> Signed-off-by: Samuel Holland <samuel@sholland.org> >> --- >> >> drivers/mtd/nand/raw/sunxi_nand.c | 3 +-- >> 1 file changed, 1 insertion(+), 2 deletions(-) >> >> diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c >> index 1bddeb1be66f..1ecf2cee343b 100644 >> --- a/drivers/mtd/nand/raw/sunxi_nand.c >> +++ b/drivers/mtd/nand/raw/sunxi_nand.c >> @@ -1643,8 +1643,7 @@ static int sunxi_nand_hw_ecc_ctrl_init(struct nand_chip *nand, >> ecc->size = 1024; >> nsectors = mtd->writesize / ecc->size; >> >> - /* Reserve 2 bytes for the BBM */ >> - bytes = (mtd->oobsize - 2) / nsectors; >> + bytes = mtd->oobsize / nsectors; > > I'm sorry but I don't think we can make this work. This change would > break all existing users... OK, it is not too much of an issue because I can manually specify the ECC parameters in the devicetree. Do you think it makes sense to fix this when adding new hardware variants/compatible strings? Regards, Samuel
Hi Samuel, samuel@sholland.org wrote on Mon, 2 Jan 2023 09:59:29 -0600: > Hi Miquèl, > > On 1/2/23 03:11, Miquel Raynal wrote: > > Hi Samuel, > > > > samuel@sholland.org wrote on Thu, 29 Dec 2022 12:15:23 -0600: > > > >> This is already accounted for in the subtraction for OOB, since the BBM > >> overlaps the first OOB dword. With this change, the driver picks the > >> same ECC strength as the vendor driver. > >> > >> Fixes: 4796d8655915 ("mtd: nand: sunxi: Support ECC maximization") > >> Signed-off-by: Samuel Holland <samuel@sholland.org> > >> --- > >> > >> drivers/mtd/nand/raw/sunxi_nand.c | 3 +-- > >> 1 file changed, 1 insertion(+), 2 deletions(-) > >> > >> diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c > >> index 1bddeb1be66f..1ecf2cee343b 100644 > >> --- a/drivers/mtd/nand/raw/sunxi_nand.c > >> +++ b/drivers/mtd/nand/raw/sunxi_nand.c > >> @@ -1643,8 +1643,7 @@ static int sunxi_nand_hw_ecc_ctrl_init(struct nand_chip *nand, > >> ecc->size = 1024; > >> nsectors = mtd->writesize / ecc->size; > >> > >> - /* Reserve 2 bytes for the BBM */ > >> - bytes = (mtd->oobsize - 2) / nsectors; > >> + bytes = mtd->oobsize / nsectors; > > > > I'm sorry but I don't think we can make this work. This change would > > break all existing users... > > OK, it is not too much of an issue because I can manually specify the > ECC parameters in the devicetree. Do you think it makes sense to fix > this when adding new hardware variants/compatible strings? Actually, looking at the code again, I don't get how the above diff could be valid. The "maximize strength" logic (in which this diff is) looks for the biggest region to store ECC bytes. These bytes cannot be stored on the BBM, which "mtd->oobsize - 2" tries to avoid, so we cannot get rid of this. Thanks, Miquèl
Hi Miquèl, On 1/2/23 10:45, Miquel Raynal wrote: >>>> This is already accounted for in the subtraction for OOB, since the BBM >>>> overlaps the first OOB dword. With this change, the driver picks the >>>> same ECC strength as the vendor driver. >>>> >>>> Fixes: 4796d8655915 ("mtd: nand: sunxi: Support ECC maximization") >>>> Signed-off-by: Samuel Holland <samuel@sholland.org> >>>> --- >>>> >>>> drivers/mtd/nand/raw/sunxi_nand.c | 3 +-- >>>> 1 file changed, 1 insertion(+), 2 deletions(-) >>>> >>>> diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c >>>> index 1bddeb1be66f..1ecf2cee343b 100644 >>>> --- a/drivers/mtd/nand/raw/sunxi_nand.c >>>> +++ b/drivers/mtd/nand/raw/sunxi_nand.c >>>> @@ -1643,8 +1643,7 @@ static int sunxi_nand_hw_ecc_ctrl_init(struct nand_chip *nand, >>>> ecc->size = 1024; >>>> nsectors = mtd->writesize / ecc->size; >>>> >>>> - /* Reserve 2 bytes for the BBM */ >>>> - bytes = (mtd->oobsize - 2) / nsectors; >>>> + bytes = mtd->oobsize / nsectors; >>> >>> I'm sorry but I don't think we can make this work. This change would >>> break all existing users... >> >> OK, it is not too much of an issue because I can manually specify the >> ECC parameters in the devicetree. Do you think it makes sense to fix >> this when adding new hardware variants/compatible strings? > > Actually, looking at the code again, I don't get how the above diff > could be valid. The "maximize strength" logic (in which this diff is) > looks for the biggest region to store ECC bytes. These bytes cannot > be stored on the BBM, which "mtd->oobsize - 2" tries to avoid, so we > cannot get rid of this. Right, we cannot overlap the BBM, but the BBM is accounted for in the line below: /* 4 non-ECC bytes are added before each ECC bytes section */ bytes -= 4; Normally those 4 bytes are all free OOB, but for the first ECC step, those are split into 2 free bytes and 2 BBM bytes: /* * The first 2 bytes are used for BB markers, hence we * only have 2 bytes available in the first user data * section. */ if (!section && ecc->engine_type == NAND_ECC_ENGINE_TYPE_ON_HOST) { oobregion->offset = 2; oobregion->length = 2; return 0; } So if we subtract 4 bytes for the each free OOB area, including the first one, and also subtract 2 bytes for the BBM, we are double-counting the BBM. I should have made my commit message clearer. But I am going to drop this patch anyway. Regards, Samuel
Hi Samuel, samuel@sholland.org wrote on Mon, 2 Jan 2023 11:06:20 -0600: > Hi Miquèl, > > On 1/2/23 10:45, Miquel Raynal wrote: > >>>> This is already accounted for in the subtraction for OOB, since the BBM > >>>> overlaps the first OOB dword. With this change, the driver picks the > >>>> same ECC strength as the vendor driver. > >>>> > >>>> Fixes: 4796d8655915 ("mtd: nand: sunxi: Support ECC maximization") > >>>> Signed-off-by: Samuel Holland <samuel@sholland.org> > >>>> --- > >>>> > >>>> drivers/mtd/nand/raw/sunxi_nand.c | 3 +-- > >>>> 1 file changed, 1 insertion(+), 2 deletions(-) > >>>> > >>>> diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c > >>>> index 1bddeb1be66f..1ecf2cee343b 100644 > >>>> --- a/drivers/mtd/nand/raw/sunxi_nand.c > >>>> +++ b/drivers/mtd/nand/raw/sunxi_nand.c > >>>> @@ -1643,8 +1643,7 @@ static int sunxi_nand_hw_ecc_ctrl_init(struct nand_chip *nand, > >>>> ecc->size = 1024; > >>>> nsectors = mtd->writesize / ecc->size; > >>>> > >>>> - /* Reserve 2 bytes for the BBM */ > >>>> - bytes = (mtd->oobsize - 2) / nsectors; > >>>> + bytes = mtd->oobsize / nsectors; > >>> > >>> I'm sorry but I don't think we can make this work. This change would > >>> break all existing users... > >> > >> OK, it is not too much of an issue because I can manually specify the > >> ECC parameters in the devicetree. Do you think it makes sense to fix > >> this when adding new hardware variants/compatible strings? > > > > Actually, looking at the code again, I don't get how the above diff > > could be valid. The "maximize strength" logic (in which this diff is) > > looks for the biggest region to store ECC bytes. These bytes cannot > > be stored on the BBM, which "mtd->oobsize - 2" tries to avoid, so we > > cannot get rid of this. > > Right, we cannot overlap the BBM, but the BBM is accounted for in the > line below: > > /* 4 non-ECC bytes are added before each ECC bytes section */ > bytes -= 4; > > Normally those 4 bytes are all free OOB, but for the first ECC step, > those are split into 2 free bytes and 2 BBM bytes: > > /* > * The first 2 bytes are used for BB markers, hence we > * only have 2 bytes available in the first user data > * section. > */ > if (!section && ecc->engine_type == NAND_ECC_ENGINE_TYPE_ON_HOST) { > oobregion->offset = 2; > oobregion->length = 2; > > return 0; > } > > So if we subtract 4 bytes for the each free OOB area, including the > first one, and also subtract 2 bytes for the BBM, we are double-counting > the BBM. I should have made my commit message clearer. But I am going to > drop this patch anyway. Ah, yes, you are absolutely right, then. Thanks, Miquèl
diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c index 1bddeb1be66f..1ecf2cee343b 100644 --- a/drivers/mtd/nand/raw/sunxi_nand.c +++ b/drivers/mtd/nand/raw/sunxi_nand.c @@ -1643,8 +1643,7 @@ static int sunxi_nand_hw_ecc_ctrl_init(struct nand_chip *nand, ecc->size = 1024; nsectors = mtd->writesize / ecc->size; - /* Reserve 2 bytes for the BBM */ - bytes = (mtd->oobsize - 2) / nsectors; + bytes = mtd->oobsize / nsectors; /* 4 non-ECC bytes are added before each ECC bytes section */ bytes -= 4;