Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2991051imm; Fri, 20 Jul 2018 08:17:41 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcirg8hiRNOvUjg0bMYHUIaU/7alA8hFK3EgWzb0GLpFgoO6sZBgRPsccAK7avXrVCY2nr/ X-Received: by 2002:a62:3703:: with SMTP id e3-v6mr2625164pfa.117.1532099861609; Fri, 20 Jul 2018 08:17:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532099861; cv=none; d=google.com; s=arc-20160816; b=Z9PqfPET8FYhFOTUrMR/U932QI3G0wVWx+vTUhsIzkgfloJRaBIQ/UoXAkXgsR7ZJL u1Pp0ot7OvKsG67qITjm3Fxs+uil1UM7CqHddzZZpXGQyNMv1MKsyYccrBI3zsGQgbJe wIVs/P5jHOTHaYcdKJ9ht1UN998qosdYEQxJjVNEfoceL/hhl0FtzDxneEBkGcRduH6D ICFGM9yCxYsXJcPLpmgzleEz7r+dxiBTry7FJOCyZENaambP5OMQISZ+qfRL10AGnthl c+WKV9gi3xvB0qWrR9uhia01WJqUXslgs4LYj4wOp+2vD6V5FobYc7t+7lxXFprgY//T /bbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=XyGs/l56xGcFJsuFRJyeQG6eEiDpovG3Lv5PsblO6c8=; b=DRP6v+E1z40VXZTkNVhW798hsAtFm6s92ZhFIeLSs2tt0WarTEm1e1krJciJf/Kqt6 8IdhCUk2YhdOF3s/xkmTMtysAtNertbF89lR281SjYWF9mp5s7lv0dX0KHntkHaBR1F2 YuFc9wFiMlyAi8G25fOXI6KjzLc2/Lz55fc/11Yup3SvjCmQgFmSac5NaYUFPU/Md66D OP9SXN7sRkeqNBt13hjpe2Hfmf4/DnYxJNe1smeKuWIO4YyWKIg9kSBjb3+ufs6Sk/ab W8TnrF8UH07RVdi5RJUmLtYO/l+MlLsVnu89u/JpwMW65zU/87uZnFWQ5L2huHgguAhM 4BlA== 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 u3-v6si1990179pgq.354.2018.07.20.08.17.26; Fri, 20 Jul 2018 08:17:41 -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 S2387973AbeGTQEg (ORCPT + 99 others); Fri, 20 Jul 2018 12:04:36 -0400 Received: from mail.bootlin.com ([62.4.15.54]:54260 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387893AbeGTQEg (ORCPT ); Fri, 20 Jul 2018 12:04:36 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 6C49020876; Fri, 20 Jul 2018 17:15:50 +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 localhost.localdomain (AAubervilliers-681-1-78-122.w90-88.abo.wanadoo.fr [90.88.20.122]) by mail.bootlin.com (Postfix) with ESMTPSA id 494E120922; Fri, 20 Jul 2018 17:15:34 +0200 (CEST) From: Miquel Raynal To: Wenyou Yang , Josh Wu , Tudor Ambarus , Boris Brezillon , Miquel Raynal , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Nicolas Ferre , Alexandre Belloni , Kamal Dasu , Masahiro Yamada , Han Xu , Harvey Hunt , Vladimir Zapolskiy , Sylvain Lemieux , Xiaolei Li , Matthias Brugger , Maxime Ripard , Chen-Yu Tsai , Marc Gonzalez , Mans Rullgard , Stefan Agner Cc: linux-mtd@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com, linux-mediatek@lists.infradead.org Subject: [PATCH v4 10/35] mtd: rawnand: jz4780: convert driver to nand_scan() Date: Fri, 20 Jul 2018 17:15:02 +0200 Message-Id: <20180720151527.16038-11-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180720151527.16038-1-miquel.raynal@bootlin.com> References: <20180720151527.16038-1-miquel.raynal@bootlin.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Acked-by: Harvey Hunt --- drivers/mtd/nand/raw/jz4780_nand.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/drivers/mtd/nand/raw/jz4780_nand.c b/drivers/mtd/nand/raw/jz4780_nand.c index 49841dad347c..db4fa60bd52a 100644 --- a/drivers/mtd/nand/raw/jz4780_nand.c +++ b/drivers/mtd/nand/raw/jz4780_nand.c @@ -158,9 +158,8 @@ static int jz4780_nand_ecc_correct(struct mtd_info *mtd, u8 *dat, return jz4780_bch_correct(nfc->bch, ¶ms, dat, read_ecc); } -static int jz4780_nand_init_ecc(struct jz4780_nand_chip *nand, struct device *dev) +static int jz4780_nand_attach_chip(struct nand_chip *chip) { - struct nand_chip *chip = &nand->chip; struct mtd_info *mtd = nand_to_mtd(chip); struct jz4780_nand_controller *nfc = to_jz4780_nand_controller(chip->controller); int eccbytes; @@ -171,7 +170,8 @@ static int jz4780_nand_init_ecc(struct jz4780_nand_chip *nand, struct device *de switch (chip->ecc.mode) { case NAND_ECC_HW: if (!nfc->bch) { - dev_err(dev, "HW BCH selected, but BCH controller not found\n"); + dev_err(nfc->dev, + "HW BCH selected, but BCH controller not found\n"); return -ENODEV; } @@ -180,15 +180,16 @@ static int jz4780_nand_init_ecc(struct jz4780_nand_chip *nand, struct device *de chip->ecc.correct = jz4780_nand_ecc_correct; /* fall through */ case NAND_ECC_SOFT: - dev_info(dev, "using %s (strength %d, size %d, bytes %d)\n", - (nfc->bch) ? "hardware BCH" : "software ECC", - chip->ecc.strength, chip->ecc.size, chip->ecc.bytes); + dev_info(nfc->dev, "using %s (strength %d, size %d, bytes %d)\n", + (nfc->bch) ? "hardware BCH" : "software ECC", + chip->ecc.strength, chip->ecc.size, chip->ecc.bytes); break; case NAND_ECC_NONE: - dev_info(dev, "not using ECC\n"); + dev_info(nfc->dev, "not using ECC\n"); break; default: - dev_err(dev, "ECC mode %d not supported\n", chip->ecc.mode); + dev_err(nfc->dev, "ECC mode %d not supported\n", + chip->ecc.mode); return -EINVAL; } @@ -200,7 +201,7 @@ static int jz4780_nand_init_ecc(struct jz4780_nand_chip *nand, struct device *de eccbytes = mtd->writesize / chip->ecc.size * chip->ecc.bytes; if (eccbytes > mtd->oobsize - 2) { - dev_err(dev, + dev_err(nfc->dev, "invalid ECC config: required %d ECC bytes, but only %d are available", eccbytes, mtd->oobsize - 2); return -EINVAL; @@ -211,6 +212,10 @@ static int jz4780_nand_init_ecc(struct jz4780_nand_chip *nand, struct device *de return 0; } +static const struct nand_controller_ops jz4780_nand_controller_ops = { + .attach_chip = jz4780_nand_attach_chip, +}; + static int jz4780_nand_init_chip(struct platform_device *pdev, struct jz4780_nand_controller *nfc, struct device_node *np, @@ -280,15 +285,8 @@ static int jz4780_nand_init_chip(struct platform_device *pdev, chip->controller = &nfc->controller; nand_set_flash_node(chip, np); - ret = nand_scan_ident(mtd, 1, NULL); - if (ret) - return ret; - - ret = jz4780_nand_init_ecc(nand, dev); - if (ret) - return ret; - - ret = nand_scan_tail(mtd); + chip->controller->ops = &jz4780_nand_controller_ops; + ret = nand_scan(mtd, 1); if (ret) return ret; -- 2.14.1