Commit 7a192ec334cab9fafe3a8665a65af398b0e24730

Authored by Ming Lei
Committed by Greg Kroah-Hartman
1 parent 6da2d377bb

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>

Showing 21 changed files with 371 additions and 250 deletions Side-by-side Diff

arch/mips/basler/excite/excite_iodev.c
... ... @@ -33,8 +33,8 @@
33 33  
34 34  
35 35 static const struct resource *iodev_get_resource(struct platform_device *, const char *, unsigned int);
36   -static int __init iodev_probe(struct device *);
37   -static int __exit iodev_remove(struct device *);
  36 +static int __init iodev_probe(struct platform_device *);
  37 +static int __exit iodev_remove(struct platform_device *);
38 38 static int iodev_open(struct inode *, struct file *);
39 39 static int iodev_release(struct inode *, struct file *);
40 40 static ssize_t iodev_read(struct file *, char __user *, size_t s, loff_t *);
41 41  
... ... @@ -65,13 +65,13 @@
65 65 .fops = &fops
66 66 };
67 67  
68   -static struct device_driver iodev_driver =
69   -{
70   - .name = (char *) iodev_name,
71   - .bus = &platform_bus_type,
72   - .owner = THIS_MODULE,
  68 +static struct platform_driver iodev_driver = {
  69 + .driver = {
  70 + .name = iodev_name,
  71 + .owner = THIS_MODULE,
  72 + },
73 73 .probe = iodev_probe,
74   - .remove = __exit_p(iodev_remove)
  74 + .remove = __devexit_p(iodev_remove),
75 75 };
76 76  
77 77  
78 78  
79 79  
... ... @@ -89,11 +89,10 @@
89 89  
90 90  
91 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 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 97 if (unlikely(!ri))
99 98 return -ENXIO;
... ... @@ -104,7 +103,7 @@
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 108 return misc_deregister(&miscdev);
110 109 }
111 110  
... ... @@ -160,14 +159,14 @@
160 159  
161 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 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 172 module_init(iodev_init_module);
drivers/char/tpm/tpm_atmel.c
... ... @@ -168,12 +168,22 @@
168 168 }
169 169 }
170 170  
171   -static struct device_driver atml_drv = {
172   - .name = "tpm_atmel",
173   - .bus = &platform_bus_type,
174   - .owner = THIS_MODULE,
175   - .suspend = tpm_pm_suspend,
176   - .resume = tpm_pm_resume,
  171 +static int tpm_atml_suspend(struct platform_device *dev, pm_message_t msg)
  172 +{
  173 + return tpm_pm_suspend(&dev->dev, msg);
  174 +}
  175 +
  176 +static int tpm_atml_resume(struct platform_device *dev)
  177 +{
  178 + return tpm_pm_resume(&dev->dev);
  179 +}
  180 +static struct platform_driver atml_drv = {
  181 + .driver = {
  182 + .name = "tpm_atmel",
  183 + .owner = THIS_MODULE,
  184 + },
  185 + .suspend = tpm_atml_suspend,
  186 + .resume = tpm_atml_resume,
177 187 };
178 188  
179 189 static int __init init_atmel(void)
... ... @@ -184,7 +194,7 @@
184 194 unsigned long base;
185 195 struct tpm_chip *chip;
186 196  
187   - rc = driver_register(&atml_drv);
  197 + rc = platform_driver_register(&atml_drv);
188 198 if (rc)
189 199 return rc;
190 200  
191 201  
... ... @@ -223,13 +233,13 @@
223 233 atmel_release_region(base,
224 234 region_size);
225 235 err_unreg_drv:
226   - driver_unregister(&atml_drv);
  236 + platform_driver_unregister(&atml_drv);
227 237 return rc;
228 238 }
229 239  
230 240 static void __exit cleanup_atmel(void)
231 241 {
232   - driver_unregister(&atml_drv);
  242 + platform_driver_unregister(&atml_drv);
233 243 atml_plat_remove();
234 244 }
235 245  
drivers/char/tpm/tpm_tis.c
... ... @@ -654,12 +654,22 @@
654 654 sizeof(tpm_pnp_tbl[TIS_HID_USR_IDX].id), 0444);
655 655 MODULE_PARM_DESC(hid, "Set additional specific HID for this driver to probe");
656 656  
657   -static struct device_driver tis_drv = {
658   - .name = "tpm_tis",
659   - .bus = &platform_bus_type,
660   - .owner = THIS_MODULE,
661   - .suspend = tpm_pm_suspend,
662   - .resume = tpm_pm_resume,
  657 +static int tpm_tis_suspend(struct platform_device *dev, pm_message_t msg)
  658 +{
  659 + return tpm_pm_suspend(&dev->dev, msg);
  660 +}
  661 +
  662 +static int tpm_tis_resume(struct platform_device *dev)
  663 +{
  664 + return tpm_pm_resume(&dev->dev);
  665 +}
  666 +static struct platform_driver tis_drv = {
  667 + .driver = {
  668 + .name = "tpm_tis",
  669 + .owner = THIS_MODULE,
  670 + },
  671 + .suspend = tpm_tis_suspend,
  672 + .resume = tpm_tis_resume,
663 673 };
664 674  
665 675 static struct platform_device *pdev;
666 676  
... ... @@ -672,14 +682,14 @@
672 682 int rc;
673 683  
674 684 if (force) {
675   - rc = driver_register(&tis_drv);
  685 + rc = platform_driver_register(&tis_drv);
676 686 if (rc < 0)
677 687 return rc;
678 688 if (IS_ERR(pdev=platform_device_register_simple("tpm_tis", -1, NULL, 0)))
679 689 return PTR_ERR(pdev);
680 690 if((rc=tpm_tis_init(&pdev->dev, TIS_MEM_BASE, TIS_MEM_LEN, 0)) != 0) {
681 691 platform_device_unregister(pdev);
682   - driver_unregister(&tis_drv);
  692 + platform_driver_unregister(&tis_drv);
683 693 }
684 694 return rc;
685 695 }
... ... @@ -711,7 +721,7 @@
711 721  
712 722 if (force) {
713 723 platform_device_unregister(pdev);
714   - driver_unregister(&tis_drv);
  724 + platform_driver_unregister(&tis_drv);
715 725 } else
716 726 pnp_unregister_driver(&tis_pnp_driver);
717 727 }
drivers/ide/au1xxx-ide.c
... ... @@ -536,9 +536,8 @@
536 536 #endif
537 537 };
538 538  
539   -static int au_ide_probe(struct device *dev)
  539 +static int au_ide_probe(struct platform_device *dev)
540 540 {
541   - struct platform_device *pdev = to_platform_device(dev);
542 541 _auide_hwif *ahwif = &auide_hwif;
543 542 struct resource *res;
544 543 struct ide_host *host;
545 544  
546 545  
547 546  
548 547  
... ... @@ -552,23 +551,23 @@
552 551 #endif
553 552  
554 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 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 560 ret = -ENODEV;
562 561 goto out;
563 562 }
564 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 565 ret = -ENODEV;
567 566 goto out;
568 567 }
569 568  
570 569 if (!request_mem_region(res->start, res->end - res->start + 1,
571   - pdev->name)) {
  570 + dev->name)) {
572 571 pr_debug("%s: request_mem_region failed\n", DRV_NAME);
573 572 ret = -EBUSY;
574 573 goto out;
... ... @@ -583,7 +582,7 @@
583 582 memset(&hw, 0, sizeof(hw));
584 583 auide_setup_ports(&hw, ahwif);
585 584 hw.irq = ahwif->irq;
586   - hw.dev = dev;
  585 + hw.dev = &dev->dev;
587 586 hw.chipset = ide_au1xxx;
588 587  
589 588 ret = ide_host_add(&au1xxx_port_info, hws, &host);
... ... @@ -592,7 +591,7 @@
592 591  
593 592 auide_hwif.hwif = host->ports[0];
594 593  
595   - dev_set_drvdata(dev, host);
  594 + platform_set_drvdata(dev, host);
596 595  
597 596 printk(KERN_INFO "Au1xxx IDE(builtin) configured for %s\n", mode );
598 597  
599 598  
600 599  
601 600  
602 601  
603 602  
604 603  
... ... @@ -600,38 +599,39 @@
600 599 return ret;
601 600 }
602 601  
603   -static int au_ide_remove(struct device *dev)
  602 +static int au_ide_remove(struct platform_device *dev)
