diff options
author | David Woodhouse <dwmw2@infradead.org> | 2006-05-13 20:20:46 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@infradead.org> | 2006-05-13 20:20:46 -0400 |
commit | 552d9205186428a1e2a49ed577bcbba9f777af37 (patch) | |
tree | d61e09abae0ad18a3beef281384e576d8a54c145 /drivers/mtd/nand | |
parent | 4f678a58d335291ce9213c049bbe16e6d24487ed (diff) |
[MTD] Fix module refcounting in NAND board drivers.
The _board_ driver needs to be mtd->owner, and it in turn pins the
nand.ko module. Fix them all to actually do that, and fix nand.ko not to
overwrite it -- and also to check that the caller sets it, if the caller
is a module.
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to 'drivers/mtd/nand')
-rw-r--r-- | drivers/mtd/nand/au1550nd.c | 1 | ||||
-rw-r--r-- | drivers/mtd/nand/autcpu12.c | 1 | ||||
-rw-r--r-- | drivers/mtd/nand/cs553x_nand.c | 2 | ||||
-rw-r--r-- | drivers/mtd/nand/edb7312.c | 1 | ||||
-rw-r--r-- | drivers/mtd/nand/h1910.c | 1 | ||||
-rw-r--r-- | drivers/mtd/nand/nand_base.c | 16 | ||||
-rw-r--r-- | drivers/mtd/nand/nandsim.c | 2 | ||||
-rw-r--r-- | drivers/mtd/nand/ppchameleonevb.c | 1 | ||||
-rw-r--r-- | drivers/mtd/nand/rtc_from4.c | 1 | ||||
-rw-r--r-- | drivers/mtd/nand/s3c2410.c | 1 | ||||
-rw-r--r-- | drivers/mtd/nand/sharpsl.c | 1 | ||||
-rw-r--r-- | drivers/mtd/nand/spia.c | 1 | ||||
-rw-r--r-- | drivers/mtd/nand/toto.c | 1 | ||||
-rw-r--r-- | drivers/mtd/nand/ts7250.c | 1 |
14 files changed, 27 insertions, 4 deletions
diff --git a/drivers/mtd/nand/au1550nd.c b/drivers/mtd/nand/au1550nd.c index 50cbfd4826fb..87d34351a86d 100644 --- a/drivers/mtd/nand/au1550nd.c +++ b/drivers/mtd/nand/au1550nd.c | |||
@@ -345,6 +345,7 @@ int __init au1xxx_nand_init(void) | |||
345 | 345 | ||
346 | /* Link the private data with the MTD structure */ | 346 | /* Link the private data with the MTD structure */ |
347 | au1550_mtd->priv = this; | 347 | au1550_mtd->priv = this; |
348 | au1550_mtd->owner = THIS_MODULE; | ||
348 | 349 | ||
349 | /* disable interrupts */ | 350 | /* disable interrupts */ |
350 | au_writel(au_readl(MEM_STNDCTL) & ~(1 << 8), MEM_STNDCTL); | 351 | au_writel(au_readl(MEM_STNDCTL) & ~(1 << 8), MEM_STNDCTL); |
diff --git a/drivers/mtd/nand/autcpu12.c b/drivers/mtd/nand/autcpu12.c index 9c9f21b0d260..330deb032217 100644 --- a/drivers/mtd/nand/autcpu12.c +++ b/drivers/mtd/nand/autcpu12.c | |||
@@ -154,6 +154,7 @@ int __init autcpu12_init(void) | |||
154 | 154 | ||
155 | /* Link the private data with the MTD structure */ | 155 | /* Link the private data with the MTD structure */ |
156 | autcpu12_mtd->priv = this; | 156 | autcpu12_mtd->priv = this; |
157 | autcpu12_mtd->owner = THIS_MODULE; | ||
157 | 158 | ||
158 | /* Set address of NAND IO lines */ | 159 | /* Set address of NAND IO lines */ |
159 | this->IO_ADDR_R = autcpu12_fio_base; | 160 | this->IO_ADDR_R = autcpu12_fio_base; |
diff --git a/drivers/mtd/nand/cs553x_nand.c b/drivers/mtd/nand/cs553x_nand.c index fba7be5cffe3..d5b05514bb8b 100644 --- a/drivers/mtd/nand/cs553x_nand.c +++ b/drivers/mtd/nand/cs553x_nand.c | |||
@@ -223,6 +223,7 @@ static int __init cs553x_init_one(int cs, int mmio, unsigned long adr) | |||
223 | 223 | ||
224 | /* Link the private data with the MTD structure */ | 224 | /* Link the private data with the MTD structure */ |
225 | new_mtd->priv = this; | 225 | new_mtd->priv = this; |
226 | new_mtd->owner = THIS_MODULE; | ||
226 | 227 | ||
227 | /* map physical address */ | 228 | /* map physical address */ |
228 | this->IO_ADDR_R = this->IO_ADDR_W = ioremap(adr, 4096); | 229 | this->IO_ADDR_R = this->IO_ADDR_W = ioremap(adr, 4096); |
@@ -255,7 +256,6 @@ static int __init cs553x_init_one(int cs, int mmio, unsigned long adr) | |||
255 | goto out_ior; | 256 | goto out_ior; |
256 | } | 257 | } |
257 | 258 | ||
258 | new_mtd->owner = THIS_MODULE; | ||
259 | cs553x_mtd[cs] = new_mtd; | 259 | cs553x_mtd[cs] = new_mtd; |
260 | goto out; | 260 | goto out; |
261 | 261 | ||
diff --git a/drivers/mtd/nand/edb7312.c b/drivers/mtd/nand/edb7312.c index 8467d770710c..ad4488abfb0b 100644 --- a/drivers/mtd/nand/edb7312.c +++ b/drivers/mtd/nand/edb7312.c | |||
@@ -148,6 +148,7 @@ static int __init ep7312_init(void) | |||
148 | 148 | ||
149 | /* Link the private data with the MTD structure */ | 149 | /* Link the private data with the MTD structure */ |
150 | ep7312_mtd->priv = this; | 150 | ep7312_mtd->priv = this; |
151 | ep7312_mtd->owner = THIS_MODULE; | ||
151 | 152 | ||
152 | /* | 153 | /* |
153 | * Set GPIO Port B control register so that the pins are configured | 154 | * Set GPIO Port B control register so that the pins are configured |
diff --git a/drivers/mtd/nand/h1910.c b/drivers/mtd/nand/h1910.c index efa53a9adf23..b47a15c23d1c 100644 --- a/drivers/mtd/nand/h1910.c +++ b/drivers/mtd/nand/h1910.c | |||
@@ -135,6 +135,7 @@ static int __init h1910_init(void) | |||
135 | 135 | ||
136 | /* Link the private data with the MTD structure */ | 136 | /* Link the private data with the MTD structure */ |
137 | h1910_nand_mtd->priv = this; | 137 | h1910_nand_mtd->priv = this; |
138 | h1910_nand_mtd->owner = THIS_MODULE; | ||
138 | 139 | ||
139 | /* | 140 | /* |
140 | * Enable VPEN | 141 | * Enable VPEN |
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index fdaf32083ada..42cff0a2b93d 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c | |||
@@ -69,6 +69,7 @@ | |||
69 | * | 69 | * |
70 | */ | 70 | */ |
71 | 71 | ||
72 | #include <linux/module.h> | ||
72 | #include <linux/delay.h> | 73 | #include <linux/delay.h> |
73 | #include <linux/errno.h> | 74 | #include <linux/errno.h> |
74 | #include <linux/sched.h> | 75 | #include <linux/sched.h> |
@@ -2316,11 +2317,12 @@ static void nand_resume(struct mtd_info *mtd) | |||
2316 | * @mtd: MTD device structure | 2317 | * @mtd: MTD device structure |
2317 | * @maxchips: Number of chips to scan for | 2318 | * @maxchips: Number of chips to scan for |
2318 | * | 2319 | * |
2319 | * This fills out all the not initialized function pointers | 2320 | * This fills out all the uninitialized function pointers |
2320 | * with the defaults. | 2321 | * with the defaults. |
2321 | * The flash ID is read and the mtd/chip structures are | 2322 | * The flash ID is read and the mtd/chip structures are |
2322 | * filled with the appropriate values. Buffers are allocated if | 2323 | * filled with the appropriate values. Buffers are allocated if |
2323 | * they are not provided by the board driver | 2324 | * they are not provided by the board driver |
2325 | * The mtd->owner field must be set to the module of the caller | ||
2324 | * | 2326 | * |
2325 | */ | 2327 | */ |
2326 | int nand_scan(struct mtd_info *mtd, int maxchips) | 2328 | int nand_scan(struct mtd_info *mtd, int maxchips) |
@@ -2328,6 +2330,16 @@ int nand_scan(struct mtd_info *mtd, int maxchips) | |||
2328 | int i, nand_maf_id, nand_dev_id, busw, maf_id; | 2330 | int i, nand_maf_id, nand_dev_id, busw, maf_id; |
2329 | struct nand_chip *this = mtd->priv; | 2331 | struct nand_chip *this = mtd->priv; |
2330 | 2332 | ||
2333 | /* module_text_address() isn't exported. But if _this_ is a module, | ||
2334 | it's a fairly safe bet that its caller is a module too... and | ||
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"); | ||
2340 | BUG(); | ||
2341 | } | ||
2342 | |||
2331 | /* Get buswidth to select the correct functions */ | 2343 | /* Get buswidth to select the correct functions */ |
2332 | busw = this->options & NAND_BUSWIDTH_16; | 2344 | busw = this->options & NAND_BUSWIDTH_16; |
2333 | 2345 | ||
@@ -2676,8 +2688,6 @@ int nand_scan(struct mtd_info *mtd, int maxchips) | |||
2676 | /* and make the autooob the default one */ | 2688 | /* and make the autooob the default one */ |
2677 | memcpy(&mtd->oobinfo, this->autooob, sizeof(mtd->oobinfo)); | 2689 | memcpy(&mtd->oobinfo, this->autooob, sizeof(mtd->oobinfo)); |
2678 | 2690 | ||
2679 | mtd->owner = THIS_MODULE; | ||
2680 | |||
2681 | /* Check, if we should skip the bad block table scan */ | 2691 | /* Check, if we should skip the bad block table scan */ |
2682 | if (this->options & NAND_SKIP_BBTSCAN) | 2692 | if (this->options & NAND_SKIP_BBTSCAN) |
2683 | return 0; | 2693 | return 0; |
diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c index a0af92cc7efd..6903f5b903c6 100644 --- a/drivers/mtd/nand/nandsim.c +++ b/drivers/mtd/nand/nandsim.c | |||
@@ -1546,6 +1546,8 @@ static int __init ns_init_module(void) | |||
1546 | chip->options |= NAND_BUSWIDTH_16; | 1546 | chip->options |= NAND_BUSWIDTH_16; |
1547 | } | 1547 | } |
1548 | 1548 | ||
1549 | nsmtd->owner = THIS_MODULE; | ||
1550 | |||
1549 | if ((retval = nand_scan(nsmtd, 1)) != 0) { | 1551 | if ((retval = nand_scan(nsmtd, 1)) != 0) { |
1550 | NS_ERR("can't register NAND Simulator\n"); | 1552 | NS_ERR("can't register NAND Simulator\n"); |
1551 | if (retval > 0) | 1553 | if (retval > 0) |
diff --git a/drivers/mtd/nand/ppchameleonevb.c b/drivers/mtd/nand/ppchameleonevb.c index 405beece9c5a..5d4d16fb1df6 100644 --- a/drivers/mtd/nand/ppchameleonevb.c +++ b/drivers/mtd/nand/ppchameleonevb.c | |||
@@ -221,6 +221,7 @@ static int __init ppchameleonevb_init(void) | |||
221 | 221 | ||
222 | /* Link the private data with the MTD structure */ | 222 | /* Link the private data with the MTD structure */ |
223 | ppchameleon_mtd->priv = this; | 223 | ppchameleon_mtd->priv = this; |
224 | ppchameleon_mtd->owner = THIS_MODULE; | ||
224 | 225 | ||
225 | /* Initialize GPIOs */ | 226 | /* Initialize GPIOs */ |
226 | /* Pin mapping for NAND chip */ | 227 | /* Pin mapping for NAND chip */ |
diff --git a/drivers/mtd/nand/rtc_from4.c b/drivers/mtd/nand/rtc_from4.c index 1887989fb885..0c56a6629128 100644 --- a/drivers/mtd/nand/rtc_from4.c +++ b/drivers/mtd/nand/rtc_from4.c | |||
@@ -538,6 +538,7 @@ int __init rtc_from4_init(void) | |||
538 | 538 | ||
539 | /* Link the private data with the MTD structure */ | 539 | /* Link the private data with the MTD structure */ |
540 | rtc_from4_mtd->priv = this; | 540 | rtc_from4_mtd->priv = this; |
541 | rtc_from4_mtd->owner = THIS_MODULE; | ||
541 | 542 | ||
542 | /* set area 5 as PCMCIA mode to clear the spec of tDH(Data hold time;9ns min) */ | 543 | /* set area 5 as PCMCIA mode to clear the spec of tDH(Data hold time;9ns min) */ |
543 | bcr1 = *SH77X9_BCR1 & ~0x0002; | 544 | bcr1 = *SH77X9_BCR1 & ~0x0002; |
diff --git a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c index 338fda87b9e5..f8002596de8b 100644 --- a/drivers/mtd/nand/s3c2410.c +++ b/drivers/mtd/nand/s3c2410.c | |||
@@ -516,6 +516,7 @@ static void s3c2410_nand_init_chip(struct s3c2410_nand_info *info, | |||
516 | 516 | ||
517 | nmtd->info = info; | 517 | nmtd->info = info; |
518 | nmtd->mtd.priv = chip; | 518 | nmtd->mtd.priv = chip; |
519 | nmtd->mtd.owner = THIS_MODULE; | ||
519 | nmtd->set = set; | 520 | nmtd->set = set; |
520 | 521 | ||
521 | if (hardware_ecc) { | 522 | if (hardware_ecc) { |
diff --git a/drivers/mtd/nand/sharpsl.c b/drivers/mtd/nand/sharpsl.c index 25322a8d44d8..d375cb3e77d6 100644 --- a/drivers/mtd/nand/sharpsl.c +++ b/drivers/mtd/nand/sharpsl.c | |||
@@ -185,6 +185,7 @@ int __init sharpsl_nand_init(void) | |||
185 | 185 | ||
186 | /* Link the private data with the MTD structure */ | 186 | /* Link the private data with the MTD structure */ |
187 | sharpsl_mtd->priv = this; | 187 | sharpsl_mtd->priv = this; |
188 | sharpsl_mtd->owner = THIS_MODULE; | ||
188 | 189 | ||
189 | /* | 190 | /* |
190 | * PXA initialize | 191 | * PXA initialize |
diff --git a/drivers/mtd/nand/spia.c b/drivers/mtd/nand/spia.c index a11354b9afa2..b06aada31f79 100644 --- a/drivers/mtd/nand/spia.c +++ b/drivers/mtd/nand/spia.c | |||
@@ -121,6 +121,7 @@ int __init spia_init(void) | |||
121 | 121 | ||
122 | /* Link the private data with the MTD structure */ | 122 | /* Link the private data with the MTD structure */ |
123 | spia_mtd->priv = this; | 123 | spia_mtd->priv = this; |
124 | spia_mtd->owner = THIS_MODULE; | ||
124 | 125 | ||
125 | /* | 126 | /* |
126 | * Set GPIO Port E control register so that the pins are configured | 127 | * Set GPIO Port E control register so that the pins are configured |
diff --git a/drivers/mtd/nand/toto.c b/drivers/mtd/nand/toto.c index e3a90e60e249..24cfa9e2e025 100644 --- a/drivers/mtd/nand/toto.c +++ b/drivers/mtd/nand/toto.c | |||
@@ -137,6 +137,7 @@ int __init toto_init(void) | |||
137 | 137 | ||
138 | /* Link the private data with the MTD structure */ | 138 | /* Link the private data with the MTD structure */ |
139 | toto_mtd->priv = this; | 139 | toto_mtd->priv = this; |
140 | toto_mtd->owner = THIS_MODULE; | ||
140 | 141 | ||
141 | /* Set address of NAND IO lines */ | 142 | /* Set address of NAND IO lines */ |
142 | this->IO_ADDR_R = toto_io_base; | 143 | this->IO_ADDR_R = toto_io_base; |
diff --git a/drivers/mtd/nand/ts7250.c b/drivers/mtd/nand/ts7250.c index d2b7d57ace42..756ef64b0efd 100644 --- a/drivers/mtd/nand/ts7250.c +++ b/drivers/mtd/nand/ts7250.c | |||
@@ -147,6 +147,7 @@ static int __init ts7250_init(void) | |||
147 | 147 | ||
148 | /* Link the private data with the MTD structure */ | 148 | /* Link the private data with the MTD structure */ |
149 | ts7250_mtd->priv = this; | 149 | ts7250_mtd->priv = this; |
150 | ts7250_mtd->owner = THIS_MODULE; | ||
150 | 151 | ||
151 | /* insert callbacks */ | 152 | /* insert callbacks */ |
152 | this->IO_ADDR_R = (void *)TS72XX_NAND_DATA_VIRT_BASE; | 153 | this->IO_ADDR_R = (void *)TS72XX_NAND_DATA_VIRT_BASE; |