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/maps | |
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/maps')
-rw-r--r-- | drivers/mtd/maps/pxa2xx-flash.c | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/drivers/mtd/maps/pxa2xx-flash.c b/drivers/mtd/maps/pxa2xx-flash.c index 771139c5bf87..e9026cb1c5b2 100644 --- a/drivers/mtd/maps/pxa2xx-flash.c +++ b/drivers/mtd/maps/pxa2xx-flash.c | |||
@@ -41,9 +41,8 @@ struct pxa2xx_flash_info { | |||
41 | static const char *probes[] = { "RedBoot", "cmdlinepart", NULL }; | 41 | static const char *probes[] = { "RedBoot", "cmdlinepart", NULL }; |
42 | 42 | ||
43 | 43 | ||
44 | static int __init pxa2xx_flash_probe(struct device *dev) | 44 | static int __init pxa2xx_flash_probe(struct platform_device *pdev) |
45 | { | 45 | { |
46 | struct platform_device *pdev = to_platform_device(dev); | ||
47 | struct flash_platform_data *flash = pdev->dev.platform_data; | 46 | struct flash_platform_data *flash = pdev->dev.platform_data; |
48 | struct pxa2xx_flash_info *info; | 47 | struct pxa2xx_flash_info *info; |
49 | struct mtd_partition *parts; | 48 | struct mtd_partition *parts; |
@@ -114,15 +113,15 @@ static int __init pxa2xx_flash_probe(struct device *dev) | |||
114 | add_mtd_device(info->mtd); | 113 | add_mtd_device(info->mtd); |
115 | } | 114 | } |
116 | 115 | ||
117 | dev_set_drvdata(dev, info); | 116 | platform_set_drvdata(pdev, info); |
118 | return 0; | 117 | return 0; |
119 | } | 118 | } |
120 | 119 | ||
121 | static int __exit pxa2xx_flash_remove(struct device *dev) | 120 | static int __exit pxa2xx_flash_remove(struct platform_device *dev) |
122 | { | 121 | { |
123 | struct pxa2xx_flash_info *info = dev_get_drvdata(dev); | 122 | struct pxa2xx_flash_info *info = platform_get_drvdata(dev); |
124 | 123 | ||
125 | dev_set_drvdata(dev, NULL); | 124 | platform_set_drvdata(dev, NULL); |
126 | 125 | ||
127 | #ifdef CONFIG_MTD_PARTITIONS | 126 | #ifdef CONFIG_MTD_PARTITIONS |
128 | if (info->nr_parts) | 127 | if (info->nr_parts) |
@@ -141,9 +140,9 @@ static int __exit pxa2xx_flash_remove(struct device *dev) | |||
141 | } | 140 | } |
142 | 141 | ||
143 | #ifdef CONFIG_PM | 142 | #ifdef CONFIG_PM |
144 | static int pxa2xx_flash_suspend(struct device *dev, pm_message_t state) | 143 | static int pxa2xx_flash_suspend(struct platform_device *dev, pm_message_t state) |
145 | { | 144 | { |
146 | struct pxa2xx_flash_info *info = dev_get_drvdata(dev); | 145 | struct pxa2xx_flash_info *info = platform_get_drvdata(dev); |
147 | int ret = 0; | 146 | int ret = 0; |
148 | 147 | ||
149 | if (info->mtd && info->mtd->suspend) | 148 | if (info->mtd && info->mtd->suspend) |
@@ -151,17 +150,17 @@ static int pxa2xx_flash_suspend(struct device *dev, pm_message_t state) | |||
151 | return ret; | 150 | return ret; |
152 | } | 151 | } |
153 | 152 | ||
154 | static int pxa2xx_flash_resume(struct device *dev) | 153 | static int pxa2xx_flash_resume(struct platform_device *dev) |
155 | { | 154 | { |
156 | struct pxa2xx_flash_info *info = dev_get_drvdata(dev); | 155 | struct pxa2xx_flash_info *info = platform_get_drvdata(dev); |
157 | 156 | ||
158 | if (info->mtd && info->mtd->resume) | 157 | if (info->mtd && info->mtd->resume) |
159 | info->mtd->resume(info->mtd); | 158 | info->mtd->resume(info->mtd); |
160 | return 0; | 159 | return 0; |
161 | } | 160 | } |
162 | static void pxa2xx_flash_shutdown(struct device *dev) | 161 | static void pxa2xx_flash_shutdown(struct platform_device *dev) |
163 | { | 162 | { |
164 | struct pxa2xx_flash_info *info = dev_get_drvdata(dev); | 163 | struct pxa2xx_flash_info *info = platform_get_drvdata(dev); |
165 | 164 | ||
166 | if (info && info->mtd->suspend(info->mtd) == 0) | 165 | if (info && info->mtd->suspend(info->mtd) == 0) |
167 | info->mtd->resume(info->mtd); | 166 | info->mtd->resume(info->mtd); |
@@ -172,11 +171,13 @@ static void pxa2xx_flash_shutdown(struct device *dev) | |||
172 | #define pxa2xx_flash_shutdown NULL | 171 | #define pxa2xx_flash_shutdown NULL |
173 | #endif | 172 | #endif |
174 | 173 | ||
175 | static struct device_driver pxa2xx_flash_driver = { | 174 | static struct platform_driver pxa2xx_flash_driver = { |
176 | .name = "pxa2xx-flash", | 175 | .driver = { |
177 | .bus = &platform_bus_type, | 176 | .name = "pxa2xx-flash", |
177 | .owner = THIS_MODULE, | ||
178 | }, | ||
178 | .probe = pxa2xx_flash_probe, | 179 | .probe = pxa2xx_flash_probe, |
179 | .remove = __exit_p(pxa2xx_flash_remove), | 180 | .remove = __devexit_p(pxa2xx_flash_remove), |
180 | .suspend = pxa2xx_flash_suspend, | 181 | .suspend = pxa2xx_flash_suspend, |
181 | .resume = pxa2xx_flash_resume, | 182 | .resume = pxa2xx_flash_resume, |
182 | .shutdown = pxa2xx_flash_shutdown, | 183 | .shutdown = pxa2xx_flash_shutdown, |
@@ -184,12 +185,12 @@ static struct device_driver pxa2xx_flash_driver = { | |||
184 | 185 | ||
185 | static int __init init_pxa2xx_flash(void) | 186 | static int __init init_pxa2xx_flash(void) |
186 | { | 187 | { |
187 | return driver_register(&pxa2xx_flash_driver); | 188 | return platform_driver_register(&pxa2xx_flash_driver); |
188 | } | 189 | } |
189 | 190 | ||
190 | static void __exit cleanup_pxa2xx_flash(void) | 191 | static void __exit cleanup_pxa2xx_flash(void) |
191 | { | 192 | { |
192 | driver_unregister(&pxa2xx_flash_driver); | 193 | platform_driver_unregister(&pxa2xx_flash_driver); |
193 | } | 194 | } |
194 | 195 | ||
195 | module_init(init_pxa2xx_flash); | 196 | module_init(init_pxa2xx_flash); |