Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2991291imm; Fri, 20 Jul 2018 08:17:54 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdYLCvjlPE2IrdtV4aJ5zaURmBSvP4Bi/sb3cBD+AWVQ+zjAtGify4ODSKQn7egjzmXD5BL X-Received: by 2002:a63:3190:: with SMTP id x138-v6mr2486667pgx.60.1532099874776; Fri, 20 Jul 2018 08:17:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532099874; cv=none; d=google.com; s=arc-20160816; b=hcbUy8K/W+y2camwEBZ55TduwyOaSb499u8CwuCHx0EH9vGFmivNsIe2hGJ+sRC6A7 RsKOedaS/FU1LdOWuxAfeEePlLfoWcYzNsAor7kcQlj9qFC7OJALrUVetz1z6h5NlMyr KwxnG1RXEvxpefTjYS8x3f37Q8yN+d/AUXuExnuEqXFcI/7SRPSJSRTj6F+BoztMe/jq 15Y44lyuihMgiNZOEEzNOCb6KSQ4E0bhIY+XJ0WkvLwHV5HE4sv++wB9/guqv0ikKzkX L9LYTLrvK8zE1744N6wZ7gWR65yokEl4ENnK9P+FjLt0n1nxXUGPk3j8NwGR7Xr4x/xx /7Lw== 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=oPtYU9Gx+8ahrDLPfEMWyAn8viONehybXMbLGEL2exw=; b=hhW1//i3HzYu45DpZqqaOy8z0weMBGIs0oZygrTKrQsu6yn8F+7tExIoF2a14OA6gL b4eiWgdbPyOC4TbvzGVg4PSdLpuotFhJZ9ZawueH6rVqR/TVPn94lU0ufb8qu7Ia7yRU ZvV8rf/s3nki3/V3TWx0rfeMLKdDR55E9iksL1ywv8e7iAhKlUtNxD4ZERJ8GZrjxWH+ 5c6saCHOwZydtg7azXmlqKv51P6TKaC4z7qDlAwAbcuA89toTUlbnrTpwSQN+0vDXW8e 8GDYSiyXKgp3GXr+47GAD62Fl9j+vhrTelWw5XSf7q+L6mGKh2yapf0tfhp7bQeov7By YPvg== 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 w9-v6si1786162plp.395.2018.07.20.08.17.39; Fri, 20 Jul 2018 08:17:54 -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 S2388209AbeGTQEu (ORCPT + 99 others); Fri, 20 Jul 2018 12:04:50 -0400 Received: from mail.bootlin.com ([62.4.15.54]:54499 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388054AbeGTQEq (ORCPT ); Fri, 20 Jul 2018 12:04:46 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 017D7207B4; Fri, 20 Jul 2018 17:16:00 +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 9825520765; Fri, 20 Jul 2018 17:15:40 +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 21/35] mtd: rawnand: sunxi: convert driver to nand_scan() Date: Fri, 20 Jul 2018 17:15:13 +0200 Message-Id: <20180720151527.16038-22-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 --- drivers/mtd/nand/raw/sunxi_nand.c | 43 +++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c index 07f3ff9a28f2..a4d23381003d 100644 --- a/drivers/mtd/nand/raw/sunxi_nand.c +++ b/drivers/mtd/nand/raw/sunxi_nand.c @@ -1816,12 +1816,21 @@ static void sunxi_nand_ecc_cleanup(struct nand_ecc_ctrl *ecc) } } -static int sunxi_nand_ecc_init(struct mtd_info *mtd, struct nand_ecc_ctrl *ecc, - struct device_node *np) +static int sunxi_nand_attach_chip(struct nand_chip *nand) { - struct nand_chip *nand = mtd_to_nand(mtd); + struct mtd_info *mtd = nand_to_mtd(nand); + struct nand_ecc_ctrl *ecc = &nand->ecc; + struct device_node *np = nand_get_flash_node(nand); int ret; + if (nand->bbt_options & NAND_BBT_USE_FLASH) + nand->bbt_options |= NAND_BBT_NO_OOB; + + if (nand->options & NAND_NEED_SCRAMBLING) + nand->options |= NAND_NO_SUBPAGE_WRITE; + + nand->options |= NAND_SUBPAGE_READ; + if (!ecc->size) { ecc->size = nand->ecc_step_ds; ecc->strength = nand->ecc_strength_ds; @@ -1846,6 +1855,10 @@ static int sunxi_nand_ecc_init(struct mtd_info *mtd, struct nand_ecc_ctrl *ecc, return 0; } +static const struct nand_controller_ops sunxi_nand_controller_ops = { + .attach_chip = sunxi_nand_attach_chip, +}; + static int sunxi_nand_chip_init(struct device *dev, struct sunxi_nfc *nfc, struct device_node *np) { @@ -1911,6 +1924,8 @@ static int sunxi_nand_chip_init(struct device *dev, struct sunxi_nfc *nfc, /* Default tR value specified in the ONFI spec (chapter 4.15.1) */ nand->chip_delay = 200; nand->controller = &nfc->controller; + nand->controller->ops = &sunxi_nand_controller_ops; + /* * Set the ECC mode to the default value in case nothing is specified * in the DT. @@ -1927,30 +1942,10 @@ static int sunxi_nand_chip_init(struct device *dev, struct sunxi_nfc *nfc, mtd = nand_to_mtd(nand); mtd->dev.parent = dev; - ret = nand_scan_ident(mtd, nsels, NULL); + ret = nand_scan(mtd, nsels); if (ret) return ret; - if (nand->bbt_options & NAND_BBT_USE_FLASH) - nand->bbt_options |= NAND_BBT_NO_OOB; - - if (nand->options & NAND_NEED_SCRAMBLING) - nand->options |= NAND_NO_SUBPAGE_WRITE; - - nand->options |= NAND_SUBPAGE_READ; - - ret = sunxi_nand_ecc_init(mtd, &nand->ecc, np); - if (ret) { - dev_err(dev, "ECC init failed: %d\n", ret); - return ret; - } - - ret = nand_scan_tail(mtd); - if (ret) { - dev_err(dev, "nand_scan_tail failed: %d\n", ret); - return ret; - } - ret = mtd_device_register(mtd, NULL, 0); if (ret) { dev_err(dev, "failed to register mtd device: %d\n", ret); -- 2.14.1