Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2992972imm; Fri, 20 Jul 2018 08:19:38 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf1SigiJ0gjN/W8Tdtpb5a/EPdRvHlYfY4+olgB2izCO9ZKpTvxFXZ+i3Ldd3X3AADiyjnM X-Received: by 2002:a63:1b5c:: with SMTP id b28-v6mr2562521pgm.204.1532099978340; Fri, 20 Jul 2018 08:19:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532099978; cv=none; d=google.com; s=arc-20160816; b=rfPOIwS0hzCfumFut8A7HeDhl8DXf7CpMALYBU+xgSCCyAyB29BkRi3HykBII53zBj 9URPgzw1nrYAA3Dx7ZHsOop91BsKNDz3e3dyFpgUuE36p4ZQx3DjyPRjIH+odYJ3FX/K NEyCehc0M+vnJb0g2v9BL3vhbNOHk/CQN0mwxcsNpaiyothyCJfM6pVPJjlDzMGxBxU0 3L5MFORT+sUWixFq+kOVWaaImM8cHBVtyES1NJSZNv5DXszIlyZz1NOtYqPiPeWIh/mk NI+RifUcW0jrRh9JduGUFPrTW+pziqSDoM18B7dFS5QOEQplK5orvg5Vovj5AUJrEiyv uIVA== 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=wA0soVblHluX/QDiaWV7+atfCqkXG6b1FXW2wyQn+JY=; b=GcSckPlbeMWbWqW0VZS4XLdOJnmg7AjBiwyZ6YWpSbTih0ItEH2JsEm6KJOyF1p3Aq FaBBnNnmQX5d87kNo/0opGK7CpbdiigGn+e1O+GK2oUtFT4u+btawM/QHV/xizlBhB7V 1m3Ty39d47QnUgmrzuqu36INA0pqOqxdGUHlshdYqiZ1bm2iGVJw+gv3z0a7FQ/QSArA oTk2c4FqEY29WtMD5rHQa52vx7FGC2wPw5pEbx4zT9Ut3Fy3YzHRFgsOGu4u3PXhRoiX y9O7ga7ykpCRp/3YhaqwksqnJaJYZKX6yPxjzlFb8ZSap82rc3QycwbJ6Mp9HGRq0v38 BWVQ== 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 u6-v6si2019840pfu.143.2018.07.20.08.19.23; Fri, 20 Jul 2018 08:19:38 -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 S2388029AbeGTQEk (ORCPT + 99 others); Fri, 20 Jul 2018 12:04:40 -0400 Received: from mail.bootlin.com ([62.4.15.54]:54312 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387961AbeGTQEh (ORCPT ); Fri, 20 Jul 2018 12:04:37 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id A5E9820A0F; Fri, 20 Jul 2018 17:15:51 +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 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 93FDF20943; Fri, 20 Jul 2018 17:15:36 +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 14/35] mtd: rawnand: mtk: convert driver to nand_scan() Date: Fri, 20 Jul 2018 17:15:06 +0200 Message-Id: <20180720151527.16038-15-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/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; nand_set_flash_node(nand, np); nand_set_controller_data(nand, nfc); @@ -1324,36 +1366,7 @@ static int mtk_nfc_nand_chip_init(struct device *dev, struct mtk_nfc *nfc, mtk_nfc_hw_init(nfc); - ret = nand_scan_ident(mtd, nsels, NULL); - if (ret) - return ret; - - /* store bbt magic in page, cause OOB is not protected */ - if (nand->bbt_options & NAND_BBT_USE_FLASH) - nand->bbt_options |= NAND_BBT_NO_OOB; - - ret = mtk_nfc_ecc_init(dev, mtd); - if (ret) - return -EINVAL; - - if (nand->options & NAND_BUSWIDTH_16) { - dev_err(dev, "16bits buswidth not supported"); - return -EINVAL; - } - - ret = mtk_nfc_set_spare_per_sector(&chip->spare_per_sector, mtd); - if (ret) - return ret; - - mtk_nfc_set_fdm(&chip->fdm, mtd); - mtk_nfc_set_bad_mark_ctl(&chip->bad_mark, mtd); - - len = mtd->writesize + mtd->oobsize; - nfc->buffer = devm_kzalloc(dev, len, GFP_KERNEL); - if (!nfc->buffer) - return -ENOMEM; - - ret = nand_scan_tail(mtd); + ret = nand_scan(mtd, nsels); if (ret) return ret; -- 2.14.1