Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2992569imm; Fri, 20 Jul 2018 08:19:10 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcKxghi3rP/uBa8dB8hkxJhfB2qCy29vaOPMYG3iXeidtHocgl+cXd9qvM28kDqy+CDrQvK X-Received: by 2002:a62:8995:: with SMTP id n21-v6mr2605134pfk.83.1532099950720; Fri, 20 Jul 2018 08:19:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532099950; cv=none; d=google.com; s=arc-20160816; b=pPREhlRs61SDUx0Rj4DqlyRKsbXyaSOYy+ajaRrnyTnbPAvMzxi8S0PdmW8yCPcwcE O3KJUPZv7deKi6sUbuM0xySA0Cp1brIyKF0p4+4sSG+yDVGGbLJ3oZ2A2SKMWZMcRsrr TyZ53cb2pTt+k4I+a2Gc5SXi0tSJ0U5LCTxO8LdtOgQZJmrzF9+2uz6H5tLFVjNYZ2FS N4NBMiPUkgH9vEiOhFSU1rBRXX7IcvVwd91sQj+SHFLeI/1uO6mxIjXh8DsySXzlCH6u MdLe+Q68Mq4N6XeWjsU9cnPGayONK1dKm/DUtOVVt0UACv5/UzDNe+K+OnLYkhlLmuoi fBGg== 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=dlDptm0TjJ53wI0pq9H6jcwDBQyA9TLVCxsYAHnpaDM=; b=QEQIM+/fuYW/wbgb2cshfpnvVkW01Lhsd5ag2Vx889jCew1CAoyt0nRdNGqsP5ARJK TM0Jd0eckfiEKqNOx4McSAt9IrAgR0YrHZ2cdKVGTK+ooT2JPsK8a0zMU0HzOzDZ6JUR ain9cGExoj5Pa2k4rel2YWbAC1qI1tWSJJJhnnOv14AsXZUboEbfy76QwvNaCb8mvRlS JHtIjBVo/o0Owa6ZUAF2o8T+rBNLxKJxL0sFRDltciWTF/QNbwDutOuohXwG2eqUvVRY CiEbgROKAuQWosUx07oCgR9OATgFkKK2Pc7K75DfREJEhO6OrI/wVSN8FGlVk6XQglYB BWRA== 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 bc12-v6si1820712plb.373.2018.07.20.08.18.55; Fri, 20 Jul 2018 08:19:10 -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 S2388004AbeGTQGX (ORCPT + 99 others); Fri, 20 Jul 2018 12:06:23 -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 S2387933AbeGTQEq (ORCPT ); Fri, 20 Jul 2018 12:04:46 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id EFF7C2097A; Fri, 20 Jul 2018 17:15:59 +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 31A51207B4; Fri, 20 Jul 2018 17:15:41 +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 22/35] mtd: rawnand: tango: convert driver to nand_scan() Date: Fri, 20 Jul 2018 17:15:14 +0200 Message-Id: <20180720151527.16038-23-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/tango_nand.c | 40 +++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/drivers/mtd/nand/raw/tango_nand.c b/drivers/mtd/nand/raw/tango_nand.c index dd7a26efdf4f..a448d0797cd5 100644 --- a/drivers/mtd/nand/raw/tango_nand.c +++ b/drivers/mtd/nand/raw/tango_nand.c @@ -517,6 +517,28 @@ static int tango_set_timings(struct mtd_info *mtd, int csline, return 0; } +static int tango_attach_chip(struct nand_chip *chip) +{ + struct nand_ecc_ctrl *ecc = &chip->ecc; + + ecc->mode = NAND_ECC_HW; + ecc->algo = NAND_ECC_BCH; + ecc->bytes = DIV_ROUND_UP(ecc->strength * FIELD_ORDER, BITS_PER_BYTE); + + ecc->read_page_raw = tango_read_page_raw; + ecc->write_page_raw = tango_write_page_raw; + ecc->read_page = tango_read_page; + ecc->write_page = tango_write_page; + ecc->read_oob = tango_read_oob; + ecc->write_oob = tango_write_oob; + + return 0; +} + +static const struct nand_controller_ops tango_controller_ops = { + .attach_chip = tango_attach_chip, +}; + static int chip_init(struct device *dev, struct device_node *np) { u32 cs; @@ -560,28 +582,14 @@ static int chip_init(struct device *dev, struct device_node *np) NAND_NO_SUBPAGE_WRITE | NAND_WAIT_TCCS; chip->controller = &nfc->hw; + chip->controller->ops = &tango_controller_ops; tchip->base = nfc->pbus_base + (cs * 256); nand_set_flash_node(chip, np); mtd_set_ooblayout(mtd, &tango_nand_ooblayout_ops); mtd->dev.parent = dev; - err = nand_scan_ident(mtd, 1, NULL); - if (err) - return err; - - ecc->mode = NAND_ECC_HW; - ecc->algo = NAND_ECC_BCH; - ecc->bytes = DIV_ROUND_UP(ecc->strength * FIELD_ORDER, BITS_PER_BYTE); - - ecc->read_page_raw = tango_read_page_raw; - ecc->write_page_raw = tango_write_page_raw; - ecc->read_page = tango_read_page; - ecc->write_page = tango_write_page; - ecc->read_oob = tango_read_oob; - ecc->write_oob = tango_write_oob; - - err = nand_scan_tail(mtd); + err = nand_scan(mtd, 1); if (err) return err; -- 2.14.1