diff options
author | David Woodhouse <dwmw2@infradead.org> | 2006-05-14 16:54:39 +0100 |
---|---|---|
committer | David Woodhouse <dwmw2@infradead.org> | 2006-05-14 16:54:39 +0100 |
commit | 52239da1b06ff445bf71d35e04d8ce74e4c6fe7b (patch) | |
tree | b33fe34d8a641600fbddb8dda7f4706c70026346 | |
parent | 0d4e30d26a279f1b6a008a233a6835ad2af571e4 (diff) | |
download | linux-3.10-52239da1b06ff445bf71d35e04d8ce74e4c6fe7b.tar.gz linux-3.10-52239da1b06ff445bf71d35e04d8ce74e4c6fe7b.tar.bz2 linux-3.10-52239da1b06ff445bf71d35e04d8ce74e4c6fe7b.zip |
[MTD NAND] Modify check for modules registering NAND devices without ->owner
Make it work even with compilers which lack the wit to notice that
THIS_MODULE is always non-NULL. Use #ifdef MODULE instead. It's only
a temporary debugging check anyway.
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
-rw-r--r-- | drivers/mtd/nand/nand_base.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 42cff0a2b93..08dffb7a938 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -2312,6 +2312,15 @@ static void nand_resume(struct mtd_info *mtd) } +/* module_text_address() isn't exported, and it's mostly a pointless + test if this is a module _anyway_ -- they'd have to try _really_ hard + to call us from in-kernel code if the core NAND support is modular. */ +#ifdef MODULE +#define caller_is_module() (1) +#else +#define caller_is_module() module_text_address((unsigned long)__builtin_return_address(0)) +#endif + /** * nand_scan - [NAND Interface] Scan for the NAND device * @mtd: MTD device structure @@ -2330,12 +2339,8 @@ int nand_scan(struct mtd_info *mtd, int maxchips) int i, nand_maf_id, nand_dev_id, busw, maf_id; struct nand_chip *this = mtd->priv; - /* module_text_address() isn't exported. But if _this_ is a module, - it's a fairly safe bet that its caller is a module too... and - that means the call to module_text_address() gets optimised out - without having to resort to ifdefs */ - if (!mtd->owner && (THIS_MODULE || - module_text_address((unsigned long)__builtin_return_address(0)))) { + /* Many callers got this wrong, so check for it for a while... */ + if (!mtd->owner && caller_is_module()) { printk(KERN_CRIT "nand_scan() called with NULL mtd->owner!\n"); BUG(); } |