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:
Ming Lei
2009-02-06 23:40:12 +08:00
committed by Greg Kroah-Hartman
parent 6da2d377bb
commit 7a192ec334
21 changed files with 371 additions and 250 deletions

View File

@ -34,7 +34,7 @@ static struct scsi_host_template mvme16x_scsi_driver_template = {
static struct platform_device *mvme16x_scsi_device;
static __devinit int
mvme16x_probe(struct device *dev)
mvme16x_probe(struct platform_device *dev)
{
struct Scsi_Host * host = NULL;
struct NCR_700_Host_Parameters *hostdata;
@ -88,7 +88,7 @@ mvme16x_probe(struct device *dev)
out_be32(0xfff4202c, v);
}
dev_set_drvdata(dev, host);
platform_set_drvdata(dev, host);
scsi_scan_host(host);
return 0;
@ -102,9 +102,9 @@ mvme16x_probe(struct device *dev)
}
static __devexit int
mvme16x_device_remove(struct device *dev)
mvme16x_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);
/* Disable scsi chip ints */
@ -123,25 +123,27 @@ mvme16x_device_remove(struct device *dev)
return 0;
}
static struct device_driver mvme16x_scsi_driver = {
.name = "mvme16x-scsi",
.bus = &platform_bus_type,
.probe = mvme16x_probe,
.remove = __devexit_p(mvme16x_device_remove),
static struct platform_driver mvme16x_scsi_driver = {
.driver = {
.name = "mvme16x-scsi",
.owner = THIS_MODULE,
},
.probe = mvme16x_probe,
.remove = __devexit_p(mvme16x_device_remove),
};
static int __init mvme16x_scsi_init(void)
{
int err;
err = driver_register(&mvme16x_scsi_driver);
err = platform_driver_register(&mvme16x_scsi_driver);
if (err)
return err;
mvme16x_scsi_device = platform_device_register_simple("mvme16x-scsi",
-1, NULL, 0);
if (IS_ERR(mvme16x_scsi_device)) {
driver_unregister(&mvme16x_scsi_driver);
platform_driver_unregister(&mvme16x_scsi_driver);
return PTR_ERR(mvme16x_scsi_device);
}
@ -151,7 +153,7 @@ static int __init mvme16x_scsi_init(void)
static void __exit mvme16x_scsi_exit(void)
{
platform_device_unregister(mvme16x_scsi_device);
driver_unregister(&mvme16x_scsi_driver);
platform_driver_unregister(&mvme16x_scsi_driver);
}
module_init(mvme16x_scsi_init);