Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2991201imm; Fri, 20 Jul 2018 08:17:49 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdA2lq0K9iIJxfQuSwNrcbTODSrLnCj7sYB6KffdA5Z0OF7LgZHhtU40pymCEFTze7DOrI1 X-Received: by 2002:a62:2352:: with SMTP id j79-v6mr2556491pfj.221.1532099869900; Fri, 20 Jul 2018 08:17:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532099869; cv=none; d=google.com; s=arc-20160816; b=ozrRwYqqvVKE+DqIagCgHyI1DwovriZQRFe293bHpguo66ZR3ySph20OuAc5z1WPIK oVg/d8GFegldGbydNT5cPhlPsmCaApb1p74bgQY0ZVbHhgy8jmnKqAI6rXBXj/iqURli YZUMPdiUlNkTaY5ukfkm0fy26g4MxoxfNYAiVgMI7XgKrwfYizOnCyYg6AAt+1789YHN Fiet5pSytw5+AltAK0x2aIYwdP4bm3FimqUJ9iczt6vJjwfSEEsVArSBJHqm2iegdFkV KnNtdwSn68a7zDwgrGn2lzJ9lKWH85EDMxgiJ8w2Rhl0VcGaA2boo7CQHkK/v/LE+92i WqZQ== 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=llOHYA3tYuDt+ecKtc+60BbbW/TaBjf6zpsgO9nueAk=; b=UONE6vOEj6xLL2CXs84LXqYsKQRd3fWzRStrbfqdz62FvvRxOj/4VoELhbKcm1bupC KHu/p+I+TNb1WpkaCTn8Tk1bJt63JWibmBX7dAYeOY1nfPHe05aSf+yfgJEpCcuvjZeW aEzr0m7VJeURBdq7gOMhdJMWEWSuM4MKxx+Bp0iGXeZbzPyYn+GGSuVe57LOsusJrylT cRttY3TWq2g0hvBszVCKcTXlutQRiTeoFhEHh6zI1Jca7tGisrq9qE9NcLyK06y/PW4Y 3R0Wa7lg1hj3PvQWeU6tgrI9nW41n7Hksa6iiiNt3BMbN+ny61qVmZrGqEF1N9f5MMe3 b/zg== 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 f1-v6si1843523plm.375.2018.07.20.08.17.34; Fri, 20 Jul 2018 08:17:49 -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 S2388226AbeGTQEu (ORCPT + 99 others); Fri, 20 Jul 2018 12:04:50 -0400 Received: from mail.bootlin.com ([62.4.15.54]:54566 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388099AbeGTQEr (ORCPT ); Fri, 20 Jul 2018 12:04:47 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 38B4320A31; 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 13963209B9; Fri, 20 Jul 2018 17:15:44 +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 27/35] mtd: rawnand: sm_common: convert driver to nand_scan_with_ids() Date: Fri, 20 Jul 2018 17:15:19 +0200 Message-Id: <20180720151527.16038-28-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_with_ids() (alternative to nand_scan() for passing a flash IDs table) instead of both nand_scan_ident() and nand_scan_tail(). Signed-off-by: Miquel Raynal --- drivers/mtd/nand/raw/sm_common.c | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/drivers/mtd/nand/raw/sm_common.c b/drivers/mtd/nand/raw/sm_common.c index 7f5044a79f01..d05e3f976a5e 100644 --- a/drivers/mtd/nand/raw/sm_common.c +++ b/drivers/mtd/nand/raw/sm_common.c @@ -160,19 +160,9 @@ static struct nand_flash_dev nand_xd_flash_ids[] = { {NULL} }; -int sm_register_device(struct mtd_info *mtd, int smartmedia) +static int sm_attach_chip(struct nand_chip *chip) { - struct nand_chip *chip = mtd_to_nand(mtd); - int ret; - - chip->options |= NAND_SKIP_BBTSCAN; - - /* Scan for card properties */ - ret = nand_scan_ident(mtd, 1, smartmedia ? - nand_smartmedia_flash_ids : nand_xd_flash_ids); - - if (ret) - return ret; + struct mtd_info *mtd = nand_to_mtd(chip); /* Bad block marker position */ chip->badblockpos = 0x05; @@ -187,12 +177,33 @@ int sm_register_device(struct mtd_info *mtd, int smartmedia) else return -ENODEV; - ret = nand_scan_tail(mtd); + return 0; +} +static const struct nand_controller_ops sm_controller_ops = { + .attach_chip = sm_attach_chip, +}; + +int sm_register_device(struct mtd_info *mtd, int smartmedia) +{ + struct nand_chip *chip = mtd_to_nand(mtd); + struct nand_flash_dev *flash_ids; + int ret; + + chip->options |= NAND_SKIP_BBTSCAN; + + /* Scan for card properties */ + chip->dummy_controller.ops = &sm_controller_ops; + flash_ids = smartmedia ? nand_smartmedia_flash_ids : nand_xd_flash_ids; + ret = nand_scan_with_ids(mtd, 1, flash_ids); if (ret) return ret; - return mtd_device_register(mtd, NULL, 0); + ret = mtd_device_register(mtd, NULL, 0); + if (ret) + nand_release(mtd); + + return ret; } EXPORT_SYMBOL_GPL(sm_register_device); -- 2.14.1