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 /arch/mips/basler | |
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 'arch/mips/basler')
-rw-r--r-- | arch/mips/basler/excite/excite_iodev.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/arch/mips/basler/excite/excite_iodev.c b/arch/mips/basler/excite/excite_iodev.c index a1e3526b4a94..dfbfd7e2ac08 100644 --- a/arch/mips/basler/excite/excite_iodev.c +++ b/arch/mips/basler/excite/excite_iodev.c | |||
@@ -33,8 +33,8 @@ | |||
33 | 33 | ||
34 | 34 | ||
35 | static const struct resource *iodev_get_resource(struct platform_device *, const char *, unsigned int); | 35 | static const struct resource *iodev_get_resource(struct platform_device *, const char *, unsigned int); |
36 | static int __init iodev_probe(struct device *); | 36 | static int __init iodev_probe(struct platform_device *); |
37 | static int __exit iodev_remove(struct device *); | 37 | static int __exit iodev_remove(struct platform_device *); |
38 | static int iodev_open(struct inode *, struct file *); | 38 | static int iodev_open(struct inode *, struct file *); |
39 | static int iodev_release(struct inode *, struct file *); | 39 | static int iodev_release(struct inode *, struct file *); |
40 | static ssize_t iodev_read(struct file *, char __user *, size_t s, loff_t *); | 40 | static ssize_t iodev_read(struct file *, char __user *, size_t s, loff_t *); |
@@ -65,13 +65,13 @@ static struct miscdevice miscdev = | |||
65 | .fops = &fops | 65 | .fops = &fops |
66 | }; | 66 | }; |
67 | 67 | ||
68 | static struct device_driver iodev_driver = | 68 | static struct platform_driver iodev_driver = { |
69 | { | 69 | .driver = { |
70 | .name = (char *) iodev_name, | 70 | .name = iodev_name, |
71 | .bus = &platform_bus_type, | 71 | .owner = THIS_MODULE, |
72 | .owner = THIS_MODULE, | 72 | }, |
73 | .probe = iodev_probe, | 73 | .probe = iodev_probe, |
74 | .remove = __exit_p(iodev_remove) | 74 | .remove = __devexit_p(iodev_remove), |
75 | }; | 75 | }; |
76 | 76 | ||
77 | 77 | ||
@@ -89,11 +89,10 @@ iodev_get_resource(struct platform_device *pdv, const char *name, | |||
89 | 89 | ||
90 | 90 | ||
91 | /* No hotplugging on the platform bus - use __init */ | 91 | /* No hotplugging on the platform bus - use __init */ |
92 | static int __init iodev_probe(struct device *dev) | 92 | static int __init iodev_probe(struct platform_device *dev) |
93 | { | 93 | { |
94 | struct platform_device * const pdv = to_platform_device(dev); | ||
95 | const struct resource * const ri = | 94 | const struct resource * const ri = |
96 | iodev_get_resource(pdv, IODEV_RESOURCE_IRQ, IORESOURCE_IRQ); | 95 | iodev_get_resource(dev, IODEV_RESOURCE_IRQ, IORESOURCE_IRQ); |
97 | 96 | ||
98 | if (unlikely(!ri)) | 97 | if (unlikely(!ri)) |
99 | return -ENXIO; | 98 | return -ENXIO; |
@@ -104,7 +103,7 @@ static int __init iodev_probe(struct device *dev) | |||
104 | 103 | ||
105 | 104 | ||
106 | 105 | ||
107 | static int __exit iodev_remove(struct device *dev) | 106 | static int __exit iodev_remove(struct platform_device *dev) |
108 | { | 107 | { |
109 | return misc_deregister(&miscdev); | 108 | return misc_deregister(&miscdev); |
110 | } | 109 | } |
@@ -160,14 +159,14 @@ static irqreturn_t iodev_irqhdl(int irq, void *ctxt) | |||
160 | 159 | ||
161 | static int __init iodev_init_module(void) | 160 | static int __init iodev_init_module(void) |
162 | { | 161 | { |
163 | return driver_register(&iodev_driver); | 162 | return platform_driver_register(&iodev_driver); |
164 | } | 163 | } |
165 | 164 | ||
166 | 165 | ||
167 | 166 | ||
168 | static void __exit iodev_cleanup_module(void) | 167 | static void __exit iodev_cleanup_module(void) |
169 | { | 168 | { |
170 | driver_unregister(&iodev_driver); | 169 | platform_driver_unregister(&iodev_driver); |
171 | } | 170 | } |
172 | 171 | ||
173 | module_init(iodev_init_module); | 172 | module_init(iodev_init_module); |