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>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
6da2d377bb
commit
7a192ec334
@@ -34,7 +34,7 @@ static struct scsi_host_template bvme6000_scsi_driver_template = {
|
||||
static struct platform_device *bvme6000_scsi_device;
|
||||
|
||||
static __devinit int
|
||||
bvme6000_probe(struct device *dev)
|
||||
bvme6000_probe(struct platform_device *dev)
|
||||
{
|
||||
struct Scsi_Host *host;
|
||||
struct NCR_700_Host_Parameters *hostdata;
|
||||
@@ -73,7 +73,7 @@ bvme6000_probe(struct device *dev)
|
||||
goto out_put_host;
|
||||
}
|
||||
|
||||
dev_set_drvdata(dev, host);
|
||||
platform_set_drvdata(dev, host);
|
||||
scsi_scan_host(host);
|
||||
|
||||
return 0;
|
||||
@@ -87,9 +87,9 @@ bvme6000_probe(struct device *dev)
|
||||
}
|
||||
|
||||
static __devexit int
|
||||
bvme6000_device_remove(struct device *dev)
|
||||
bvme6000_device_remove(struct platform_device *dev)
|
||||
{
|
||||
struct Scsi_Host *host = dev_get_drvdata(dev);
|
||||
struct Scsi_Host *host = platform_get_drvdata(dev);
|
||||
struct NCR_700_Host_Parameters *hostdata = shost_priv(host);
|
||||
|
||||
scsi_remove_host(host);
|
||||
@@ -100,25 +100,27 @@ bvme6000_device_remove(struct device *dev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct device_driver bvme6000_scsi_driver = {
|
||||
.name = "bvme6000-scsi",
|
||||
.bus = &platform_bus_type,
|
||||
.probe = bvme6000_probe,
|
||||
.remove = __devexit_p(bvme6000_device_remove),
|
||||
static struct platform_driver bvme6000_scsi_driver = {
|
||||
.driver = {
|
||||
.name = "bvme6000-scsi",
|
||||
.owner = THIS_MODULE,
|
||||
},
|
||||
.probe = bvme6000_probe,
|
||||
.remove = __devexit_p(bvme6000_device_remove),
|
||||
};
|
||||
|
||||
static int __init bvme6000_scsi_init(void)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = driver_register(&bvme6000_scsi_driver);
|
||||
err = platform_driver_register(&bvme6000_scsi_driver);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
bvme6000_scsi_device = platform_device_register_simple("bvme6000-scsi",
|
||||
-1, NULL, 0);
|
||||
if (IS_ERR(bvme6000_scsi_device)) {
|
||||
driver_unregister(&bvme6000_scsi_driver);
|
||||
platform_driver_unregister(&bvme6000_scsi_driver);
|
||||
return PTR_ERR(bvme6000_scsi_device);
|
||||
}
|
||||
|
||||
@@ -128,7 +130,7 @@ static int __init bvme6000_scsi_init(void)
|
||||
static void __exit bvme6000_scsi_exit(void)
|
||||
{
|
||||
platform_device_unregister(bvme6000_scsi_device);
|
||||
driver_unregister(&bvme6000_scsi_driver);
|
||||
platform_driver_unregister(&bvme6000_scsi_driver);
|
||||
}
|
||||
|
||||
module_init(bvme6000_scsi_init);
|
||||
|
Reference in New Issue
Block a user