Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2993868imm; Fri, 20 Jul 2018 08:20:32 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcu9gSAYEztn6L6ah+LvbVWUEWCvRkg0vI7lagd1HoaSCmkI0ZZSogjrY7vaWEalcZbqbYr X-Received: by 2002:a17:902:bc49:: with SMTP id t9-v6mr2525188plz.116.1532100032688; Fri, 20 Jul 2018 08:20:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532100032; cv=none; d=google.com; s=arc-20160816; b=GUElYZAkNu0d79Y7ikoV7Mm5S/TK0qO5jiTLgQn+Xk9lxd/MUhuR7dU4oLVaMt3gUp U3ptEvqP8AILxHjzMuvISoIICaJ58W64Q6HyCdcyIWcFGMgAVMIQeH0Jgx6DxWiPaneR pOmpClVGfBLUAOxcYOO8+zzoZs275+1Yy+qeJUp/iFqMd39ihkTdTV3Un6cdtuUc7Ru0 u1s81/KYSH5Da+nN6CKFe820SQMrJHKAfYphqek9omqBNsN+/64TaWl3ueQHDDE4+IFC GGSo+MwSzQVYoYuyFS4vXbq7nfDRF2Fstwu6S207CrvhINrYC3rtiDr6vTon1lDaefLl CNpw== 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=Skx837XexoPImcVqdQfw4Jiwxu43Im746m0QdzWax3I=; b=epL15Cxz2+q24J8k9I4lcm0PY1Gf/knhgKFyA8WKIBzlh4VJQ4v+hmfaWTHQkzc9Wp QZSFSFTw3ioQ9q+iK8DGFHxUdVCjDEBU5g/OpKdy+oajoL9+iWs+xY9LSQxuNomR4vL6 rSdcRUN9vJxkatTGef4VSxnsl2Q4N+OV8zognYzlJAtDWxr/Zgz4k8DkU1M1vV0UrFYF nrVKQbRQ1f2eMW8UVDPCUHin2bGqXiha8GMFujdz1wdRb0THysQx8qZBZcxoIF0U9IX0 +osCcW6+NWwRm2JSTWIg1MvSpJACXL71ZMqf48R/YmsIDpk+acJsGPXbw8f2GYhWtwcD j09g== 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 w6-v6si2120204pgb.61.2018.07.20.08.20.18; Fri, 20 Jul 2018 08:20:32 -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 S2388224AbeGTQHE (ORCPT + 99 others); Fri, 20 Jul 2018 12:07:04 -0400 Received: from mail.bootlin.com ([62.4.15.54]:54232 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387890AbeGTQEg (ORCPT ); Fri, 20 Jul 2018 12:04:36 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id D4953208FF; Fri, 20 Jul 2018 17:15:49 +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 28A2F20908; Fri, 20 Jul 2018 17:15:33 +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 08/35] mtd: rawnand: gpmi: convert driver to nand_scan() Date: Fri, 20 Jul 2018 17:15:00 +0200 Message-Id: <20180720151527.16038-9-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/gpmi-nand/gpmi-nand.c | 56 ++++++++++++++++++------------ 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c index 6294d018df65..1c1ebbc82824 100644 --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c @@ -744,9 +744,9 @@ static int gpmi_alloc_dma_buffer(struct gpmi_nand_data *this) * [2] Allocate a read/write data buffer. * The gpmi_alloc_dma_buffer can be called twice. * We allocate a PAGE_SIZE length buffer if gpmi_alloc_dma_buffer - * is called before the nand_scan_ident; and we allocate a buffer - * of the real NAND page size when the gpmi_alloc_dma_buffer is - * called after the nand_scan_ident. + * is called before the NAND identification; and we allocate a + * buffer of the real NAND page size when the gpmi_alloc_dma_buffer + * is called after. */ this->data_buffer_dma = kzalloc(mtd->writesize ?: PAGE_SIZE, GFP_DMA | GFP_KERNEL); @@ -1865,6 +1865,34 @@ static int gpmi_init_last(struct gpmi_nand_data *this) return 0; } +static int gpmi_nand_attach_chip(struct nand_chip *chip) +{ + struct gpmi_nand_data *this = nand_get_controller_data(chip); + int ret; + + if (chip->bbt_options & NAND_BBT_USE_FLASH) { + chip->bbt_options |= NAND_BBT_NO_OOB; + + if (of_property_read_bool(this->dev->of_node, + "fsl,no-blockmark-swap")) + this->swap_block_mark = false; + } + dev_dbg(this->dev, "Blockmark swapping %sabled\n", + this->swap_block_mark ? "en" : "dis"); + + ret = gpmi_init_last(this); + if (ret) + return ret; + + chip->options |= NAND_SKIP_BBTSCAN; + + return 0; +} + +static const struct nand_controller_ops gpmi_nand_controller_ops = { + .attach_chip = gpmi_nand_attach_chip, +}; + static int gpmi_nand_init(struct gpmi_nand_data *this) { struct nand_chip *chip = &this->nand; @@ -1905,26 +1933,8 @@ static int gpmi_nand_init(struct gpmi_nand_data *this) if (ret) goto err_out; - ret = nand_scan_ident(mtd, GPMI_IS_MX6(this) ? 2 : 1, NULL); - if (ret) - goto err_out; - - if (chip->bbt_options & NAND_BBT_USE_FLASH) { - chip->bbt_options |= NAND_BBT_NO_OOB; - - if (of_property_read_bool(this->dev->of_node, - "fsl,no-blockmark-swap")) - this->swap_block_mark = false; - } - dev_dbg(this->dev, "Blockmark swapping %sabled\n", - this->swap_block_mark ? "en" : "dis"); - - ret = gpmi_init_last(this); - if (ret) - goto err_out; - - chip->options |= NAND_SKIP_BBTSCAN; - ret = nand_scan_tail(mtd); + chip->dummy_controller.ops = &gpmi_nand_controller_ops; + ret = nand_scan(mtd, GPMI_IS_MX6(this) ? 2 : 1); if (ret) goto err_out; -- 2.14.1