diff options
author | David Woodhouse <dwmw2@infradead.org> | 2006-05-14 11:54:39 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@infradead.org> | 2006-05-14 11:54:39 -0400 |
commit | 52239da1b06ff445bf71d35e04d8ce74e4c6fe7b (patch) | |
tree | b33fe34d8a641600fbddb8dda7f4706c70026346 /drivers | |
parent | 0d4e30d26a279f1b6a008a233a6835ad2af571e4 (diff) |
[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>
Diffstat (limited to 'drivers')
-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 42cff0a2b93d..08dffb7a9389 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) | |||
2312 | 2312 | ||
2313 | } | 2313 | } |
2314 | 2314 | ||
2315 | /* module_text_address() isn't exported, and it's mostly a pointless | ||
2316 | test if this is a module _anyway_ -- they'd have to try _really_ hard | ||
2317 | to call us from in-kernel code if the core NAND support is modular. */ | ||
2318 | #ifdef MODULE | ||
2319 | #define caller_is_module() (1) | ||
2320 | #else | ||
2321 | #define caller_is_module() module_text_address((unsigned long)__builtin_return_address(0)) | ||
2322 | #endif | ||
2323 | |||
2315 | /** | 2324 | /** |
2316 | * nand_scan - [NAND Interface] Scan for the NAND device | 2325 | * nand_scan - [NAND Interface] Scan for the NAND device |
2317 | * @mtd: MTD device structure | 2326 | * @mtd: MTD device structure |
@@ -2330,12 +2339,8 @@ int nand_scan(struct mtd_info *mtd, int maxchips) | |||
2330 | int i, nand_maf_id, nand_dev_id, busw, maf_id; | 2339 | int i, nand_maf_id, nand_dev_id, busw, maf_id; |
2331 | struct nand_chip *this = mtd->priv; | 2340 | struct nand_chip *this = mtd->priv; |
2332 | 2341 | ||
2333 | /* module_text_address() isn't exported. But if _this_ is a module, | 2342 | /* Many callers got this wrong, so check for it for a while... */ |
2334 | it's a fairly safe bet that its caller is a module too... and | 2343 | if (!mtd->owner && caller_is_module()) { |
2335 | that means the call to module_text_address() gets optimised out | ||
2336 | without having to resort to ifdefs */ | ||
2337 | if (!mtd->owner && (THIS_MODULE || | ||
2338 | module_text_address((unsigned long)__builtin_return_address(0)))) { | ||
2339 | printk(KERN_CRIT "nand_scan() called with NULL mtd->owner!\n"); | 2344 | printk(KERN_CRIT "nand_scan() called with NULL mtd->owner!\n"); |
2340 | BUG(); | 2345 | BUG(); |
2341 | } | 2346 | } |