From patchwork Fri Mar 2 17:03:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 10255369 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E5D966037F for ; Fri, 2 Mar 2018 18:20:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D2C0D27D0C for ; Fri, 2 Mar 2018 18:20:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C411927FA1; Fri, 2 Mar 2018 18:20:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3139827D0C for ; Fri, 2 Mar 2018 18:20:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=C9BDP6khBpaJE5S6hgDN6/Tk8lfnI5tWu43lVJY8myo=; b=mD7LWvXojfr8/8P0eCHBOuZVcK 3sZ33KwRXFf2zaT2am7aPaQWeFfUmLe3DDOVWqwcJKfXjGrYJDQ26H1l/Amj47h+HNRwyd/bAq/mB ujBiZMxVnEO15EpV0Gfp2WV6jgOWdH0YDc/qGGu2+E+gINCPCgvI2jzk8IwwlWP2sLPKi18hvM3oA uHhf0INUeXi5Z62LxT5oUyoy3c6rTZFsgWZvjdz6hmM3eGoztlXDasDRK5fwt1kzFZq13+GJvaAPB zESM9/AZxEMUAnh1F10Ge/N+teh/SEUeQDQ3ESCn5k/hrL5gq3eQymBYW2W/tYl6vuOcQqbGPP9+v WZwnE++A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1erpIS-0000vr-UG; Fri, 02 Mar 2018 18:20:45 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1erpC0-0001qC-CO; Fri, 02 Mar 2018 18:14:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=kASVJGDUfNQlZqfgnugiUy6axNHLWSg0la0qzOSsXvo=; b=ILM8JvRIWhpg1rYJUtqVPw8Jp O1PGTZ9Wtcec8F5QYAM43j0t0Ve8MqNe+syDPhuiTgVgRVMXfq/eUFwwnTibTAdBdex185Y6ApzF6 jm5csKjYrY4H+LL7coyPytlsnue8UG9tQwTtJYuvzZgxP6n4DyoOiwb7X2vKHlraHqNPB8aolqetG 7k1o+KBCUYzOgl3Z7Dci7Nz+0SNXY69SZX0AoPIqrm7ey7b+Doo52zibXBi4iyqNZ44Gtpr7GuMxh hyMuRXXQTRxzMok3a2P4rjbyNvCBHe4GKCghEhwO2xMzBVjxrWdUEe4nCYzgodJ88jm1+8zh2LrEz 1sAzTa7rA==; Received: from mail.bootlin.com ([62.4.15.54]) by merlin.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1ero7C-00075c-79; Fri, 02 Mar 2018 17:05:03 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 80F9B209FA; Fri, 2 Mar 2018 18:04:41 +0100 (CET) Received: from localhost.localdomain (unknown [91.224.148.103]) by mail.bootlin.com (Postfix) with ESMTPSA id 8DD4220379; Fri, 2 Mar 2018 18:04:40 +0100 (CET) From: Miquel Raynal To: Boris Brezillon , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Cyrille Pitchen , Josh Wu , Kamal Dasu , Harvey Hunt , Stefan Agner Subject: [PATCH 43/52] mtd: rawnand: atmel: convert driver to nand_scan() Date: Fri, 2 Mar 2018 18:03:51 +0100 Message-Id: <20180302170400.6712-44-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180302170400.6712-1-miquel.raynal@bootlin.com> References: <20180302170400.6712-1-miquel.raynal@bootlin.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180302_120502_595163_6F1EAD93 X-CRM114-Status: GOOD ( 16.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mtd@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Miquel Raynal MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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/atmel/nand-controller.c | 70 +++++++++++----------------- 1 file changed, 27 insertions(+), 43 deletions(-) diff --git a/drivers/mtd/nand/raw/atmel/nand-controller.c b/drivers/mtd/nand/raw/atmel/nand-controller.c index 12f6753d47ae..0808bc558bb8 100644 --- a/drivers/mtd/nand/raw/atmel/nand-controller.c +++ b/drivers/mtd/nand/raw/atmel/nand-controller.c @@ -197,7 +197,7 @@ struct atmel_nand_controller_ops { int (*remove)(struct atmel_nand_controller *nc); void (*nand_init)(struct atmel_nand_controller *nc, struct atmel_nand *nand); - int (*ecc_init)(struct atmel_nand *nand); + int (*ecc_init)(struct nand_chip *chip); int (*setup_data_interface)(struct atmel_nand *nand, int csline, const struct nand_data_interface *conf); }; @@ -1128,9 +1128,8 @@ static int atmel_nand_pmecc_init(struct nand_chip *chip) return 0; } -static int atmel_nand_ecc_init(struct atmel_nand *nand) +static int atmel_nand_ecc_init(struct nand_chip *chip) { - struct nand_chip *chip = &nand->base; struct atmel_nand_controller *nc; int ret; @@ -1165,12 +1164,11 @@ static int atmel_nand_ecc_init(struct atmel_nand *nand) return 0; } -static int atmel_hsmc_nand_ecc_init(struct atmel_nand *nand) +static int atmel_hsmc_nand_ecc_init(struct nand_chip *chip) { - struct nand_chip *chip = &nand->base; int ret; - ret = atmel_nand_ecc_init(nand); + ret = atmel_nand_ecc_init(chip); if (ret) return ret; @@ -1553,22 +1551,6 @@ static void atmel_hsmc_nand_init(struct atmel_nand_controller *nc, chip->select_chip = atmel_hsmc_nand_select_chip; } -static int atmel_nand_detect(struct atmel_nand *nand) -{ - struct nand_chip *chip = &nand->base; - struct mtd_info *mtd = nand_to_mtd(chip); - struct atmel_nand_controller *nc; - int ret; - - nc = to_nand_controller(chip->controller); - - ret = nand_scan_ident(mtd, nand->numcs, NULL); - if (ret) - dev_err(nc->dev, "nand_scan_ident() failed: %d\n", ret); - - return ret; -} - static int atmel_nand_unregister(struct atmel_nand *nand) { struct nand_chip *chip = &nand->base; @@ -1590,7 +1572,6 @@ static int atmel_nand_register(struct atmel_nand *nand) struct nand_chip *chip = &nand->base; struct mtd_info *mtd = nand_to_mtd(chip); struct atmel_nand_controller *nc; - int ret; nc = to_nand_controller(chip->controller); @@ -1621,21 +1602,6 @@ static int atmel_nand_register(struct atmel_nand *nand) } } - ret = nand_scan_tail(mtd); - if (ret) { - dev_err(nc->dev, "nand_scan_tail() failed: %d\n", ret); - return ret; - } - - ret = mtd_device_register(mtd, NULL, 0); - if (ret) { - dev_err(nc->dev, "Failed to register mtd device: %d\n", ret); - nand_cleanup(chip); - return ret; - } - - list_add_tail(&nand->node, &nc->chips); - return 0; } @@ -1750,6 +1716,8 @@ static int atmel_nand_controller_add_nand(struct atmel_nand_controller *nc, struct atmel_nand *nand) { + struct nand_chip *chip = &nand->base; + struct mtd_info *mtd = nand_to_mtd(chip); int ret; /* No card inserted, skip this NAND. */ @@ -1760,15 +1728,31 @@ atmel_nand_controller_add_nand(struct atmel_nand_controller *nc, nc->caps->ops->nand_init(nc, nand); - ret = atmel_nand_detect(nand); - if (ret) + chip->ecc.attach_chip = nc->caps->ops->ecc_init; + ret = nand_scan(mtd, nand->numcs); + if (ret) { + dev_err(nc->dev, "NAND scan failed: %d\n", ret); return ret; + } - ret = nc->caps->ops->ecc_init(nand); + ret = atmel_nand_register(nand); if (ret) - return ret; + goto cleanup_nand; + + ret = mtd_device_register(mtd, NULL, 0); + if (ret) { + dev_err(nc->dev, "Failed to register mtd device: %d\n", ret); + goto cleanup_nand; + } + + list_add_tail(&nand->node, &nc->chips); + + return 0; + +cleanup_nand: + nand_cleanup(chip); - return atmel_nand_register(nand); + return ret; } static int