604 603 {
605   - struct platform_device *pdev = to_platform_device(dev);
606 604 struct resource *res;
607   - struct ide_host *host = dev_get_drvdata(dev);
  605 + struct ide_host *host = platform_get_drvdata(dev);
608 606 _auide_hwif *ahwif = &auide_hwif;
609 607  
610 608 ide_host_remove(host);
611 609  
612 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 613 release_mem_region(res->start, res->end - res->start + 1);
616 614  
617 615 return 0;
618 616 }
619 617  
620   -static struct device_driver au1200_ide_driver = {
621   - .name = "au1200-ide",
622   - .bus = &platform_bus_type,
  618 +static struct platform_driver au1200_ide_driver = {
  619 + .driver = {
  620 + .name = "au1200-ide",
  621 + .owner = THIS_MODULE,
  622 + },
623 623 .probe = au_ide_probe,
624 624 .remove = au_ide_remove,
625 625 };
626 626  
627 627 static 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  
632 632 static 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  
637 637 MODULE_LICENSE("GPL");
drivers/mtd/maps/pxa2xx-flash.c
... ... @@ -41,9 +41,8 @@
41 41 static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
42 42  
43 43  
44   -static int __init pxa2xx_flash_probe(struct device *dev)
  44 +static int __init pxa2xx_flash_probe(struct platform_device *pdev)
45 45 {
46   - struct platform_device *pdev = to_platform_device(dev);
47 46 struct flash_platform_data *flash = pdev->dev.platform_data;
48 47 struct pxa2xx_flash_info *info;
49 48 struct mtd_partition *parts;
50 49  
51 50  
52 51  
... ... @@ -114,15 +113,15 @@
114 113 add_mtd_device(info->mtd);
115 114 }
116 115  
117   - dev_set_drvdata(dev, info);
  116 + platform_set_drvdata(pdev, info);
118 117 return 0;
119 118 }
120 119  
121   -static int __exit pxa2xx_flash_remove(struct device *dev)
  120 +static int __exit pxa2xx_flash_remove(struct platform_device *dev)
122 121 {
123   - struct pxa2xx_flash_info *info = dev_get_drvdata(dev);
  122 + struct pxa2xx_flash_info *info = platform_get_drvdata(dev);
124 123  
125   - dev_set_drvdata(dev, NULL);
  124 + platform_set_drvdata(dev, NULL);
126 125  
127 126 #ifdef CONFIG_MTD_PARTITIONS
128 127 if (info->nr_parts)
129 128  
... ... @@ -141,9 +140,9 @@
141 140 }
142 141  
143 142 #ifdef CONFIG_PM
144   -static int pxa2xx_flash_suspend(struct device *dev, pm_message_t state)
  143 +static int pxa2xx_flash_suspend(struct platform_device *dev, pm_message_t state)
145 144 {
146   - struct pxa2xx_flash_info *info = dev_get_drvdata(dev);
  145 + struct pxa2xx_flash_info *info = platform_get_drvdata(dev);
147 146 int ret = 0;
148 147  
149 148 if (info->mtd && info->mtd->suspend)
150 149  
151 150  
152 151  
... ... @@ -151,17 +150,17 @@
151 150 return ret;
152 151 }
153 152  
154   -static int pxa2xx_flash_resume(struct device *dev)
  153 +static int pxa2xx_flash_resume(struct platform_device *dev)
155 154 {
156   - struct pxa2xx_flash_info *info = dev_get_drvdata(dev);
  155 + struct pxa2xx_flash_info *info = platform_get_drvdata(dev);
157 156  
158 157 if (info->mtd && info->mtd->resume)
159 158 info->mtd->resume(info->mtd);
160 159 return 0;
161 160 }
162   -static void pxa2xx_flash_shutdown(struct device *dev)
  161 +static void pxa2xx_flash_shutdown(struct platform_device *dev)
