Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp86793imm; Wed, 25 Jul 2018 23:15:23 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf8a0ZQkpDHLe+4oeSGbTKJYmo6a54t8izu9WhZToKxWK5mjefiRLqCAgJ9+VHj6TpPomKe X-Received: by 2002:a63:7c18:: with SMTP id x24-v6mr637694pgc.311.1532585723689; Wed, 25 Jul 2018 23:15:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532585723; cv=none; d=google.com; s=arc-20160816; b=NkVTrIJ0Xne3KeYcDj3DkJ6rSEDrTFpKqs1dfcYD1aoBcefjlNa1JMTgASpjTEHaXz HRqWsPywKDWUxcxfxfyQPscq5z0H86OihP8nQdGaXLidclMLlzgC7cb0ORuPmwn5ht3M nKALpwLTaktvD6SL8hByczIAi1t5Td8dduSaJbQ5bwY859ajcxajj5gcswf433/M/zt+ eMA1N+Zesdacuz4r7WyMeZlmSQ0ry3yPulAt6lXYv9ybWpKTDTjqzw4dhXC3ZqUzDoPj zICtxeiM+W9NuB92XCtPDkU/DLkrAQ1jXOa6Z9N8Vt764m8MqSqFsKRPYV6phU92kWZ1 G/Nw== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=2Mpj0W4+tOuuEfD3+EWXNfnWaD/xJQQ+5r57z7qhwb4=; b=pbRAxNqeKIwBaWL1iSY7yrOv0ULWzgoyqd7hNP+VS5vB+Uvoix3VMMuGnL8KLgqQSm 4O+IruhHYn7NvfPz24YuNDE/1J6/rH7iwmKWwZfct8MLYHHyDyrXxs69GUc4F6VBPpR3 d2B3KKzMIJnqEkRa8PVMJBgQiySP+ep/D4jr5aaNX/c7SJqdRXUp0oPADV8FGEQsFCBb FdaqBkMAf840/t0bxbVDoqhJgRDB6RhwYS9gQwpRDSd/nrsKy7skUDfn4WNjhfQ09KZQ /6ltQNbMiAgWZMVcZ9wI1bREnLUYXDhgARay7A/Dehu/G3QEM6KA7NJlH81Vosx0hmXq AFSg== 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 t80-v6si564889pfk.228.2018.07.25.23.15.07; Wed, 25 Jul 2018 23:15:23 -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 S1728611AbeGZH3a (ORCPT + 99 others); Thu, 26 Jul 2018 03:29:30 -0400 Received: from mail.bootlin.com ([62.4.15.54]:42902 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726037AbeGZH3a (ORCPT ); Thu, 26 Jul 2018 03:29:30 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 33D14208FF; Thu, 26 Jul 2018 08:14:13 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from bbrezillon (unknown [91.160.177.164]) by mail.bootlin.com (Postfix) with ESMTPSA id 7622E20893; Thu, 26 Jul 2018 08:14:02 +0200 (CEST) Date: Thu, 26 Jul 2018 08:14:02 +0200 From: Boris Brezillon To: xiaolei li 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 , , , , , Subject: Re: [PATCH v4 14/35] mtd: rawnand: mtk: convert driver to nand_scan() Message-ID: <20180726081402.1fa86ec5@bbrezillon> In-Reply-To: <1532585201.10234.9.camel@mhfsdcap03> References: <20180720151527.16038-1-miquel.raynal@bootlin.com> <20180720151527.16038-15-miquel.raynal@bootlin.com> <20180721191004.26fc9290@bbrezillon> <1532585201.10234.9.camel@mhfsdcap03> X-Mailer: Claws Mail 3.15.0-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 26 Jul 2018 14:06:41 +0800 xiaolei li wrote: > 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? Well, now it's named nand_controller_init(), but yes, that's what I meant.