Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp4553379imm; Sat, 21 Jul 2018 23:45:50 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeOiW4hNxkyH5xEBUXxoWDb2Qg4Z4wQyG/v+ntoAjZmqJSrs5e1ctp+tz2i77pAAhN/+mL8 X-Received: by 2002:a62:3f44:: with SMTP id m65-v6mr470421pfa.98.1532241950207; Sat, 21 Jul 2018 23:45:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532241950; cv=none; d=google.com; s=arc-20160816; b=HlI92m/Deewjjck3t1zWPUTuOPmM+Wj6/nLmF3ETMLtNIq3KBA8nR9yQuG0PuplFfo TSJlFFr2roECvZ9FXU9xIZh1RIEGpJlc1IYnONwLDfC4dgya3SWVHwy+Mdo8sy0TwRGA eeR031cQ1m630/b/YVdMnuAcOa0RguPQ1B2oxanW01rG8cj1L30vI6+oUCJ3UH8wawCS 7p9Lbb684ry/dcLB7tRtu4qVkvgQhsWtHYjYOckUWIgoXqADfIDHAyeIZpwXFRnD9O2L CpNWaDolPr36cISHkIwalJjMcdb0ZXi4kfeZ72MTQy2tFa6VmtdeC4A+OuzgQ3kyunQS rUFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=yaaljz8NJCm8SAUh36sueprL5cBlpV4bKs5Hac3+KEs=; b=iL8dc9k8cJW3s0Q6zECUVvIsHdgX8iTvf2EZCg2guDP6/0coYjf0R2X0VmkTBpd0+I jl1wi1IQ6RKkfyrfK5kr/ZOnb71c5bFzmNADKKDfwBG2pnOiSUsAF1as2wgZwUPSPIbj 0wLsoOgtpa0q4Myn6Cw+68QKPZD3ntPmwdh+Hhi7KNRB38eGZBQmrh3NubDY289ltqJJ zSPqFKlP5tbN2cVYlgdzzO+S9odAAoFfUBRPR3h2lCO3d3UcA5b67q9eeQ2nhj0ap5Hj ZRCoI7TK5ghUTfEINRTfYyqXWeqapr9+IwSXFoL9tO9DyjyVi6YSMFNK7UCcTQciLFUx niyQ== 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 9-v6si5507526pla.59.2018.07.21.23.45.35; Sat, 21 Jul 2018 23:45:50 -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 S1727981AbeGVHkY (ORCPT + 99 others); Sun, 22 Jul 2018 03:40:24 -0400 Received: from mail.bootlin.com ([62.4.15.54]:58361 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727764AbeGVHkY (ORCPT ); Sun, 22 Jul 2018 03:40:24 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 993F1206A6; Sun, 22 Jul 2018 08:44:45 +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 bbrezillon (unknown [37.173.105.99]) by mail.bootlin.com (Postfix) with ESMTPSA id B6BCF203EC; Sun, 22 Jul 2018 08:44:33 +0200 (CEST) Date: Sun, 22 Jul 2018 08:44:32 +0200 From: Boris Brezillon To: Miquel Raynal Cc: Wenyou Yang , Josh Wu , Tudor Ambarus , 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 , 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: Re: [PATCH v4 27/35] mtd: rawnand: sm_common: convert driver to nand_scan_with_ids() Message-ID: <20180722084432.61b579b1@bbrezillon> In-Reply-To: <20180720151527.16038-28-miquel.raynal@bootlin.com> References: <20180720151527.16038-1-miquel.raynal@bootlin.com> <20180720151527.16038-28-miquel.raynal@bootlin.com> X-Mailer: Claws Mail 3.15.0-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 20 Jul 2018 17:15:19 +0200 Miquel Raynal wrote: > 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 Reviewed-by: Boris Brezillon > --- > 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); >