163 162 {
164   - struct pxa2xx_flash_info *info = dev_get_drvdata(dev);
  163 + struct pxa2xx_flash_info *info = platform_get_drvdata(dev);
165 164  
166 165 if (info && info->mtd->suspend(info->mtd) == 0)
167 166 info->mtd->resume(info->mtd);
168 167  
... ... @@ -172,11 +171,13 @@
172 171 #define pxa2xx_flash_shutdown NULL
173 172 #endif
174 173  
175   -static struct device_driver pxa2xx_flash_driver = {
176   - .name = "pxa2xx-flash",
177   - .bus = &platform_bus_type,
  174 +static struct platform_driver pxa2xx_flash_driver = {
  175 + .driver = {
  176 + .name = "pxa2xx-flash",
  177 + .owner = THIS_MODULE,
  178 + },
178 179 .probe = pxa2xx_flash_probe,
179   - .remove = __exit_p(pxa2xx_flash_remove),
  180 + .remove = __devexit_p(pxa2xx_flash_remove),
180 181 .suspend = pxa2xx_flash_suspend,
181 182 .resume = pxa2xx_flash_resume,
182 183 .shutdown = pxa2xx_flash_shutdown,
183 184  
... ... @@ -184,12 +185,12 @@
184 185  
185 186 static int __init init_pxa2xx_flash(void)
186 187 {
187   - return driver_register(&pxa2xx_flash_driver);
  188 + return platform_driver_register(&pxa2xx_flash_driver);
188 189 }
189 190  
190 191 static void __exit cleanup_pxa2xx_flash(void)
191 192 {
192   - driver_unregister(&pxa2xx_flash_driver);
  193 + platform_driver_unregister(&pxa2xx_flash_driver);
193 194 }
194 195  
195 196 module_init(init_pxa2xx_flash);
drivers/mtd/nand/excite_nandflash.c
... ... @@ -128,11 +128,11 @@
128 128 * The binding to the mtd and all allocated
129 129 * resources are released.
130 130 */
131   -static int __exit excite_nand_remove(struct device *dev)
  131 +static int __exit excite_nand_remove(struct platform_device *dev)
132 132 {
133   - struct excite_nand_drvdata * const this = dev_get_drvdata(dev);
  133 + struct excite_nand_drvdata * const this = platform_get_drvdata(dev);
134 134  
135   - dev_set_drvdata(dev, NULL);
  135 + platform_set_drvdata(dev, NULL);
136 136  
137 137 if (unlikely(!this)) {
138 138 printk(KERN_ERR "%s: called %s without private data!!",
139 139  
... ... @@ -159,9 +159,8 @@
159 159 * it can allocate all necessary resources then calls the
160 160 * nand layer to look for devices.
161 161 */
162   -static int __init excite_nand_probe(struct device *dev)
  162 +static int __init excite_nand_probe(struct platform_device *pdev)
163 163 {
164   - struct platform_device * const pdev = to_platform_device(dev);
165 164 struct excite_nand_drvdata *drvdata; /* private driver data */
166 165 struct nand_chip *board_chip; /* private flash chip data */
167 166 struct mtd_info *board_mtd; /* mtd info for this board */
... ... @@ -175,7 +174,7 @@
175 174 }
176 175  
177 176 /* bind private data into driver */
178   - dev_set_drvdata(dev, drvdata);
  177 + platform_set_drvdata(pdev, drvdata);
179 178  
180 179 /* allocate and map the resource */
181 180 drvdata->regs =
182 181  
183 182  
184 183  
... ... @@ -219,23 +218,25 @@
219 218 return 0;
220 219 }
221 220  
222   -static struct device_driver excite_nand_driver = {
223   - .name = "excite_nand",
224   - .bus = &platform_bus_type,
  221 +static struct platform_driver excite_nand_driver = {
  222 + .driver = {
  223 + .name = "excite_nand",
  224 + .owner = THIS_MODULE,
  225 + },
225 226 .probe = excite_nand_probe,
226   - .remove = __exit_p(excite_nand_remove)
  227 + .remove = __devexit_p(excite_nand_remove)
227 228 };
228 229  
229 230 static int __init excite_nand_init(void)
230 231 {
231 232 pr_info("Basler eXcite nand flash driver Version "
232 233 EXCITE_NANDFLASH_VERSION "\n");
233   - return driver_register(&excite_nand_driver);
  234 + return platform_driver_register(&excite_nand_driver);
234 235 }
235 236  
236 237 static void __exit excite_nand_exit(void)
237 238 {
238   - driver_unregister(&excite_nand_driver);
  239 + platform_driver_unregister(&excite_nand_driver);
239 240 }
240 241  
241 242 module_init(excite_nand_init);
drivers/mtd/onenand/generic.c
... ... @@ -36,10 +36,9 @@
36 36 struct onenand_chip onenand;
37 37 };
38 38  
39   -static int __devinit generic_onenand_probe(struct device *dev)
  39 +static int __devinit generic_onenand_probe(struct platform_device *pdev)
40 40 {
41 41 struct onenand_info *info;
42   - struct platform_device *pdev = to_platform_device(dev);
43 42 struct flash_platform_data *pdata = pdev->dev.platform_data;
44 43 struct resource *res = pdev->resource;
45 44 unsigned long size = res->end - res->start + 1;
... ... @@ -49,7 +48,7 @@
49 48 if (!info)
50 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 52 err = -EBUSY;
54 53 goto out_free_info;
55 54 }
... ... @@ -82,7 +81,7 @@
82 81 #endif
83 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 86 return 0;
88 87  
89 88  
90 89  
... ... @@ -96,14 +95,13 @@
96 95 return err;
97 96 }
98 97  
99   -static int __devexit generic_onenand_remove(struct device *dev)
  98 +static int __devexit generic_onenand_remove(struct platform_device *pdev)
100 99 {
101   - struct platform_device *pdev = to_platform_device(dev);
102   - struct onenand_info *info = dev_get_drvdata(&pdev->dev);
  100 + struct onenand_info *info = platform_get_drvdata(pdev);
103 101 struct resource *res = pdev->resource;
104 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 106 if (info) {
109 107 if (info->parts)
... ... @@ -120,9 +118,11 @@
120 118 return 0;
121 119 }
122 120  
123   -static struct device_driver generic_onenand_driver = {
124   - .name = DRIVER_NAME,
125   - .bus = &platform_bus_type,
  121 +static struct platform_driver generic_onenand_driver = {
  122 + .driver = {
  123 + .name = DRIVER_NAME,
  124 + .owner = THIS_MODULE,
  125 + },
126 126 .probe = generic_onenand_probe,
127 127 .remove = __devexit_p(generic_onenand_remove),
128 128 };
129 129  
... ... @@ -131,12 +131,12 @@
131 131  
132 132 static 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  
137 137 static 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  
142 142 module_init(generic_onenand_init);
drivers/net/mipsnet.c
... ... @@ -237,7 +237,7 @@
237 237 {
238 238 }
239 239  
240   -static int __init mipsnet_probe(struct device *dev)
  240 +static int __init mipsnet_probe(struct platform_device *dev)
241 241 {
242 242 struct net_device *netdev;
243 243 int err;
... ... @@ -248,7 +248,7 @@
248 248 goto out;
249 249 }
250 250  
251   - dev_set_drvdata(dev, netdev);
  251 + platform_set_drvdata(dev, netdev);
252 252  
253 253 netdev->open = mipsnet_open;
254 254 netdev->stop = mipsnet_close;
255 255  
256 256  
257 257  
... ... @@ -293,23 +293,25 @@
293 293 return err;
294 294 }
295 295  
296   -static int __devexit mipsnet_device_remove(struct device *device)
  296 +static int __devexit mipsnet_device_remove(struct platform_device *device)
297 297 {
298   - struct net_device *dev = dev_get_drvdata(device);
  298 + struct net_device *dev = platform_get_drvdata(device);
299 299  
300 300 unregister_netdev(dev);
301 301 release_region(dev->base_addr, sizeof(struct mipsnet_regs));
302 302 free_netdev(dev);
303   - dev_set_drvdata(device, NULL);
  303 + platform_set_drvdata(device, NULL);
304 304  
305 305 return 0;
306 306 }
307 307  
308   -static struct device_driver mipsnet_driver = {
309   - .name = mipsnet_string,
310   - .bus = &platform_bus_type,
311   - .probe = mipsnet_probe,
312   - .remove = __devexit_p(mipsnet_device_remove),
  308 +static struct platform_driver mipsnet_driver = {
  309 + .driver = {
  310 + .name = mipsnet_string,
  311 + .owner = THIS_MODULE,
  312 + },
  313 + .probe = mipsnet_probe,
  314 + .remove = __devexit_p(mipsnet_device_remove),
313 315 };
314 316  
315 317 static int __init mipsnet_init_module(void)
... ... @@ -319,7 +321,7 @@
319 321 printk(KERN_INFO "MIPSNet Ethernet driver. Version: %s. "
320 322 "(c)2005 MIPS Technologies, Inc.\n", MIPSNET_VERSION);
321 323  
322   - err = driver_register(&mipsnet_driver);
  324 + err = platform_driver_register(&mipsnet_driver);
323 325 if (err)
324 326 printk(KERN_ERR "Driver registration failed\n");
325 327  
... ... @@ -328,7 +330,7 @@
328 330  
329 331 static void __exit mipsnet_exit_module(void)
330 332 {
331   - driver_unregister(&mipsnet_driver);
  333 + platform_driver_unregister(&mipsnet_driver);
332 334 }
333 335  
334 336 module_init(mipsnet_init_module);
drivers/pcmcia/au1000_generic.c
... ... @@ -468,13 +468,13 @@
468 468 return ret;
469 469 }
470 470  
471   -int au1x00_drv_pcmcia_remove(struct device *dev)
  471 +int au1x00_drv_pcmcia_remove(struct platform_device *dev)
472 472 {
473   - struct skt_dev_info *sinfo = dev_get_drvdata(dev);
  473 + struct skt_dev_info *sinfo = platform_get_drvdata(dev);
474 474 int i;
475 475  
476 476 mutex_lock(&pcmcia_sockets_lock);
477   - dev_set_drvdata(dev, NULL);
  477 + platform_set_drvdata(dev, NULL);
478 478  
479 479 for (i = 0; i < sinfo->nskt; i++) {
480 480 struct au1000_pcmcia_socket *skt = PCMCIA_SOCKET(i);
481 481  
... ... @@ -498,13 +498,13 @@
498 498 * PCMCIA "Driver" API
499 499 */
500 500  
501   -static int au1x00_drv_pcmcia_probe(struct device *dev)
  501 +static int au1x00_drv_pcmcia_probe(struct platform_device *dev)
502 502 {
503 503 int i, ret = -ENODEV;
504 504  
505 505 mutex_lock(&pcmcia_sockets_lock);
506 506 for (i=0; i < ARRAY_SIZE(au1x00_pcmcia_hw_init); i++) {
507   - ret = au1x00_pcmcia_hw_init[i](dev);
  507 + ret = au1x00_pcmcia_hw_init[i](&dev->dev);
508 508 if (ret == 0)
509 509 break;
510 510 }
511 511  
512 512  
... ... @@ -512,14 +512,26 @@
512 512 return ret;
513 513 }
514 514  
  515 +static int au1x00_drv_pcmcia_suspend(struct platform_device *dev,
  516 + pm_message_t state)
  517 +{
  518 + return pcmcia_socket_dev_suspend(&dev->dev, state);
  519 +}
515 520  
516   -static struct device_driver au1x00_pcmcia_driver = {
  521 +static int au1x00_drv_pcmcia_resume(struct platform_device *dev)
  522 +{
  523 + return pcmcia_socket_dev_resume(&dev->dev);
  524 +}
  525 +
  526 +static struct platform_driver au1x00_pcmcia_driver = {
  527 + .driver = {
  528 + .name = "au1x00-pcmcia",
  529 + .owner = THIS_MODULE,
  530 + },
517 531 .probe = au1x00_drv_pcmcia_probe,
518 532 .remove = au1x00_drv_pcmcia_remove,
519   - .name = "au1x00-pcmcia",
520   - .bus = &platform_bus_type,
521   - .suspend = pcmcia_socket_dev_suspend,
522   - .resume = pcmcia_socket_dev_resume,
  533 + .suspend = au1x00_drv_pcmcia_suspend,
  534 + .resume = au1x00_drv_pcmcia_resume,
523 535 };
524 536  
525 537  
... ... @@ -533,8 +545,7 @@
533 545 static int __init au1x00_pcmcia_init(void)
534 546 {
535 547 int error = 0;
536   - if ((error = driver_register(&au1x00_pcmcia_driver)))
537   - return error;
  548 + error = platform_driver_register(&au1x00_pcmcia_driver);
538 549 return error;
539 550 }
540 551  
... ... @@ -544,7 +555,7 @@
544 555 */
545 556 static void __exit au1x00_pcmcia_exit(void)
546 557 {
547   - driver_unregister(&au1x00_pcmcia_driver);
  558 + platform_driver_unregister(&au1x00_pcmcia_driver);
548 559 }
549 560  
550 561 module_init(au1x00_pcmcia_init);
drivers/pcmcia/i82365.c
... ... @@ -1238,6 +1238,16 @@
1238 1238 return 0;
1239 1239 }
1240 1240  
  1241 +static int i82365_drv_pcmcia_suspend(struct platform_device *dev,
  1242 + pm_message_t state)
  1243 +{
  1244 + return pcmcia_socket_dev_suspend(&dev->dev, state);
  1245 +}
  1246 +
  1247 +static int i82365_drv_pcmcia_resume(struct platform_device *dev)
  1248 +{
  1249 + return pcmcia_socket_dev_resume(&dev->dev);
  1250 +}
1241 1251 static struct pccard_operations pcic_operations = {
1242 1252 .init = pcic_init,
1243 1253 .get_status = pcic_get_status,
... ... @@ -1248,11 +1258,13 @@
1248 1258  
1249 1259 /*====================================================================*/
1250 1260  
1251   -static struct device_driver i82365_driver = {
1252   - .name = "i82365",
1253   - .bus = &platform_bus_type,
1254   - .suspend = pcmcia_socket_dev_suspend,
1255   - .resume = pcmcia_socket_dev_resume,
  1261 +static struct platform_driver i82365_driver = {
  1262 + .driver = {
  1263 + .name = "i82365",
  1264 + .owner = THIS_MODULE,
  1265 + },
  1266 + .suspend = i82365_drv_pcmcia_suspend,
  1267 + .resume = i82365_drv_pcmcia_resume,
1256 1268 };
1257 1269  
1258 1270 static struct platform_device *i82365_device;
... ... @@ -1261,7 +1273,7 @@
1261 1273 {
1262 1274 int i, ret;
1263 1275  
1264   - ret = driver_register(&i82365_driver);
  1276 + ret = platform_driver_register(&i82365_driver);
1265 1277 if (ret)
1266 1278 goto err_out;
1267 1279  
... ... @@ -1337,7 +1349,7 @@
1337 1349 pnp_disable_dev(i82365_pnpdev);
1338 1350 #endif
1339 1351 err_driver_unregister:
1340   - driver_unregister(&i82365_driver);
  1352 + platform_driver_unregister(&i82365_driver);
1341 1353 err_out:
1342 1354 return ret;
1343 1355 } /* init_i82365 */
... ... @@ -1365,7 +1377,7 @@
1365 1377 if (i82365_pnpdev)
1366 1378 pnp_disable_dev(i82365_pnpdev);
1367 1379 #endif
1368   - driver_unregister(&i82365_driver);
  1380 + platform_driver_unregister(&i82365_driver);
1369 1381 } /* exit_i82365 */
1370 1382  
1371 1383 module_init(init_i82365);
drivers/pcmcia/m32r_cfc.c
... ... @@ -696,13 +696,25 @@
696 696 .set_mem_map = pcc_set_mem_map,
697 697 };
698 698  
  699 +static int cfc_drv_pcmcia_suspend(struct platform_device *dev,
  700 + pm_message_t state)
  701 +{
  702 + return pcmcia_socket_dev_suspend(&dev->dev, state);
  703 +}
  704 +
  705 +static int cfc_drv_pcmcia_resume(struct platform_device *dev)
  706 +{
  707 + return pcmcia_socket_dev_resume(&dev->dev);
  708 +}
699 709 /*====================================================================*/
700 710  
701   -static struct device_driver pcc_driver = {
702   - .name = "cfc",
703   - .bus = &platform_bus_type,
704   - .suspend = pcmcia_socket_dev_suspend,
705   - .resume = pcmcia_socket_dev_resume,
  711 +static struct platform_driver pcc_driver = {
  712 + .driver = {
  713 + .name = "cfc",
  714 + .owner = THIS_MODULE,
  715 + },
  716 + .suspend = cfc_drv_pcmcia_suspend,
  717 + .resume = cfc_drv_pcmcia_resume,
706 718 };
707 719  
708 720 static struct platform_device pcc_device = {
709 721  
... ... @@ -716,13 +728,13 @@
716 728 {
717 729 int i, ret;
718 730  
719   - ret = driver_register(&pcc_driver);
  731 + ret = platform_driver_register(&pcc_driver);
720 732 if (ret)
721 733 return ret;
722 734  
723 735 ret = platform_device_register(&pcc_device);
724 736 if (ret){
725   - driver_unregister(&pcc_driver);
  737 + platform_driver_unregister(&pcc_driver);
726 738 return ret;
727 739 }
728 740  
... ... @@ -754,7 +766,7 @@
754 766 if (pcc_sockets == 0) {
755 767 printk("socket is not found.\n");
756 768 platform_device_unregister(&pcc_device);
757   - driver_unregister(&pcc_driver);
  769 + platform_driver_unregister(&pcc_driver);
758 770 return -ENODEV;
759 771 }
760 772  
... ... @@ -802,7 +814,7 @@
802 814 if (poll_interval != 0)
803 815 del_timer_sync(&poll_timer);
804 816  
805   - driver_unregister(&pcc_driver);
  817 + platform_driver_unregister(&pcc_driver);
806 818 } /* exit_m32r_pcc */
807 819  
808 820 module_init(init_m32r_pcc);
drivers/pcmcia/m32r_pcc.c
... ... @@ -672,13 +672,25 @@
672 672 .set_mem_map = pcc_set_mem_map,
673 673 };
674 674  
  675 +static int pcc_drv_pcmcia_suspend(struct platform_device *dev,
  676 + pm_message_t state)
  677 +{
  678 + return pcmcia_socket_dev_suspend(&dev->dev, state);
  679 +}
  680 +
  681 +static int pcc_drv_pcmcia_resume(struct platform_device *dev)
  682 +{
  683 + return pcmcia_socket_dev_resume(&dev->dev);
  684 +}
675 685 /*====================================================================*/
676 686  
677   -static struct device_driver pcc_driver = {
678   - .name = "pcc",
679   - .bus = &platform_bus_type,
680   - .suspend = pcmcia_socket_dev_suspend,
681   - .resume = pcmcia_socket_dev_resume,
  687 +static struct platform_driver pcc_driver = {
  688 + .driver = {
  689 + .name = "pcc",
  690 + .owner = THIS_MODULE,
  691 + },
  692 + .suspend = pcc_drv_pcmcia_suspend,
  693 + .resume = pcc_drv_pcmcia_resume,
682 694 };
683 695  
684 696 static struct platform_device pcc_device = {
685 697  
... ... @@ -692,13 +704,13 @@
692 704 {
693 705 int i, ret;
694 706  
695   - ret = driver_register(&pcc_driver);
  707 + ret = platform_driver_register(&pcc_driver);
696 708 if (ret)
697 709 return ret;
698 710  
699 711 ret = platform_device_register(&pcc_device);
700 712 if (ret){
701   - driver_unregister(&pcc_driver);
  713 + platform_driver_unregister(&pcc_driver);
702 714 return ret;
703 715 }
704 716  
... ... @@ -715,7 +727,7 @@
715 727 if (pcc_sockets == 0) {
716 728 printk("socket is not found.\n");
717 729 platform_device_unregister(&pcc_device);
718   - driver_unregister(&pcc_driver);
  730 + platform_driver_unregister(&pcc_driver);
719 731 return -ENODEV;
720 732 }
721 733  
... ... @@ -763,7 +775,7 @@
763 775 if (poll_interval != 0)
764 776 del_timer_sync(&poll_timer);
765 777  
766   - driver_unregister(&pcc_driver);
  778 + platform_driver_unregister(&pcc_driver);
767 779 } /* exit_m32r_pcc */
768 780  
769 781 module_init(init_m32r_pcc);
drivers/pcmcia/sa1100_generic.c
... ... @@ -65,7 +65,7 @@
65 65 #endif
66 66 };
67 67  
68   -static int sa11x0_drv_pcmcia_probe(struct device *dev)
  68 +static int sa11x0_drv_pcmcia_probe(struct platform_device *dev)
69 69 {
70 70 int i, ret = -ENODEV;
71 71  
... ... @@ -73,7 +73,7 @@
73 73 * Initialise any "on-board" PCMCIA sockets.
74 74 */
75 75 for (i = 0; i < ARRAY_SIZE(sa11x0_pcmcia_hw_init); i++) {
76   - ret = sa11x0_pcmcia_hw_init[i](dev);
  76 + ret = sa11x0_pcmcia_hw_init[i](&dev->dev);
77 77 if (ret == 0)
78 78 break;
79 79 }
80 80  
... ... @@ -81,13 +81,31 @@
81 81 return ret;
82 82 }
83 83  
84   -static struct device_driver sa11x0_pcmcia_driver = {
  84 +static int sa11x0_drv_pcmcia_remove(struct platform_device *dev)
  85 +{
  86 + return soc_common_drv_pcmcia_remove(&dev->dev);
  87 +}
  88 +
  89 +static int sa11x0_drv_pcmcia_suspend(struct platform_device *dev,
  90 + pm_message_t state)
  91 +{
  92 + return pcmcia_socket_dev_suspend(&dev->dev, state);
  93 +}
  94 +
  95 +static int sa11x0_drv_pcmcia_resume(struct platform_device *dev)
  96 +{
  97 + return pcmcia_socket_dev_resume(&dev->dev);
  98 +}
  99 +
  100 +static struct platform_driver sa11x0_pcmcia_driver = {
  101 + .driver = {
  102 + .name = "sa11x0-pcmcia",
  103 + .owner = THIS_MODULE,
  104 + },
85 105 .probe = sa11x0_drv_pcmcia_probe,
86   - .remove = soc_common_drv_pcmcia_remove,
87   - .name = "sa11x0-pcmcia",
88   - .bus = &platform_bus_type,
89   - .suspend = pcmcia_socket_dev_suspend,
90   - .resume = pcmcia_socket_dev_resume,
  106 + .remove = sa11x0_drv_pcmcia_remove,
  107 + .suspend = sa11x0_drv_pcmcia_suspend,
  108 + .resume = sa11x0_drv_pcmcia_resume,
91 109 };
92 110  
93 111 /* sa11x0_pcmcia_init()
... ... @@ -100,7 +118,7 @@
100 118 */
101 119 static int __init sa11x0_pcmcia_init(void)
102 120 {
103   - return driver_register(&sa11x0_pcmcia_driver);
  121 + return platform_driver_register(&sa11x0_pcmcia_driver);
104 122 }
105 123  
106 124 /* sa11x0_pcmcia_exit()
... ... @@ -110,7 +128,7 @@
110 128 */
111 129 static void __exit sa11x0_pcmcia_exit(void)
112 130 {
113   - driver_unregister(&sa11x0_pcmcia_driver);
  131 + platform_driver_unregister(&sa11x0_pcmcia_driver);
114 132 }
115 133  
116 134 MODULE_AUTHOR("John Dorsey <john+@cs.cmu.edu>");
drivers/pcmcia/tcic.c
... ... @@ -363,13 +363,25 @@
363 363 return id;
364 364 }
365 365  
  366 +static int tcic_drv_pcmcia_suspend(struct platform_device *dev,
  367 + pm_message_t state)
  368 +{
  369 + return pcmcia_socket_dev_suspend(&dev->dev, state);
  370 +}
  371 +
  372 +static int tcic_drv_pcmcia_resume(struct platform_device *dev)
  373 +{
  374 + return pcmcia_socket_dev_resume(&dev->dev);
  375 +}
366 376 /*====================================================================*/
367 377  
368   -static struct device_driver tcic_driver = {
369   - .name = "tcic-pcmcia",
370   - .bus = &platform_bus_type,
371   - .suspend = pcmcia_socket_dev_suspend,
372   - .resume = pcmcia_socket_dev_resume,
  378 +static struct platform_driver tcic_driver = {
  379 + .driver = {
  380 + .name = "tcic-pcmcia",
  381 + .owner = THIS_MODULE,
  382 + },
  383 + .suspend = tcic_drv_pcmcia_suspend,
  384 + .resume = tcic_drv_pcmcia_resume,
373 385 };
374 386  
375 387 static struct platform_device tcic_device = {
... ... @@ -383,7 +395,7 @@
383 395 int i, sock, ret = 0;
384 396 u_int mask, scan;
385 397  
386   - if (driver_register(&tcic_driver))
  398 + if (platform_driver_register(&tcic_driver))
387 399 return -1;
388 400  
389 401 printk(KERN_INFO "Databook TCIC-2 PCMCIA probe: ");
... ... @@ -391,7 +403,7 @@
391 403  
392 404 if (!request_region(tcic_base, 16, "tcic-2")) {
393 405 printk("could not allocate ports,\n ");
394   - driver_unregister(&tcic_driver);
  406 + platform_driver_unregister(&tcic_driver);
395 407 return -ENODEV;
396 408 }
397 409 else {
... ... @@ -414,7 +426,7 @@
414 426 if (sock == 0) {
415 427 printk("not found.\n");
416 428 release_region(tcic_base, 16);
417   - driver_unregister(&tcic_driver);
  429 + platform_driver_unregister(&tcic_driver);
418 430 return -ENODEV;
419 431 }
420 432  
... ... @@ -542,7 +554,7 @@
542 554 }
543 555  
544 556 platform_device_unregister(&tcic_device);
545   - driver_unregister(&tcic_driver);
  557 + platform_driver_unregister(&tcic_driver);
546 558 } /* exit_tcic */
547 559  
548 560 /*====================================================================*/
drivers/pcmcia/vrc4171_card.c
... ... @@ -704,24 +704,37 @@
704 704  
705 705 __setup("vrc4171_card=", vrc4171_card_setup);
706 706  
707   -static struct device_driver vrc4171_card_driver = {
708   - .name = vrc4171_card_name,
709   - .bus = &platform_bus_type,
710   - .suspend = pcmcia_socket_dev_suspend,
711   - .resume = pcmcia_socket_dev_resume,
  707 +static int vrc4171_card_suspend(struct platform_device *dev,
  708 + pm_message_t state)
  709 +{
  710 + return pcmcia_socket_dev_suspend(&dev->dev, state);
  711 +}
  712 +
  713 +static int vrc4171_card_resume(struct platform_device *dev)
  714 +{
  715 + return pcmcia_socket_dev_resume(&dev->dev);
  716 +}
  717 +
  718 +static struct platform_driver vrc4171_card_driver = {
  719 + .driver = {
  720 + .name = vrc4171_card_name,
  721 + .owner = THIS_MODULE,
  722 + },
  723 + .suspend = vrc4171_card_suspend,
  724 + .resume = vrc4171_card_resume,
712 725 };
713 726  
714 727 static int __devinit vrc4171_card_init(void)
715 728 {
716 729 int retval;
717 730  
718   - retval = driver_register(&vrc4171_card_driver);
  731 + retval = platform_driver_register(&vrc4171_card_driver);
719 732 if (retval < 0)
720 733 return retval;
721 734  
722 735 retval = platform_device_register(&vrc4171_card_device);
723 736 if (retval < 0) {
724   - driver_unregister(&vrc4171_card_driver);
  737 + platform_driver_unregister(&vrc4171_card_driver);
725 738 return retval;
726 739 }
727 740  
728 741  
... ... @@ -735,11 +748,12 @@
735 748 if (retval < 0) {
736 749 vrc4171_remove_sockets();
737 750 platform_device_unregister(&vrc4171_card_device);
738   - driver_unregister(&vrc4171_card_driver);
  751 + platform_driver_unregister(&vrc4171_card_driver);
739 752 return retval;
740 753 }
741 754  
742   - printk(KERN_INFO "%s, connected to IRQ %d\n", vrc4171_card_driver.name, vrc4171_irq);
  755 + printk(KERN_INFO "%s, connected to IRQ %d\n",
  756 + vrc4171_card_driver.driver.name, vrc4171_irq);
743 757  
744 758 return 0;
745 759 }
... ... @@ -749,7 +763,7 @@
749 763 free_irq(vrc4171_irq, vrc4171_sockets);
750 764 vrc4171_remove_sockets();
751 765 platform_device_unregister(&vrc4171_card_device);
752   - driver_unregister(&vrc4171_card_driver);
  766 + platform_driver_unregister(&vrc4171_card_driver);
753 767 }
754 768  
755 769 module_init(vrc4171_card_init);
drivers/scsi/a4000t.c
... ... @@ -35,7 +35,7 @@
35 35  
36 36 #define A4000T_SCSI_ADDR 0xdd0040
37 37  
38   -static int __devinit a4000t_probe(struct device *dev)
  38 +static int __devinit a4000t_probe(struct platform_device *dev)
39 39 {
40 40 struct Scsi_Host *host;
41 41 struct NCR_700_Host_Parameters *hostdata;
... ... @@ -78,7 +78,7 @@
78 78 goto out_put_host;
79 79 }
80 80  
81   - dev_set_drvdata(dev, host);
  81 + platform_set_drvdata(dev, host);
82 82 scsi_scan_host(host);
83 83  
84 84 return 0;
85 85  
... ... @@ -93,9 +93,9 @@
93 93 return -ENODEV;
94 94 }
95 95  
96   -static __devexit int a4000t_device_remove(struct device *dev)
  96 +static __devexit int a4000t_device_remove(struct platform_device *dev)
97 97 {
98   - struct Scsi_Host *host = dev_get_drvdata(dev);
  98 + struct Scsi_Host *host = platform_get_drvdata(dev);
99 99 struct NCR_700_Host_Parameters *hostdata = shost_priv(host);
100 100  
101 101 scsi_remove_host(host);
102 102  
103 103  
... ... @@ -108,25 +108,27 @@
108 108 return 0;
109 109 }
110 110  
111   -static struct device_driver a4000t_scsi_driver = {
112   - .name = "a4000t-scsi",
113   - .bus = &platform_bus_type,
114   - .probe = a4000t_probe,
115   - .remove = __devexit_p(a4000t_device_remove),
  111 +static struct platform_driver a4000t_scsi_driver = {
  112 + .driver = {
  113 + .name = "a4000t-scsi",
  114 + .owner = THIS_MODULE,
  115 + },
  116 + .probe = a4000t_probe,
  117 + .remove = __devexit_p(a4000t_device_remove),
116 118 };
117 119  
118 120 static int __init a4000t_scsi_init(void)
119 121 {
120 122 int err;
121 123  
122   - err = driver_register(&a4000t_scsi_driver);
  124 + err = platform_driver_register(&a4000t_scsi_driver);
123 125 if (err)
124 126 return err;
125 127  
126 128 a4000t_scsi_device = platform_device_register_simple("a4000t-scsi",
127 129 -1, NULL, 0);
128 130 if (IS_ERR(a4000t_scsi_device)) {
129   - driver_unregister(&a4000t_scsi_driver);
  131 + platform_driver_register(&a4000t_scsi_driver);
130 132 return PTR_ERR(a4000t_scsi_device);
131 133 }
132 134  
... ... @@ -136,7 +138,7 @@
136 138 static void __exit a4000t_scsi_exit(void)
137 139 {
138 140 platform_device_unregister(a4000t_scsi_device);
139   - driver_unregister(&a4000t_scsi_driver);
  141 + platform_driver_unregister(&a4000t_scsi_driver);
140 142 }
141 143  
142 144 module_init(a4000t_scsi_init);
drivers/scsi/bvme6000_scsi.c
... ... @@ -34,7 +34,7 @@
34 34 static struct platform_device *bvme6000_scsi_device;
35 35  
36 36 static __devinit int
37   -bvme6000_probe(struct device *dev)
  37 +bvme6000_probe(struct platform_device *dev)
38 38 {
39 39 struct Scsi_Host *host;
40 40 struct NCR_700_Host_Parameters *hostdata;
... ... @@ -73,7 +73,7 @@
73 73 goto out_put_host;
74 74 }
75 75  
76   - dev_set_drvdata(dev, host);
  76 + platform_set_drvdata(dev, host);
77 77 scsi_scan_host(host);
78 78  
79 79 return 0;
80 80  
... ... @@ -87,9 +87,9 @@
87 87 }
88 88  
89 89 static __devexit int
90   -bvme6000_device_remove(struct device *dev)
  90 +bvme6000_device_remove(struct platform_device *dev)
91 91 {
92   - struct Scsi_Host *host = dev_get_drvdata(dev);
  92 + struct Scsi_Host *host = platform_get_drvdata(dev);
93 93 struct NCR_700_Host_Parameters *hostdata = shost_priv(host);
94 94  
95 95 scsi_remove_host(host);
96 96  
97 97  
... ... @@ -100,25 +100,27 @@
100 100 return 0;
101 101 }
102 102  
103   -static struct device_driver bvme6000_scsi_driver = {
104   - .name = "bvme6000-scsi",
105   - .bus = &platform_bus_type,
106   - .probe = bvme6000_probe,
107   - .remove = __devexit_p(bvme6000_device_remove),
  103 +static struct platform_driver bvme6000_scsi_driver = {
  104 + .driver = {
  105 + .name = "bvme6000-scsi",
  106 + .owner = THIS_MODULE,
  107 + },
  108 + .probe = bvme6000_probe,
  109 + .remove = __devexit_p(bvme6000_device_remove),
108 110 };
109 111  
110 112 static int __init bvme6000_scsi_init(void)
111 113 {
112 114 int err;
113 115  
114   - err = driver_register(&bvme6000_scsi_driver);
  116 + err = platform_driver_register(&bvme6000_scsi_driver);
115 117 if (err)
116 118 return err;
117 119  
118 120 bvme6000_scsi_device = platform_device_register_simple("bvme6000-scsi",
119 121 -1, NULL, 0);
120 122 if (IS_ERR(bvme6000_scsi_device)) {
121   - driver_unregister(&bvme6000_scsi_driver);
  123 + platform_driver_unregister(&bvme6000_scsi_driver);
122 124 return PTR_ERR(bvme6000_scsi_device);
123 125 }
124 126  
... ... @@ -128,7 +130,7 @@
128 130 static void __exit bvme6000_scsi_exit(void)
129 131 {
130 132 platform_device_unregister(bvme6000_scsi_device);
131   - driver_unregister(&bvme6000_scsi_driver);
  133 + platform_driver_unregister(&bvme6000_scsi_driver);
132 134 }
133 135  
134 136 module_init(bvme6000_scsi_init);
drivers/scsi/mvme16x_scsi.c
... ... @@ -34,7 +34,7 @@
34 34 static struct platform_device *mvme16x_scsi_device;
35 35  
36 36 static __devinit int
37   -mvme16x_probe(struct device *dev)
  37 +mvme16x_probe(struct platform_device *dev)
38 38 {
39 39 struct Scsi_Host * host = NULL;
40 40 struct NCR_700_Host_Parameters *hostdata;
... ... @@ -88,7 +88,7 @@
88 88 out_be32(0xfff4202c, v);
89 89 }
90 90  
91   - dev_set_drvdata(dev, host);
  91 + platform_set_drvdata(dev, host);
92 92 scsi_scan_host(host);
93 93  
94 94 return 0;
95 95  
... ... @@ -102,9 +102,9 @@
102 102 }
103 103  
104 104 static __devexit int
105   -mvme16x_device_remove(struct device *dev)
  105 +mvme16x_device_remove(struct platform_device *dev)
106 106 {
107   - struct Scsi_Host *host = dev_get_drvdata(dev);
  107 + struct Scsi_Host *host = platform_get_drvdata(dev);
108 108 struct NCR_700_Host_Parameters *hostdata = shost_priv(host);
109 109  
110 110 /* Disable scsi chip ints */
111 111  
112 112  
... ... @@ -123,25 +123,27 @@
123 123 return 0;
124 124 }
125 125  
126   -static struct device_driver mvme16x_scsi_driver = {
127   - .name = "mvme16x-scsi",
128   - .bus = &platform_bus_type,
129   - .probe = mvme16x_probe,
130   - .remove = __devexit_p(mvme16x_device_remove),
  126 +static struct platform_driver mvme16x_scsi_driver = {
  127 + .driver = {
  128 + .name = "mvme16x-scsi",
  129 + .owner = THIS_MODULE,
  130 + },
  131 + .probe = mvme16x_probe,
  132 + .remove = __devexit_p(mvme16x_device_remove),
131 133 };
132 134  
133 135 static int __init mvme16x_scsi_init(void)
134 136 {
135 137 int err;
136 138  
137   - err = driver_register(&mvme16x_scsi_driver);
  139 + err = platform_driver_register(&mvme16x_scsi_driver);
138 140 if (err)
139 141 return err;
140 142  
141 143 mvme16x_scsi_device = platform_device_register_simple("mvme16x-scsi",
142 144 -1, NULL, 0);
143 145 if (IS_ERR(mvme16x_scsi_device)) {
144   - driver_unregister(&mvme16x_scsi_driver);
  146 + platform_driver_unregister(&mvme16x_scsi_driver);
145 147 return PTR_ERR(mvme16x_scsi_device);
146 148 }
147 149  
... ... @@ -151,7 +153,7 @@
151 153 static void __exit mvme16x_scsi_exit(void)
152 154 {
153 155 platform_device_unregister(mvme16x_scsi_device);
154   - driver_unregister(&mvme16x_scsi_driver);
  156 + platform_driver_unregister(&mvme16x_scsi_driver);
155 157 }
156 158  
157 159 module_init(mvme16x_scsi_init);
drivers/video/au1100fb.c
... ... @@ -457,7 +457,7 @@
457 457  
458 458 /* AU1100 LCD controller device driver */
459 459  
460   -static int __init au1100fb_drv_probe(struct device *dev)
  460 +static int __init au1100fb_drv_probe(struct platform_device *dev)
461 461 {
462 462 struct au1100fb_device *fbdev = NULL;
463 463 struct resource *regs_res;
... ... @@ -475,7 +475,7 @@
475 475  
476 476 fbdev->panel = &known_lcd_panels[drv_info.panel_idx];
477 477  
478   - dev_set_drvdata(dev, (void*)fbdev);
  478 + platform_set_drvdata(dev, (void *)fbdev);
479 479  
480 480 /* Allocate region for our registers and map them */
481 481 if (!(regs_res = platform_get_resource(to_platform_device(dev),
482 482  
483 483  
... ... @@ -583,19 +583,19 @@
583 583 fb_dealloc_cmap(&fbdev->info.cmap);
584 584 }
585 585 kfree(fbdev);
586   - dev_set_drvdata(dev, NULL);
  586 + platform_set_drvdata(dev, NULL);
587 587  
588 588 return 0;
589 589 }
590 590  
591   -int au1100fb_drv_remove(struct device *dev)
  591 +int au1100fb_drv_remove(struct platform_device *dev)
592 592 {
593 593 struct au1100fb_device *fbdev = NULL;
594 594  
595 595 if (!dev)
596 596 return -ENODEV;
597 597  
598   - fbdev = (struct au1100fb_device*) dev_get_drvdata(dev);
  598 + fbdev = (struct au1100fb_device *) platform_get_drvdata(dev);
599 599  
600 600 #if !defined(CONFIG_FRAMEBUFFER_CONSOLE) && defined(CONFIG_LOGO)
601 601 au1100fb_fb_blank(VESA_POWERDOWN, &fbdev->info);
602 602  
... ... @@ -620,9 +620,9 @@
620 620 static u32 sys_clksrc;
621 621 static struct au1100fb_regs fbregs;
622 622  
623   -int au1100fb_drv_suspend(struct device *dev, pm_message_t state)
  623 +int au1100fb_drv_suspend(struct platform_device *dev, pm_message_t state)
624 624 {
625   - struct au1100fb_device *fbdev = dev_get_drvdata(dev);
  625 + struct au1100fb_device *fbdev = platform_get_drvdata(dev);
626 626  
627 627 if (!fbdev)
628 628 return 0;
629 629  
... ... @@ -641,9 +641,9 @@
641 641 return 0;
642 642 }
643 643  
644   -int au1100fb_drv_resume(struct device *dev)
  644 +int au1100fb_drv_resume(struct platform_device *dev)
645 645 {
646   - struct au1100fb_device *fbdev = dev_get_drvdata(dev);
  646 + struct au1100fb_device *fbdev = platform_get_drvdata(dev);
647 647  
648 648 if (!fbdev)
649 649 return 0;
... ... @@ -663,10 +663,11 @@
663 663 #define au1100fb_drv_resume NULL
664 664 #endif
665 665  
666   -static struct device_driver au1100fb_driver = {
667   - .name = "au1100-lcd",
668   - .bus = &platform_bus_type,
669   -
  666 +static struct platform_driver au1100fb_driver = {
  667 + .driver = {
  668 + .name = "au1100-lcd",
  669 + .owner = THIS_MODULE,
  670 + },
670 671 .probe = au1100fb_drv_probe,
671 672 .remove = au1100fb_drv_remove,
672 673 .suspend = au1100fb_drv_suspend,
673 674  
... ... @@ -753,12 +754,12 @@
753 754 return ret;
754 755 }
755 756  
756   - return driver_register(&au1100fb_driver);
  757 + return platform_driver_register(&au1100fb_driver);
757 758 }
758 759  
759 760 void __exit au1100fb_cleanup(void)
760 761 {
761   - driver_unregister(&au1100fb_driver);
  762 + platform_driver_unregister(&au1100fb_driver);
762 763  
763 764 kfree(drv_info.opt_mode);
764 765 }
drivers/video/au1200fb.c
... ... @@ -1622,7 +1622,7 @@
1622 1622  
1623 1623 /* AU1200 LCD controller device driver */
1624 1624  
1625   -static int au1200fb_drv_probe(struct device *dev)
  1625 +static int au1200fb_drv_probe(struct platform_device *dev)
1626 1626 {
1627 1627 struct au1200fb_device *fbdev;
1628 1628 unsigned long page;
... ... @@ -1645,7 +1645,7 @@
1645 1645 /* Allocate the framebuffer to the maximum screen size */
1646 1646 fbdev->fb_len = (win->w[plane].xres * win->w[plane].yres * bpp) / 8;
1647 1647  
1648   - fbdev->fb_mem = dma_alloc_noncoherent(dev,
  1648 + fbdev->fb_mem = dma_alloc_noncoherent(&dev->dev,
1649 1649 PAGE_ALIGN(fbdev->fb_len),
1650 1650 &fbdev->fb_phys, GFP_KERNEL);
1651 1651 if (!fbdev->fb_mem) {
... ... @@ -1715,7 +1715,7 @@
1715 1715 return ret;
1716 1716 }
1717 1717  
1718   -static int au1200fb_drv_remove(struct device *dev)
  1718 +static int au1200fb_drv_remove(struct platform_device *dev)
1719 1719 {
1720 1720 struct au1200fb_device *fbdev;
1721 1721 int plane;
... ... @@ -1733,7 +1733,8 @@
1733 1733 /* Clean up all probe data */
1734 1734 unregister_framebuffer(&fbdev->fb_info);
1735 1735 if (fbdev->fb_mem)
1736   - dma_free_noncoherent(dev, PAGE_ALIGN(fbdev->fb_len),
  1736 + dma_free_noncoherent(&dev->dev,
  1737 + PAGE_ALIGN(fbdev->fb_len),
1737 1738 fbdev->fb_mem, fbdev->fb_phys);
1738 1739 if (fbdev->fb_info.cmap.len != 0)
1739 1740 fb_dealloc_cmap(&fbdev->fb_info.cmap);
1740 1741  
1741 1742  
... ... @@ -1747,22 +1748,24 @@
1747 1748 }
1748 1749  
1749 1750 #ifdef CONFIG_PM
1750   -static int au1200fb_drv_suspend(struct device *dev, u32 state, u32 level)
  1751 +static int au1200fb_drv_suspend(struct platform_device *dev, u32 state)
1751 1752 {
1752 1753 /* TODO */
1753 1754 return 0;
1754 1755 }
1755 1756  
1756   -static int au1200fb_drv_resume(struct device *dev, u32 level)
  1757 +static int au1200fb_drv_resume(struct platform_device *dev)
1757 1758 {
1758 1759 /* TODO */
1759 1760 return 0;
1760 1761 }
1761 1762 #endif /* CONFIG_PM */
1762 1763  
1763   -static struct device_driver au1200fb_driver = {
1764   - .name = "au1200-lcd",
1765   - .bus = &platform_bus_type,
  1764 +static struct platform_driver au1200fb_driver = {
  1765 + .driver = {
  1766 + .name = "au1200-lcd",
  1767 + .owner = THIS_MODULE,
  1768 + },
1766 1769 .probe = au1200fb_drv_probe,
1767 1770 .remove = au1200fb_drv_remove,
1768 1771 #ifdef CONFIG_PM
1769 1772  
... ... @@ -1906,12 +1909,12 @@
1906 1909 printk(KERN_INFO "Power management device entry for the au1200fb loaded.\n");
1907 1910 #endif
1908 1911  
1909   - return driver_register(&au1200fb_driver);
  1912 + return platform_driver_register(&au1200fb_driver);
1910 1913 }
1911 1914  
1912 1915 static void __exit au1200fb_cleanup(void)
1913 1916 {
1914   - driver_unregister(&au1200fb_driver);
  1917 + platform_driver_unregister(&au1200fb_driver);
1915 1918 }
1916 1919  
1917 1920 module_init(au1200fb_init);
drivers/watchdog/rm9k_wdt.c
... ... @@ -59,8 +59,8 @@
59 59 static int wdt_gpi_notify(struct notifier_block *, unsigned long, void *);
60 60 static const struct resource *wdt_gpi_get_resource(struct platform_device *,
61 61 const char *, unsigned int);
62   -static int __init wdt_gpi_probe(struct device *);
63   -static int __exit wdt_gpi_remove(struct device *);
  62 +static int __init wdt_gpi_probe(struct platform_device *);
  63 +static int __exit wdt_gpi_remove(struct platform_device *);
64 64  
65 65  
66 66 static const char wdt_gpi_name[] = "wdt_gpi";
67 67  
... ... @@ -346,10 +346,9 @@
346 346 }
347 347  
348 348 /* No hotplugging on the platform bus - use __init */
349   -static int __init wdt_gpi_probe(struct device *dev)
  349 +static int __init wdt_gpi_probe(struct platform_device *pdv)
350 350 {
351 351 int res;
352   - struct platform_device * const pdv = to_platform_device(dev);
353 352 const struct resource
354 353 * const rr = wdt_gpi_get_resource(pdv, WDT_RESOURCE_REGS,
355 354 IORESOURCE_MEM),
... ... @@ -374,7 +373,7 @@
374 373 return res;
375 374 }
376 375  
377   -static int __exit wdt_gpi_remove(struct device *dev)
  376 +static int __exit wdt_gpi_remove(struct platform_device *dev)
378 377 {
379 378 int res;
380 379  
381 380  
... ... @@ -387,15 +386,13 @@
387 386  
388 387  
389 388 /* Device driver init & exit */
390   -static struct device_driver wdt_gpi_driver = {
391   - .name = (char *) wdt_gpi_name,
392   - .bus = &platform_bus_type,
393   - .owner = THIS_MODULE,
  389 +static struct platform_driver wgt_gpi_driver = {
  390 + .driver = {
  391 + .name = wdt_gpi_name,
  392 + .owner = THIS_MODULE,
  393 + },
394 394 .probe = wdt_gpi_probe,
395   - .remove = __exit_p(wdt_gpi_remove),
396   - .shutdown = NULL,
397   - .suspend = NULL,
398   - .resume = NULL,
  395 + .remove = __devexit_p(wdt_gpi_remove),
399 396 };
400 397  
401 398 static int __init wdt_gpi_init_module(void)
402 399  
... ... @@ -403,12 +400,12 @@
403 400 atomic_set(&opencnt, 1);
404 401 if (timeout > MAX_TIMEOUT_SECONDS)
405 402 timeout = MAX_TIMEOUT_SECONDS;
406   - return driver_register(&wdt_gpi_driver);
  403 + return platform_driver_register(&wdt_gpi_driver);
407 404 }
408 405  
409 406 static void __exit wdt_gpi_cleanup_module(void)
410 407 {
411   - driver_unregister(&wdt_gpi_driver);
  408 + platform_driver_unregister(&wdt_gpi_driver);
412 409 }
413 410  
414 411 module_init(wdt_gpi_init_module);