From patchwork Tue Oct 13 09:00:19 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Dooks X-Patchwork-Id: 35833 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 76926B7B88 for ; Tue, 13 Oct 2009 20:14:41 +1100 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1MxdIz-0004zc-Np; Tue, 13 Oct 2009 09:04:29 +0000 Received: from aeryn.fluff.org.uk ([87.194.8.8] helo=teyla.home.fluff.org) by bombadil.infradead.org with esmtps (Exim 4.69 #1 (Red Hat Linux)) id 1MxdIq-0004xg-Nq for linux-mtd@lists.infradead.org; Tue, 13 Oct 2009 09:04:26 +0000 Received: from ben by teyla.home.fluff.org with local (Exim 4.69) (envelope-from ) id 1MxdEx-0003XI-7E; Tue, 13 Oct 2009 10:00:19 +0100 Subject: NAND: Add flags to the probe calls to control scan behaviour Message-Id: <20091013090019.091262272@fluff.org.uk> User-Agent: quilt/0.46-1 From: Ben Dooks To: linux-mtd@lists.infradead.org Content-Disposition: inline; filename=nand-update-probe2.patch Date: Tue, 13 Oct 2009 10:00:19 +0100 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20091013_050421_092543_88AC8723 X-CRM114-Status: GOOD ( 12.63 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.2.5 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- _SUMMARY_ Cc: Simtec Linux Team X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Add a flags field to the two scan calls to control the behaviour of the scan process. Currently the only flag we define is NAND_PROBE_SPECULATIVE to stop the user-worrying messages 'No NAND device found!!!'. This message often worries users (was three exclamation marks really necessary?) and is even worse in systems such as the Simtec Osiris where there may be optional NAND devices which are not known until probe time. The approach is to change nand_scan_ident and nand_scan to have a new flags field, and add wrapper functions to the header files so that we do not have to get around all the drivers doing a search and replace. If we where to change all the call sites for nand_scan() and nand_scan_ident() we would touch about 40 drivers. Signed-off-by: Ben Dooks Signed-off-by: Simtec Linux Team --- drivers/mtd/nand/nand_base.c | 18 ++++++++++-------- include/linux/mtd/nand.h | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 40 insertions(+), 10 deletions(-) Index: b/drivers/mtd/nand/nand_base.c =================================================================== --- a/drivers/mtd/nand/nand_base.c 2009-10-12 19:12:56.000000000 +0100 +++ b/drivers/mtd/nand/nand_base.c 2009-10-12 19:23:41.000000000 +0100 @@ -2615,7 +2615,7 @@ static struct nand_flash_dev *nand_get_f } /** - * nand_scan_ident - [NAND Interface] Scan for the NAND device + * nand_scan_ident_flags - [NAND Interface] Scan for the NAND device * @mtd: MTD device structure * @maxchips: Number of chips to scan for * @@ -2624,7 +2624,7 @@ static struct nand_flash_dev *nand_get_f * * The mtd->owner field must be set to the module of the caller. */ -int nand_scan_ident(struct mtd_info *mtd, int maxchips) +int nand_scan_ident_flags(struct mtd_info *mtd, int maxchips, unsigned flags) { int i, busw, nand_maf_id; struct nand_chip *chip = mtd->priv; @@ -2639,7 +2639,8 @@ int nand_scan_ident(struct mtd_info *mtd type = nand_get_flash_type(mtd, chip, busw, &nand_maf_id); if (IS_ERR(type)) { - printk(KERN_WARNING "No NAND device found!!!\n"); + if (!(flags & NAND_PROBE_SPECULATIVE)) + printk(KERN_WARNING "No NAND device found!!!\n"); chip->select_chip(mtd, -1); return PTR_ERR(type); } @@ -2903,9 +2904,10 @@ int nand_scan_tail(struct mtd_info *mtd) #endif /** - * nand_scan - [NAND Interface] Scan for the NAND device + * nand_scan_flags - [NAND Interface] Scan for the NAND device * @mtd: MTD device structure * @maxchips: Number of chips to scan for + * @flags: The flags to pass to nand_scan_ident_flags(). * * This fills out all the uninitialized function pointers * with the defaults. @@ -2914,7 +2916,7 @@ int nand_scan_tail(struct mtd_info *mtd) * The mtd->owner field must be set to the module of the caller * */ -int nand_scan(struct mtd_info *mtd, int maxchips) +int nand_scan_flags(struct mtd_info *mtd, int maxchips, unsigned flags) { int ret; @@ -2925,7 +2927,7 @@ int nand_scan(struct mtd_info *mtd, int BUG(); } - ret = nand_scan_ident(mtd, maxchips); + ret = nand_scan_ident_flags(mtd, maxchips, flags); if (!ret) ret = nand_scan_tail(mtd); return ret; @@ -2952,8 +2954,8 @@ void nand_release(struct mtd_info *mtd) kfree(chip->buffers); } -EXPORT_SYMBOL_GPL(nand_scan); -EXPORT_SYMBOL_GPL(nand_scan_ident); +EXPORT_SYMBOL_GPL(nand_scan_flags); +EXPORT_SYMBOL_GPL(nand_scan_ident_flags); EXPORT_SYMBOL_GPL(nand_scan_tail); EXPORT_SYMBOL_GPL(nand_release); Index: b/include/linux/mtd/nand.h =================================================================== --- a/include/linux/mtd/nand.h 2009-10-12 19:13:45.000000000 +0100 +++ b/include/linux/mtd/nand.h 2009-10-12 19:23:14.000000000 +0100 @@ -22,14 +22,42 @@ #include #include +/* probe is only looking for the possibility of a chip, do not print + * authorative errors, etc. */ +#define NAND_PROBE_SPECULATIVE (1 << 0) + struct mtd_info; /* Scan and identify a NAND device */ -extern int nand_scan (struct mtd_info *mtd, int max_chips); +extern int nand_scan_flags(struct mtd_info *mtd, int max_chips, unsigned flags); /* Separate phases of nand_scan(), allowing board driver to intervene * and override command or ECC setup according to flash type */ -extern int nand_scan_ident(struct mtd_info *mtd, int max_chips); +extern int nand_scan_ident_flags(struct mtd_info *mtd, int max_chips, unsigned flags); extern int nand_scan_tail(struct mtd_info *mtd); +/** + * nand_scan - [NAND Interface] Scan for the NAND device + * @mtd: MTD device structure + * @maxchips: Number of chips to scan for + * + * Wrapper for nand_scan_flags() with flags set to zero (nothing). + */ +static inline int nand_scan(struct mtd_info *mtd, int max_chips) +{ + return nand_scan_flags(mtd, max_chips, 0); +} + +/** + * nand_scan_ident - [NAND Interface] Scan for the NAND device + * @mtd: MTD device structure + * @maxchips: Number of chips to scan for + * + * Wrapper for nand_scan_ident_flags() with flags set to zero (nothing). + */ +static inline int nand_scan_ident(struct mtd_info *mtd, int maxchips) +{ + return nand_scan_ident_flags(mtd, maxchips, 0); +} + /* Free resources held by the NAND device */ extern void nand_release (struct mtd_info *mtd);