{"id":949183,"url":"http://patchwork.ozlabs.org/api/1.2/patches/949183/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-mtd/patch/20180725133152.30898-4-miquel.raynal@bootlin.com/","project":{"id":3,"url":"http://patchwork.ozlabs.org/api/1.2/projects/3/?format=json","name":"Linux MTD development","link_name":"linux-mtd","list_id":"linux-mtd.lists.infradead.org","list_email":"linux-mtd@lists.infradead.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20180725133152.30898-4-miquel.raynal@bootlin.com>","list_archive_url":null,"date":"2018-07-25T13:31:38","name":"[v5,03/17] mtd: rawnand: lpc32xx_mlc: convert driver to nand_scan()","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"41f0e5956f30582e5ffffdd97b12bca35db51f0e","submitter":{"id":73368,"url":"http://patchwork.ozlabs.org/api/1.2/people/73368/?format=json","name":"Miquel Raynal","email":"miquel.raynal@bootlin.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-mtd/patch/20180725133152.30898-4-miquel.raynal@bootlin.com/mbox/","series":[{"id":57526,"url":"http://patchwork.ozlabs.org/api/1.2/series/57526/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-mtd/list/?series=57526","date":"2018-07-25T13:31:36","name":"Allow dynamic allocations during NAND chip identification phase","version":5,"mbox":"http://patchwork.ozlabs.org/series/57526/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/949183/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/949183/checks/","tags":{},"related":[],"headers":{"Return-Path":"<linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org; spf=none (mailfrom)\n\tsmtp.mailfrom=lists.infradead.org\n\t(client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org;\n\tenvelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdmarc=none (p=none dis=none) header.from=bootlin.com","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org header.b=\"oefgr1zR\"; \n\tdkim-atps=neutral"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n\t[IPv6:2607:7c80:54:e::133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 41bGPX2JXXz9s2M\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 25 Jul 2018 23:32:48 +1000 (AEST)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux))\n\tid 1fiJuE-0000mJ-7d; Wed, 25 Jul 2018 13:32:42 +0000","from mail.bootlin.com ([62.4.15.54])\n\tby bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux))\n\tid 1fiJtr-0000Iu-Df\n\tfor linux-mtd@lists.infradead.org; Wed, 25 Jul 2018 13:32:23 +0000","by mail.bootlin.com (Postfix, from userid 110)\n\tid A19112072F; Wed, 25 Jul 2018 15:32:07 +0200 (CEST)","from localhost.localdomain\n\t(AAubervilliers-681-1-78-122.w90-88.abo.wanadoo.fr [90.88.20.122])\n\tby mail.bootlin.com (Postfix) with ESMTPSA id 50A2620765;\n\tWed, 25 Jul 2018 15:31:57 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe:\n\tList-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References:\n\tIn-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID:\n\tContent-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc\n\t:Resent-Message-ID:List-Owner;\n\tbh=VktNxtpRfHBkCjtivv9Nqd1lA77auLHDoJYJx6vJ9Zk=;\n\tb=oefgr1zR+f9d7C63lcA1fRODY7\n\t09unzfJ1SNfbuUilSzwpBYQaKYgVcpCQjMZ8qjOX4HadXiQpFas8HPYT7e4Fd73GbsZuhNojcg8gw\n\t8iG/BI7IN/TFsRCORLykoLry31LU+H6cxD78HOB6Mh34E6veY0FpsyFqPW+5Dn/sY5jJPK8ThtfXs\n\tj3iTsCwzScCQ8VDVqKmKhBzqr8BnWk3EGZWPLOriu4YMh6obe4M1e43CSmq4MXdGAOqjU9p8jo1qi\n\tKT/yyJU3lkbSVznkp8A1+o9koyyh970vIg1ovbUK7HjGMWISr6JSCEJ/2M0VuiOqjr3iXrhTu0xCp\n\tR4xi5z5Q==;","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,\n\tURIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0","From":"Miquel Raynal <miquel.raynal@bootlin.com>","To":"Boris Brezillon <boris.brezillon@bootlin.com>,\n\tRichard Weinberger <richard@nod.at>,\n\tDavid Woodhouse <dwmw2@infradead.org>, \n\tBrian Norris <computersforpeace@gmail.com>,\n\tMarek Vasut <marek.vasut@gmail.com>","Subject":"[PATCH v5 03/17] mtd: rawnand: lpc32xx_mlc: convert driver to\n\tnand_scan()","Date":"Wed, 25 Jul 2018 15:31:38 +0200","Message-Id":"<20180725133152.30898-4-miquel.raynal@bootlin.com>","X-Mailer":"git-send-email 2.14.1","In-Reply-To":"<20180725133152.30898-1-miquel.raynal@bootlin.com>","References":"<20180725133152.30898-1-miquel.raynal@bootlin.com>","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20180725_063219_767203_3BD4D025 ","X-CRM114-Status":"GOOD (  17.03  )","X-Spam-Score":"-0.0 (/)","X-Spam-Report":"SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-0.0 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/,\n\tno trust [62.4.15.54 listed in list.dnswl.org]\n\t-0.0 SPF_PASS               SPF: sender matches SPF record","X-BeenThere":"linux-mtd@lists.infradead.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"Linux MTD discussion mailing list <linux-mtd.lists.infradead.org>","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-mtd>,\n\t<mailto:linux-mtd-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-mtd/>","List-Post":"<mailto:linux-mtd@lists.infradead.org>","List-Help":"<mailto:linux-mtd-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-mtd>,\n\t<mailto:linux-mtd-request@lists.infradead.org?subject=subscribe>","Cc":"Lucas Stach <dev@lynxeye.de>, Wenyou Yang <wenyou.yang@microchip.com>,\n\tJosh Wu <rainyfeeling@outlook.com>, Stefan Agner <stefan@agner.ch>,\n\tlinux-mtd@lists.infradead.org, Miquel Raynal <miquel.raynal@bootlin.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"\"linux-mtd\" <linux-mtd-bounces@lists.infradead.org>","Errors-To":"linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org"},"content":"Two helpers have been added to the core to do all kind of controller\nside configuration/initialization between the detection phase and the\nfinal NAND scan. Implement these hooks so that we can convert the driver\nto just use nand_scan() instead of the nand_scan_ident() +\nnand_scan_tail() pair.\n\nSigned-off-by: Miquel Raynal <miquel.raynal@bootlin.com>\n---\n drivers/mtd/nand/raw/lpc32xx_mlc.c | 61 +++++++++++++++++++++-----------------\n 1 file changed, 33 insertions(+), 28 deletions(-)","diff":"diff --git a/drivers/mtd/nand/raw/lpc32xx_mlc.c b/drivers/mtd/nand/raw/lpc32xx_mlc.c\nindex 052d123a8304..e82abada130a 100644\n--- a/drivers/mtd/nand/raw/lpc32xx_mlc.c\n+++ b/drivers/mtd/nand/raw/lpc32xx_mlc.c\n@@ -184,6 +184,7 @@ static struct nand_bbt_descr lpc32xx_nand_bbt_mirror = {\n };\n \n struct lpc32xx_nand_host {\n+\tstruct platform_device\t*pdev;\n \tstruct nand_chip\tnand_chip;\n \tstruct lpc32xx_mlc_platform_data *pdata;\n \tstruct clk\t\t*clk;\n@@ -653,6 +654,32 @@ static struct lpc32xx_nand_cfg_mlc *lpc32xx_parse_dt(struct device *dev)\n \treturn ncfg;\n }\n \n+static int lpc32xx_nand_attach_chip(struct nand_chip *chip)\n+{\n+\tstruct mtd_info *mtd = nand_to_mtd(chip);\n+\tstruct lpc32xx_nand_host *host = nand_get_controller_data(chip);\n+\tstruct device *dev = &host->pdev->dev;\n+\n+\thost->dma_buf = devm_kzalloc(dev, mtd->writesize, GFP_KERNEL);\n+\tif (!host->dma_buf)\n+\t\treturn -ENOMEM;\n+\n+\thost->dummy_buf = devm_kzalloc(dev, mtd->writesize, GFP_KERNEL);\n+\tif (!host->dummy_buf)\n+\t\treturn -ENOMEM;\n+\n+\tchip->ecc.mode = NAND_ECC_HW;\n+\tchip->ecc.size = 512;\n+\tmtd_set_ooblayout(mtd, &lpc32xx_ooblayout_ops);\n+\thost->mlcsubpages = mtd->writesize / 512;\n+\n+\treturn 0;\n+}\n+\n+static const struct nand_controller_ops lpc32xx_nand_controller_ops = {\n+\t.attach_chip = lpc32xx_nand_attach_chip,\n+};\n+\n /*\n  * Probe for NAND controller\n  */\n@@ -669,6 +696,8 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)\n \tif (!host)\n \t\treturn -ENOMEM;\n \n+\thost->pdev = pdev;\n+\n \trc = platform_get_resource(pdev, IORESOURCE_MEM, 0);\n \thost->io_base = devm_ioremap_resource(&pdev->dev, rc);\n \tif (IS_ERR(host->io_base))\n@@ -748,31 +777,6 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)\n \t\t}\n \t}\n \n-\t/*\n-\t * Scan to find existance of the device and\n-\t * Get the type of NAND device SMALL block or LARGE block\n-\t */\n-\tres = nand_scan_ident(mtd, 1, NULL);\n-\tif (res)\n-\t\tgoto release_dma_chan;\n-\n-\thost->dma_buf = devm_kzalloc(&pdev->dev, mtd->writesize, GFP_KERNEL);\n-\tif (!host->dma_buf) {\n-\t\tres = -ENOMEM;\n-\t\tgoto release_dma_chan;\n-\t}\n-\n-\thost->dummy_buf = devm_kzalloc(&pdev->dev, mtd->writesize, GFP_KERNEL);\n-\tif (!host->dummy_buf) {\n-\t\tres = -ENOMEM;\n-\t\tgoto release_dma_chan;\n-\t}\n-\n-\tnand_chip->ecc.mode = NAND_ECC_HW;\n-\tnand_chip->ecc.size = 512;\n-\tmtd_set_ooblayout(mtd, &lpc32xx_ooblayout_ops);\n-\thost->mlcsubpages = mtd->writesize / 512;\n-\n \t/* initially clear interrupt status */\n \treadb(MLC_IRQ_SR(host->io_base));\n \n@@ -794,10 +798,11 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)\n \t}\n \n \t/*\n-\t * Fills out all the uninitialized function pointers with the defaults\n-\t * And scans for a bad block table if appropriate.\n+\t * Scan to find existence of the device and get the type of NAND device:\n+\t * SMALL block or LARGE block.\n \t */\n-\tres = nand_scan_tail(mtd);\n+\tnand_chip->dummy_controller.ops = &lpc32xx_nand_controller_ops;\n+\tres = nand_scan(mtd, 1);\n \tif (res)\n \t\tgoto free_irq;\n \n","prefixes":["v5","03/17"]}