aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide
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/ide
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/ide')
-rw-r--r--drivers/ide/au1xxx-ide.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/drivers/ide/au1xxx-ide.c b/drivers/ide/au1xxx-ide.c
index 79a2dfed8eb7..154ec2cf734f 100644
--- a/drivers/ide/au1xxx-ide.c
+++ b/drivers/ide/au1xxx-ide.c
@@ -536,9 +536,8 @@ static const struct ide_port_info au1xxx_port_info = {
536#endif 536#endif
537}; 537};
538 538
539static int au_ide_probe(struct device *dev) 539static int au_ide_probe(struct platform_device *dev)
540{ 540{
541 struct platform_device *pdev = to_platform_device(dev);
542 _auide_hwif *ahwif = &auide_hwif; 541 _auide_hwif *ahwif = &auide_hwif;
543 struct resource *res; 542 struct resource *res;
544 struct ide_host *host; 543 struct ide_host *host;
@@ -552,23 +551,23 @@ static int au_ide_probe(struct device *dev)
552#endif 551#endif
553 552
554 memset(&auide_hwif, 0, sizeof(_auide_hwif)); 553 memset(&auide_hwif, 0, sizeof(_auide_hwif));
555 ahwif->irq = platform_get_irq(pdev, 0); 554 ahwif->irq = platform_get_irq(dev, 0);
556 555
557 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 556 res = platform_get_resource(dev, IORESOURCE_MEM, 0);
558 557
559 if (res == NULL) { 558 if (res == NULL) {
560 pr_debug("%s %d: no base address\n", DRV_NAME, pdev->id); 559 pr_debug("%s %d: no base address\n", DRV_NAME, dev->id);
561 ret = -ENODEV; 560 ret = -ENODEV;
562 goto out; 561 goto out;
563 } 562 }
564 if (ahwif->irq < 0) { 563 if (ahwif->irq < 0) {
565 pr_debug("%s %d: no IRQ\n", DRV_NAME, pdev->id); 564 pr_debug("%s %d: no IRQ\n", DRV_NAME, dev->id);
566 ret = -ENODEV; 565 ret = -ENODEV;
567 goto out; 566 goto out;
568 } 567 }
569 568
570 if (!request_mem_region(res->start, res->end - res->start + 1, 569 if (!request_mem_region(res->start, res->end - res->start + 1,
571 pdev->name)) { 570 dev->name)) {
572 pr_debug("%s: request_mem_region failed\n", DRV_NAME); 571 pr_debug("%s: request_mem_region failed\n", DRV_NAME);
573 ret = -EBUSY; 572 ret = -EBUSY;
574 goto out; 573 goto out;
@@ -583,7 +582,7 @@ static int au_ide_probe(struct device *dev)
583 memset(&hw, 0, sizeof(hw)); 582 memset(&hw, 0, sizeof(hw));
584 auide_setup_ports(&hw, ahwif); 583 auide_setup_ports(&hw, ahwif);
585 hw.irq = ahwif->irq; 584 hw.irq = ahwif->irq;
586 hw.dev = dev; 585 hw.dev = &dev->dev;
587 hw.chipset = ide_au1xxx; 586 hw.chipset = ide_au1xxx;
588 587
589 ret = ide_host_add(&au1xxx_port_info, hws, &host); 588 ret = ide_host_add(&au1xxx_port_info, hws, &host);
@@ -592,7 +591,7 @@ static int au_ide_probe(struct device *dev)
592 591
593 auide_hwif.hwif = host->ports[0]; 592 auide_hwif.hwif = host->ports[0];
594 593
595 dev_set_drvdata(dev, host); 594 platform_set_drvdata(dev, host);
596 595
597 printk(KERN_INFO "Au1xxx IDE(builtin) configured for %s\n", mode ); 596 printk(KERN_INFO "Au1xxx IDE(builtin) configured for %s\n", mode );
598 597
@@ -600,38 +599,39 @@ static int au_ide_probe(struct device *dev)
600 return ret; 599 return ret;
601} 600}
602 601
603static int au_ide_remove(struct device *dev) 602static int au_ide_remove(struct platform_device *dev)
604{ 603{
605 struct platform_device *pdev = to_platform_device(dev);
606 struct resource *res; 604 struct resource *res;
607 struct ide_host *host = dev_get_drvdata(dev); 605 struct ide_host *host = platform_get_drvdata(dev);
608 _auide_hwif *ahwif = &auide_hwif; 606 _auide_hwif *ahwif = &auide_hwif;
609 607
610 ide_host_remove(host); 608 ide_host_remove(host);
611 609
612 iounmap((void *)ahwif->regbase); 610 iounmap((void *)ahwif->regbase);
613 611
614 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 612 res = platform_get_resource(dev, IORESOURCE_MEM, 0);
615 release_mem_region(res->start, res->end - res->start + 1); 613 release_mem_region(res->start, res->end - res->start + 1);
616 614
617 return 0; 615 return 0;
618} 616}
619 617
620static struct device_driver au1200_ide_driver = { 618static struct platform_driver au1200_ide_driver = {
621 .name = "au1200-ide", 619 .driver = {
622 .bus = &platform_bus_type, 620 .name = "au1200-ide",
621 .owner = THIS_MODULE,
622 },
623 .probe = au_ide_probe, 623 .probe = au_ide_probe,
624 .remove = au_ide_remove, 624 .remove = au_ide_remove,
625}; 625};
626 626
627static int __init au_ide_init(void) 627static int __init au_ide_init(void)
628{ 628{
629 return driver_register(&au1200_ide_driver); 629 return platform_driver_register(&au1200_ide_driver);
630} 630}
631 631
632static void __exit au_ide_exit(void) 632static void __exit au_ide_exit(void)
633{ 633{
634 driver_unregister(&au1200_ide_driver); 634 platform_driver_unregister(&au1200_ide_driver);
635} 635}
636 636
637MODULE_LICENSE("GPL"); 637MODULE_LICENSE("GPL");