diff options
author | Ming Lei <tom.leiming@gmail.com> | 2009-02-06 10:40:12 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-03-24 19:38:25 -0400 |
commit | 7a192ec334cab9fafe3a8665a65af398b0e24730 (patch) | |
tree | eea572863500f94d446cfded69835e188dba3447 /drivers/mtd/nand | |
parent | 6da2d377bba06c29d0bc41c8dee014164dec82a7 (diff) |
platform driver: fix incorrect use of 'platform_bus_type' with 'struct device_driver'
This patch fixes the bug reported in
http://bugzilla.kernel.org/show_bug.cgi?id=11681.
"Lots of device drivers register a 'struct device_driver' with
the '.bus' member set to '&platform_bus_type'. This is wrong,
since the platform_bus functions expect the 'struct device_driver'
to be wrapped up in a 'struct platform_driver' which provides
some additional callbacks (like suspend_late, resume_early).
The effect may be that platform_suspend_late() uses bogus data
outside the device_driver struct as a pointer pointer to the
device driver's suspend_late() function or other hard to
reproduce failures."(Lothar Wassmann)
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Acked-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Acked-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/mtd/nand')
-rw-r--r-- | drivers/mtd/nand/excite_nandflash.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/drivers/mtd/nand/excite_nandflash.c b/drivers/mtd/nand/excite_nandflash.c index ced14b5294d5..72446fb48d4b 100644 --- a/drivers/mtd/nand/excite_nandflash.c +++ b/drivers/mtd/nand/excite_nandflash.c | |||
@@ -128,11 +128,11 @@ static int excite_nand_devready(struct mtd_info *mtd) | |||
128 | * The binding to the mtd and all allocated | 128 | * The binding to the mtd and all allocated |
129 | * resources are released. | 129 | * resources are released. |
130 | */ | 130 | */ |
131 | static int __exit excite_nand_remove(struct device *dev) | 131 | static int __exit excite_nand_remove(struct platform_device *dev) |
132 | { | 132 | { |
133 | struct excite_nand_drvdata * const this = dev_get_drvdata(dev); | 133 | struct excite_nand_drvdata * const this = platform_get_drvdata(dev); |
134 | 134 | ||
135 | dev_set_drvdata(dev, NULL); | 135 | platform_set_drvdata(dev, NULL); |
136 | 136 | ||
137 | if (unlikely(!this)) { | 137 | if (unlikely(!this)) { |
138 | printk(KERN_ERR "%s: called %s without private data!!", | 138 | printk(KERN_ERR "%s: called %s without private data!!", |
@@ -159,9 +159,8 @@ static int __exit excite_nand_remove(struct device *dev) | |||
159 | * it can allocate all necessary resources then calls the | 159 | * it can allocate all necessary resources then calls the |
160 | * nand layer to look for devices. | 160 | * nand layer to look for devices. |
161 | */ | 161 | */ |
162 | static int __init excite_nand_probe(struct device *dev) | 162 | static int __init excite_nand_probe(struct platform_device *pdev) |
163 | { | 163 | { |
164 | struct platform_device * const pdev = to_platform_device(dev); | ||
165 | struct excite_nand_drvdata *drvdata; /* private driver data */ | 164 | struct excite_nand_drvdata *drvdata; /* private driver data */ |
166 | struct nand_chip *board_chip; /* private flash chip data */ | 165 | struct nand_chip *board_chip; /* private flash chip data */ |
167 | struct mtd_info *board_mtd; /* mtd info for this board */ | 166 | struct mtd_info *board_mtd; /* mtd info for this board */ |
@@ -175,7 +174,7 @@ static int __init excite_nand_probe(struct device *dev) | |||
175 | } | 174 | } |
176 | 175 | ||
177 | /* bind private data into driver */ | 176 | /* bind private data into driver */ |
178 | dev_set_drvdata(dev, drvdata); | 177 | platform_set_drvdata(pdev, drvdata); |
179 | 178 | ||
180 | /* allocate and map the resource */ | 179 | /* allocate and map the resource */ |
181 | drvdata->regs = | 180 | drvdata->regs = |
@@ -219,23 +218,25 @@ static int __init excite_nand_probe(struct device *dev) | |||
219 | return 0; | 218 | return 0; |
220 | } | 219 | } |
221 | 220 | ||
222 | static struct device_driver excite_nand_driver = { | 221 | static struct platform_driver excite_nand_driver = { |
223 | .name = "excite_nand", | 222 | .driver = { |
224 | .bus = &platform_bus_type, | 223 | .name = "excite_nand", |
224 | .owner = THIS_MODULE, | ||
225 | }, | ||
225 | .probe = excite_nand_probe, | 226 | .probe = excite_nand_probe, |
226 | .remove = __exit_p(excite_nand_remove) | 227 | .remove = __devexit_p(excite_nand_remove) |
227 | }; | 228 | }; |
228 | 229 | ||
229 | static int __init excite_nand_init(void) | 230 | static int __init excite_nand_init(void) |
230 | { | 231 | { |
231 | pr_info("Basler eXcite nand flash driver Version " | 232 | pr_info("Basler eXcite nand flash driver Version " |
232 | EXCITE_NANDFLASH_VERSION "\n"); | 233 | EXCITE_NANDFLASH_VERSION "\n"); |
233 | return driver_register(&excite_nand_driver); | 234 | return platform_driver_register(&excite_nand_driver); |
234 | } | 235 | } |
235 | 236 | ||
236 | static void __exit excite_nand_exit(void) | 237 | static void __exit excite_nand_exit(void) |
237 | { | 238 | { |
238 | driver_unregister(&excite_nand_driver); | 239 | platform_driver_unregister(&excite_nand_driver); |
239 | } | 240 | } |
240 | 241 | ||
241 | module_init(excite_nand_init); | 242 | module_init(excite_nand_init); |