Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp82287imm; Wed, 25 Jul 2018 23:08:41 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfSl/bXxboO/GWznW1slwvX6H//BWuiJ0p9h/BV7oJ8SHTxpV9C5O80/yHqv5mHhBTaHkWS X-Received: by 2002:a63:cb04:: with SMTP id p4-v6mr604734pgg.197.1532585320965; Wed, 25 Jul 2018 23:08:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532585320; cv=none; d=google.com; s=arc-20160816; b=Z6AbF4/DX2SdZN6a/aER+ZJXcsPB7XrBXmJtLUbWnc6Mx4dBni9HzM7s4HLQ6thOoE g3kIefyxG97/qR7M9DSG6+ife/tjMkSTNLAeq2iOqVns53eWylXzyeCU53Alrsx/VVrO YVcMXM/i4wVYRrGaZscrW77pE9Q5YKSF/5A58LrjLDwg5OyZkNMczEtNzPOy9Knswb2q Xl/XY5dG5IYAmqZnp3EgnEcBSH+uQBGrVaVvdLZfvpfK8KqQ8SKG0vvWIbr/KLJfWT/Y SkuOBX1RewLV2AYOvJiKcmCIUe8pXt+Gusn8nP5vOIKnCItmDcbCojnbehLn7sVUsn4n cIKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :references:in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=c8dXzUxllmnpzzN6l8XBvMaUmwuBdD67y+hPVj7U4qY=; b=UTTz6NkkDKCu6/IWn3uNEtJpL/XJq4FWbe1xxqOOEOrHs3HJJ02vvMWfJ6u1wAg/yY fVpo+GUJ1VcCJtjxFzfPbGtVBkbhDfNdyXhRATfYQV6PSW3OhQJ35WtYU0++awMHDQ1D nR/asNvoUVCdqdkiI/ueauOTPenUMEHQfQSslzmxr+zGnf/Tm/oL4ZxOi943PtLLueWi FLQtKLO1UnGZO2WKrsNyIHPR4TecEbAjbNhgNz1ac/YAfQjUDYC4lFC5GQqJeQv2ImQE t/GU4PpenanSrTjX7n9luG8nIsWimLtFOfxNNg5yTMUtKnvv2dUr9vpsgJ7LVJG7YDMo C+JQ== 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 r1-v6si495754plb.172.2018.07.25.23.08.26; Wed, 25 Jul 2018 23:08:40 -0700 (PDT) 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 S1728718AbeGZHWK (ORCPT + 99 others); Thu, 26 Jul 2018 03:22:10 -0400 Received: from Mailgw01.mediatek.com ([1.203.163.78]:25281 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726837AbeGZHWJ (ORCPT ); Thu, 26 Jul 2018 03:22:09 -0400 X-UUID: 4e523ee0688f4562bb9996d307ae7499-20180726 Received: from mtkcas35.mediatek.inc [(172.27.4.250)] by mailgw01.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLS) with ESMTP id 1452920136; Thu, 26 Jul 2018 14:06:43 +0800 Received: from MTKCAS36.mediatek.inc (172.27.4.186) by MTKMBS32N1.mediatek.inc (172.27.4.71) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Thu, 26 Jul 2018 14:06:42 +0800 Received: from [10.17.3.153] (10.17.3.153) by MTKCAS36.mediatek.inc (172.27.4.170) with Microsoft SMTP Server id 15.0.1210.3 via Frontend Transport; Thu, 26 Jul 2018 14:06:41 +0800 Message-ID: <1532585201.10234.9.camel@mhfsdcap03> Subject: Re: [PATCH v4 14/35] mtd: rawnand: mtk: convert driver to nand_scan() From: xiaolei li To: Boris Brezillon CC: Miquel Raynal , Wenyou Yang , Josh Wu , "Tudor Ambarus" , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , "Nicolas Ferre" , Alexandre Belloni , Kamal Dasu , Masahiro Yamada , Han Xu , Harvey Hunt , Vladimir Zapolskiy , Sylvain Lemieux , Matthias Brugger , Maxime Ripard , Chen-Yu Tsai , Marc Gonzalez , "Mans Rullgard" , Stefan Agner , , , , , Date: Thu, 26 Jul 2018 14:06:41 +0800 In-Reply-To: <20180721191004.26fc9290@bbrezillon> References: <20180720151527.16038-1-miquel.raynal@bootlin.com> <20180720151527.16038-15-miquel.raynal@bootlin.com> <20180721191004.26fc9290@bbrezillon> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3-0ubuntu6 Content-Transfer-Encoding: 7bit MIME-Version: 1.0 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 2018-07-21 at 19:10 +0200, Boris Brezillon wrote: > On Fri, 20 Jul 2018 17:15:06 +0200 > Miquel Raynal wrote: > > > Two helpers have been added to the core to make ECC-related > > configuration between the detection phase and the final NAND scan. Use > > these hooks and convert the driver to just use nand_scan() instead of > > both nand_scan_ident() and nand_scan_tail(). > > > > Signed-off-by: Miquel Raynal > > --- > > drivers/mtd/nand/raw/mtk_nand.c | 75 ++++++++++++++++++++++++----------------- > > 1 file changed, 44 insertions(+), 31 deletions(-) > > > > diff --git a/drivers/mtd/nand/raw/mtk_nand.c b/drivers/mtd/nand/raw/mtk_nand.c > > index 7bc6be3f6ec0..967418f945ea 100644 > > --- a/drivers/mtd/nand/raw/mtk_nand.c > > +++ b/drivers/mtd/nand/raw/mtk_nand.c > > @@ -1250,13 +1250,54 @@ static int mtk_nfc_ecc_init(struct device *dev, struct mtd_info *mtd) > > return 0; > > } > > > > +static int mtk_nfc_attach_chip(struct nand_chip *chip) > > +{ > > + struct mtd_info *mtd = nand_to_mtd(chip); > > + struct device *dev = mtd->dev.parent; > > + struct mtk_nfc *nfc = nand_get_controller_data(chip); > > + struct mtk_nfc_nand_chip *mtk_nand = to_mtk_nand(chip); > > + int len; > > + int ret; > > + > > + if (chip->options & NAND_BUSWIDTH_16) { > > + dev_err(dev, "16bits buswidth not supported"); > > + return -EINVAL; > > + } > > + > > + /* store bbt magic in page, cause OOB is not protected */ > > + if (chip->bbt_options & NAND_BBT_USE_FLASH) > > + chip->bbt_options |= NAND_BBT_NO_OOB; > > + > > + ret = mtk_nfc_ecc_init(dev, mtd); > > + if (ret) > > + return ret; > > + > > + ret = mtk_nfc_set_spare_per_sector(&mtk_nand->spare_per_sector, mtd); > > + if (ret) > > + return ret; > > + > > + mtk_nfc_set_fdm(&mtk_nand->fdm, mtd); > > + mtk_nfc_set_bad_mark_ctl(&mtk_nand->bad_mark, mtd); > > + > > + len = mtd->writesize + mtd->oobsize; > > + nfc->buffer = devm_kzalloc(dev, len, GFP_KERNEL); > > + if (!nfc->buffer) > > + return -ENOMEM; > > + > > + return 0; > > +} > > + > > +static const struct nand_controller_ops mtk_nfc_controller_ops = { > > + .attach_chip = mtk_nfc_attach_chip, > > +}; > > + > > static int mtk_nfc_nand_chip_init(struct device *dev, struct mtk_nfc *nfc, > > struct device_node *np) > > { > > struct mtk_nfc_nand_chip *chip; > > struct nand_chip *nand; > > struct mtd_info *mtd; > > - int nsels, len; > > + int nsels; > > u32 tmp; > > int ret; > > int i; > > @@ -1287,6 +1328,7 @@ static int mtk_nfc_nand_chip_init(struct device *dev, struct mtk_nfc *nfc, > > > > nand = &chip->nand; > > nand->controller = &nfc->controller; > > + nand->controller->ops = &mtk_nfc_controller_ops; > > Just like for the marvell driver, this assignment should be moved here > [1]. Agree to this. > Also, it looks like this driver is open-coding > nand_controller_init(), probably something we should fix (in a separate > patch). May I ask if you mean driver should use nand_hw_control_init helper to do controller_init? Thanks, Xiaolei > > With this fixed: > > Reviewed-by: Boris Brezillon > > > > > nand_set_flash_node(nand, np); > > nand_set_controller_data(nand, nfc); > > @@ -1324,36 +1366,7 @@ static int mtk_nfc_nand_chip_init(struct device *dev, struct mtk_nfc *nfc, > > > > mtk_nfc_hw_init(nfc); > > > > - ret = nand_scan_ident(mtd, nsels, NULL); > > - if (ret) > > - return ret; > > - > > - /* store bbt magic in page, cause OOB is not protected */ > > - if (nand->bbt_options & NAND_BBT_USE_FLASH) > > - nand->bbt_options |= NAND_BBT_NO_OOB; > > - > > - ret = mtk_nfc_ecc_init(dev, mtd); > > - if (ret) > > - return -EINVAL; > > - > > - if (nand->options & NAND_BUSWIDTH_16) { > > - dev_err(dev, "16bits buswidth not supported"); > > - return -EINVAL; > > - } > > - > > - ret = mtk_nfc_set_spare_per_sector(&chip->spare_per_sector, mtd); > > - if (ret) > > - return ret; > > - > > - mtk_nfc_set_fdm(&chip->fdm, mtd); > > - mtk_nfc_set_bad_mark_ctl(&chip->bad_mark, mtd); > > - > > - len = mtd->writesize + mtd->oobsize; > > - nfc->buffer = devm_kzalloc(dev, len, GFP_KERNEL); > > - if (!nfc->buffer) > > - return -ENOMEM; > > - > > - ret = nand_scan_tail(mtd); > > + ret = nand_scan(mtd, nsels); > > if (ret) > > return ret; > > >