Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2992282imm; Fri, 20 Jul 2018 08:18:53 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfohlGleaoy+bFNCoL+Q77QI3qdV0zMs7qDuB2fAFooJg5yFVJZwE0dK5K5GXXi72HBXxxR X-Received: by 2002:a63:d15:: with SMTP id c21-v6mr2522363pgl.322.1532099933731; Fri, 20 Jul 2018 08:18:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532099933; cv=none; d=google.com; s=arc-20160816; b=ISMFI+8aFYKlp/EhZLrnXOl5ogu0Pp9ckD195CSH01qfiu1TL/X6X5gBFN05mSutW5 xYdrxpGqefCnlvxXG/fY+IpRhNzzZeBsP+dEbGyNaKW1DSuuQRR/ANMgUsuARV5ExcyG nuAHIBtN9gaNsR8rKdW5y/GaWQRl+1C4RUzSskwB4s2Hr+WBICmRG7SaMjy3wiAdJ98n 9oFeNLez+r2KzdZd6HHcvblugOYEGMHOjdlKScroxRLZNcFHH7nQHAkb3cSRb3WjZJNq E61qrII8A22CTJA1ehhFWyfdNDWK6svnh4wAA0dtAlXpqv6hS0prnHOAkWvzKnuG9/K1 jTKw== 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=Q4d9yLk/LGxe7q8L8W2eK6yuxOKcGBUbYWGFtbx4qgE=; b=ImVMURqfhMuWcjnpFZbM6w5igFTzmppofXcl/SSea5bsjE/FM0o9xYebAaUCtYpF8q gwOnrVbXh5cVs3oCV8h3L1Ulwy0IsYoTDCQ5cbJw9chr5Ix6U/Jo/qSeuN93zDaN95TT bFPOh9d357waU7/sBGKekZe/o6GMP0DzAM+g/LCAj2ot4j0EjfofrJXaMd7ggRwJVMAA iF8+ZL6RyuZVVQoswj2ay7j0+cqKU+wj5tTwpKO0Bv+BZ630auqAVRYPlmrsKZOCCUU6 H9gGOeD4HPMprjI1cY1jThNKXqX7qneLcZkUNz99tue400kEVyWhaj2iXtlnPVidC7/b 5XVw== 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 r73-v6si1934597pfr.231.2018.07.20.08.18.39; Fri, 20 Jul 2018 08:18:53 -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 S2388311AbeGTQFk (ORCPT + 99 others); Fri, 20 Jul 2018 12:05:40 -0400 Received: from mail.bootlin.com ([62.4.15.54]:54497 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388102AbeGTQEs (ORCPT ); Fri, 20 Jul 2018 12:04:48 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id CB5E3209C0; Fri, 20 Jul 2018 17:16:01 +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 BE393209C1; Fri, 20 Jul 2018 17:15:45 +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 30/35] mtd: rawnand: qcom: convert driver to nand_scan() Date: Fri, 20 Jul 2018 17:15:22 +0200 Message-Id: <20180720151527.16038-31-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/qcom_nandc.c | 71 +++++++++++++-------------------------- 1 file changed, 24 insertions(+), 47 deletions(-) diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c index aa6c3e026ef1..dc895b846b84 100644 --- a/drivers/mtd/nand/raw/qcom_nandc.c +++ b/drivers/mtd/nand/raw/qcom_nandc.c @@ -2475,10 +2475,10 @@ qcom_nandc_calc_ecc_bytes(int step_size, int strength) NAND_ECC_CAPS_SINGLE(qcom_nandc_ecc_caps, qcom_nandc_calc_ecc_bytes, NANDC_STEP_SIZE, 4, 8); -static int qcom_nand_host_setup(struct qcom_nand_host *host) +static int qcom_nand_attach_chip(struct nand_chip *chip) { - struct nand_chip *chip = &host->chip; struct mtd_info *mtd = nand_to_mtd(chip); + struct qcom_nand_host *host = to_qcom_nand_host(chip); struct nand_ecc_ctrl *ecc = &chip->ecc; struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip); int cwperpage, bad_block_byte, ret; @@ -2640,6 +2640,10 @@ static int qcom_nand_host_setup(struct qcom_nand_host *host) return 0; } +static const struct nand_controller_ops qcom_nandc_ops = { + .attach_chip = qcom_nand_attach_chip, +}; + static int qcom_nandc_alloc(struct qcom_nand_controller *nandc) { int ret; @@ -2781,9 +2785,9 @@ static int qcom_nandc_setup(struct qcom_nand_controller *nandc) return 0; } -static int qcom_nand_host_init(struct qcom_nand_controller *nandc, - struct qcom_nand_host *host, - struct device_node *dn) +static int qcom_nand_host_init_and_register(struct qcom_nand_controller *nandc, + struct qcom_nand_host *host, + struct device_node *dn) { struct nand_chip *chip = &host->chip; struct mtd_info *mtd = nand_to_mtd(chip); @@ -2824,36 +2828,20 @@ static int qcom_nand_host_init(struct qcom_nand_controller *nandc, chip->block_markbad = qcom_nandc_block_markbad; chip->controller = &nandc->controller; + chip->controller->ops = &qcom_nandc_ops; chip->options |= NAND_NO_SUBPAGE_WRITE | NAND_USE_BOUNCE_BUFFER | NAND_SKIP_BBTSCAN; /* set up initial status value */ host->status = NAND_STATUS_READY | NAND_STATUS_WP; - ret = nand_scan_ident(mtd, 1, NULL); - if (ret) - return ret; - - ret = qcom_nand_host_setup(host); - - return ret; -} - -static int qcom_nand_mtd_register(struct qcom_nand_controller *nandc, - struct qcom_nand_host *host, - struct device_node *dn) -{ - struct nand_chip *chip = &host->chip; - struct mtd_info *mtd = nand_to_mtd(chip); - int ret; - - ret = nand_scan_tail(mtd); + ret = nand_scan(mtd, 1); if (ret) return ret; ret = mtd_device_register(mtd, NULL, 0); if (ret) - nand_cleanup(mtd_to_nand(mtd)); + nand_cleanup(chip); return ret; } @@ -2862,9 +2850,19 @@ static int qcom_probe_nand_devices(struct qcom_nand_controller *nandc) { struct device *dev = nandc->dev; struct device_node *dn = dev->of_node, *child; - struct qcom_nand_host *host, *tmp; + struct qcom_nand_host *host; int ret; + if (nandc->props->is_bam) { + free_bam_transaction(nandc); + nandc->bam_txn = alloc_bam_transaction(nandc); + if (!nandc->bam_txn) { + dev_err(nandc->dev, + "failed to allocate bam transaction\n"); + return -ENOMEM; + } + } + for_each_available_child_of_node(dn, child) { host = devm_kzalloc(dev, sizeof(*host), GFP_KERNEL); if (!host) { @@ -2872,7 +2870,7 @@ static int qcom_probe_nand_devices(struct qcom_nand_controller *nandc) return -ENOMEM; } - ret = qcom_nand_host_init(nandc, host, child); + ret = qcom_nand_host_init_and_register(nandc, host, child); if (ret) { devm_kfree(dev, host); continue; @@ -2881,27 +2879,6 @@ static int qcom_probe_nand_devices(struct qcom_nand_controller *nandc) list_add_tail(&host->node, &nandc->host_list); } - if (list_empty(&nandc->host_list)) - return -ENODEV; - - if (nandc->props->is_bam) { - free_bam_transaction(nandc); - nandc->bam_txn = alloc_bam_transaction(nandc); - if (!nandc->bam_txn) { - dev_err(nandc->dev, - "failed to allocate bam transaction\n"); - return -ENOMEM; - } - } - - list_for_each_entry_safe(host, tmp, &nandc->host_list, node) { - ret = qcom_nand_mtd_register(nandc, host, child); - if (ret) { - list_del(&host->node); - devm_kfree(dev, host); - } - } - if (list_empty(&nandc->host_list)) return -ENODEV; -- 2.14.1