Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5722560ybv; Tue, 18 Feb 2020 02:46:15 -0800 (PST) X-Google-Smtp-Source: APXvYqw7zk8Binmu7kJmh4oWnDJywy/eIz1eSODtHevQIJ4Zq0DdHWFiFTOVLtGdC9GtqKN0aWTu X-Received: by 2002:aca:45c1:: with SMTP id s184mr811698oia.158.1582022775676; Tue, 18 Feb 2020 02:46:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582022775; cv=none; d=google.com; s=arc-20160816; b=rKgzLJvWlpNk36qFzMfSs8tyiv+RXCF3agYS5EIEfj5HN9asKKubXt87P/P5+CHWeK UpV6DHodeuS2MuNbBSJdLuOTIcikOmAxhInQtmMHqE/e/5xXDgJKGQ73bWS4nEocUN/A fwUn7axL3kMI/LXM0fNVl8mdRDGXOf80sMfq5btafpNTz0VAmhADKz7x8GdKrW4vFN4Q Ku2xSUnkSmubxtMkvi1S8TciYuLzgzgLMmj2gbW6GR4CaCYzwBqukG1J+WBez4jzG2pO Owi8XQiFGSYmWiK/qRNLSMf5SI8kNSWJ4szi5BK2kfkJuuODJPvN4hwQIHvdiKTOUO1Y BnRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=s6s5IRLfOOlyLU1ZGv1RAXrRfUjUb4WJbw3cMorqsAQ=; b=oirTXuXdD7pHjw3dUYeTDI1UhiXHv2M5W3+Yilunx7G9KfefUA6wgx3L8CJqfPUHEO /pLvcUEm7FjdV5kh8q6rp3oel/n6mgl2epiUjFEwJEG8s7p5L80Cl84HlDKAOueLcQnX AyfCyRO1/YQcWot+IK6m0s6K94Gx6zPQZ2s1O/P0CPpxdksRm7ZYIas62XZ10E4IJihV mDS4cD4TZSiEUuBwKvFXvqABVKELO+XtuAwPPLFm1QoH56CIYSyl+tWvceq3kMxOk3Dq x8ebfcx4cJtZV76CfaRAFnhji3qMMXZH8tXjM22LqQgQV1l2wZbqEDqRZn0wqHhiFGkS zDUQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m19si1489650otr.18.2020.02.18.02.46.02; Tue, 18 Feb 2020 02:46:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726444AbgBRKp4 convert rfc822-to-8bit (ORCPT + 99 others); Tue, 18 Feb 2020 05:45:56 -0500 Received: from relay2-d.mail.gandi.net ([217.70.183.194]:59775 "EHLO relay2-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726360AbgBRKpz (ORCPT ); Tue, 18 Feb 2020 05:45:55 -0500 X-Originating-IP: 90.76.211.102 Received: from xps13 (lfbn-tou-1-1151-102.w90-76.abo.wanadoo.fr [90.76.211.102]) (Authenticated sender: miquel.raynal@bootlin.com) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id B9E5140017; Tue, 18 Feb 2020 10:45:53 +0000 (UTC) Date: Tue, 18 Feb 2020 11:45:53 +0100 From: Miquel Raynal To: Piotr Sroka Cc: Kazuhiro Kasai , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Vignesh Raghavendra , , Subject: Re: [PATCH 2/4] mtd: rawnand: cadence: fix calculating avaialble oob size Message-ID: <20200218114537.723436b3@xps13> In-Reply-To: <1581328530-29966-2-git-send-email-piotrs@cadence.com> References: <1581328530-29966-1-git-send-email-piotrs@cadence.com> <1581328530-29966-2-git-send-email-piotrs@cadence.com> Organization: Bootlin X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Piotr, Piotr Sroka wrote on Mon, 10 Feb 2020 10:55:26 +0100: There is a typo in the title (available). > Previously ecc_sector size was used for calculation but its value > was not yet known. Can we rework a little bit this? What about: The value of cdns_chip->sector_count is not known at the moment of the derivation of ecc_size, leading to a zero value. Fix this by assigning ecc_size later in the code. Also, I think it deserves a Fixes/Cc:stable tag! > > Signed-off-by: Piotr Sroka > --- > drivers/mtd/nand/raw/cadence-nand-controller.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/mtd/nand/raw/cadence-nand-controller.c b/drivers/mtd/nand/raw/cadence-nand-controller.c > index 5063a8b493a4..2ebfd0934739 100644 > --- a/drivers/mtd/nand/raw/cadence-nand-controller.c > +++ b/drivers/mtd/nand/raw/cadence-nand-controller.c > @@ -2595,7 +2595,7 @@ int cadence_nand_attach_chip(struct nand_chip *chip) > { > struct cdns_nand_ctrl *cdns_ctrl = to_cdns_nand_ctrl(chip->controller); > struct cdns_nand_chip *cdns_chip = to_cdns_nand_chip(chip); > - u32 ecc_size = cdns_chip->sector_count * chip->ecc.bytes; > + u32 ecc_size; > struct mtd_info *mtd = nand_to_mtd(chip); > int ret; > > @@ -2634,6 +2634,7 @@ int cadence_nand_attach_chip(struct nand_chip *chip) > /* Error correction configuration. */ > cdns_chip->sector_size = chip->ecc.size; > cdns_chip->sector_count = mtd->writesize / cdns_chip->sector_size; > + ecc_size = cdns_chip->sector_count * chip->ecc.bytes; > > cdns_chip->avail_oob_size = mtd->oobsize - ecc_size; > Thanks, Miquèl