aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/onenand
diff options
context:
space:
mode:
authorMing Lei <tom.leiming@gmail.com>2009-02-06 10:40:12 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2009-03-24 19:38:25 -0400
commit7a192ec334cab9fafe3a8665a65af398b0e24730 (patch)
treeeea572863500f94d446cfded69835e188dba3447 /drivers/mtd/onenand
parent6da2d377bba06c29d0bc41c8dee014164dec82a7 (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/onenand')
-rw-r--r--drivers/mtd/onenand/generic.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/drivers/mtd/onenand/generic.c b/drivers/mtd/onenand/generic.c
index 5b69e7773c6c..3a496c33fb52 100644
--- a/drivers/mtd/onenand/generic.c
+++ b/drivers/mtd/onenand/generic.c
@@ -36,10 +36,9 @@ struct onenand_info {
36 struct onenand_chip onenand; 36 struct onenand_chip onenand;
37}; 37};
38 38
39static int __devinit generic_onenand_probe(struct device *dev) 39static int __devinit generic_onenand_probe(struct platform_device *pdev)
40{ 40{
41 struct onenand_info *info; 41 struct onenand_info *info;
42 struct platform_device *pdev = to_platform_device(dev);
43 struct flash_platform_data *pdata = pdev->dev.platform_data; 42 struct flash_platform_data *pdata = pdev->dev.platform_data;
44 struct resource *res = pdev->resource; 43 struct resource *res = pdev->resource;
45 unsigned long size = res->end - res->start + 1; 44 unsigned long size = res->end - res->start + 1;
@@ -49,7 +48,7 @@ static int __devinit generic_onenand_probe(struct device *dev)
49 if (!info) 48 if (!info)
50 return -ENOMEM; 49 return -ENOMEM;
51 50
52 if (!request_mem_region(res->start, size, dev->driver->name)) { 51 if (!request_mem_region(res->start, size, pdev->dev.driver->name)) {
53 err = -EBUSY; 52 err = -EBUSY;
54 goto out_free_info; 53 goto out_free_info;
55 } 54 }
@@ -82,7 +81,7 @@ static int __devinit generic_onenand_probe(struct device *dev)
82#endif 81#endif
83 err = add_mtd_device(&info->mtd); 82 err = add_mtd_device(&info->mtd);
84 83
85 dev_set_drvdata(&pdev->dev, info); 84 platform_set_drvdata(pdev, info);
86 85
87 return 0; 86 return 0;
88 87
@@ -96,14 +95,13 @@ out_free_info:
96 return err; 95 return err;
97} 96}
98 97
99static int __devexit generic_onenand_remove(struct device *dev) 98static int __devexit generic_onenand_remove(struct platform_device *pdev)
100{ 99{
101 struct platform_device *pdev = to_platform_device(dev); 100 struct onenand_info *info = platform_get_drvdata(pdev);
102 struct onenand_info *info = dev_get_drvdata(&pdev->dev);
103 struct resource *res = pdev->resource; 101 struct resource *res = pdev->resource;
104 unsigned long size = res->end - res->start + 1; 102 unsigned long size = res->end - res->start + 1;
105 103
106 dev_set_drvdata(&pdev->dev, NULL); 104 platform_set_drvdata(pdev, NULL);
107 105
108 if (info) { 106 if (info) {
109 if (info->parts) 107 if (info->parts)
@@ -120,9 +118,11 @@ static int __devexit generic_onenand_remove(struct device *dev)
120 return 0; 118 return 0;
121} 119}
122 120
123static struct device_driver generic_onenand_driver = { 121static struct platform_driver generic_onenand_driver = {
124 .name = DRIVER_NAME, 122 .driver = {
125 .bus = &platform_bus_type, 123 .name = DRIVER_NAME,
124 .owner = THIS_MODULE,
125 },
126 .probe = generic_onenand_probe, 126 .probe = generic_onenand_probe,
127 .remove = __devexit_p(generic_onenand_remove), 127 .remove = __devexit_p(generic_onenand_remove),
128}; 128};
@@ -131,12 +131,12 @@ MODULE_ALIAS(DRIVER_NAME);
131 131
132static int __init generic_onenand_init(void) 132static int __init generic_onenand_init(void)
133{ 133{
134 return driver_register(&generic_onenand_driver); 134 return platform_driver_register(&generic_onenand_driver);
135} 135}
136 136
137static void __exit generic_onenand_exit(void) 137static void __exit generic_onenand_exit(void)
138{ 138{
139 driver_unregister(&generic_onenand_driver); 139 platform_driver_unregister(&generic_onenand_driver);
140} 140}
141 141
142module_init(generic_onenand_init); 142module_init(generic_onenand_init);