aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/busses
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2005-11-09 17:32:44 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2005-11-09 17:32:44 -0500
commit3ae5eaec1d2d9c0cf53745352e7d4b152810ba24 (patch)
treed8825be54cefb6ad6707478d719c8e30605bee7b /drivers/i2c/busses
parent00d3dcdd96646be6059cc21f2efa94c4edc1eda5 (diff)
[DRIVER MODEL] Convert platform drivers to use struct platform_driver
This allows us to eliminate the casts in the drivers, and eventually remove the use of the device_driver function pointer methods for platform device drivers. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/i2c/busses')
-rw-r--r--drivers/i2c/busses/i2c-iop3xx.c27
-rw-r--r--drivers/i2c/busses/i2c-ixp2000.c25
-rw-r--r--drivers/i2c/busses/i2c-ixp4xx.c25
-rw-r--r--drivers/i2c/busses/i2c-mpc.c24
-rw-r--r--drivers/i2c/busses/i2c-mv64xxx.c24
-rw-r--r--drivers/i2c/busses/i2c-pxa.c25
-rw-r--r--drivers/i2c/busses/i2c-s3c2410.c71
7 files changed, 110 insertions, 111 deletions
diff --git a/drivers/i2c/busses/i2c-iop3xx.c b/drivers/i2c/busses/i2c-iop3xx.c
index cfae4ad00fae..1414851a17b8 100644
--- a/drivers/i2c/busses/i2c-iop3xx.c
+++ b/drivers/i2c/busses/i2c-iop3xx.c
@@ -405,10 +405,9 @@ static struct i2c_algorithm iop3xx_i2c_algo = {
405}; 405};
406 406
407static int 407static int
408iop3xx_i2c_remove(struct device *device) 408iop3xx_i2c_remove(struct platform_device *pdev)
409{ 409{
410 struct platform_device *pdev = to_platform_device(device); 410 struct i2c_adapter *padapter = platform_get_drvdata(pdev);
411 struct i2c_adapter *padapter = dev_get_drvdata(&pdev->dev);
412 struct i2c_algo_iop3xx_data *adapter_data = 411 struct i2c_algo_iop3xx_data *adapter_data =
413 (struct i2c_algo_iop3xx_data *)padapter->algo_data; 412 (struct i2c_algo_iop3xx_data *)padapter->algo_data;
414 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 413 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -426,15 +425,14 @@ iop3xx_i2c_remove(struct device *device)
426 kfree(adapter_data); 425 kfree(adapter_data);
427 kfree(padapter); 426 kfree(padapter);
428 427
429 dev_set_drvdata(&pdev->dev, NULL); 428 platform_set_drvdata(pdev, NULL);
430 429
431 return 0; 430 return 0;
432} 431}
433 432
434static int 433static int
435iop3xx_i2c_probe(struct device *dev) 434iop3xx_i2c_probe(struct platform_device *pdev)
436{ 435{
437 struct platform_device *pdev = to_platform_device(dev);
438 struct resource *res; 436 struct resource *res;
439 int ret; 437 int ret;
440 struct i2c_adapter *new_adapter; 438 struct i2c_adapter *new_adapter;
@@ -499,7 +497,7 @@ iop3xx_i2c_probe(struct device *dev)
499 iop3xx_i2c_set_slave_addr(adapter_data); 497 iop3xx_i2c_set_slave_addr(adapter_data);
500 iop3xx_i2c_enable(adapter_data); 498 iop3xx_i2c_enable(adapter_data);
501 499
502 dev_set_drvdata(&pdev->dev, new_adapter); 500 platform_set_drvdata(pdev, new_adapter);
503 new_adapter->algo_data = adapter_data; 501 new_adapter->algo_data = adapter_data;
504 502
505 i2c_add_adapter(new_adapter); 503 i2c_add_adapter(new_adapter);
@@ -523,24 +521,25 @@ out:
523} 521}
524 522
525 523
526static struct device_driver iop3xx_i2c_driver = { 524static struct platform_driver iop3xx_i2c_driver = {
527 .owner = THIS_MODULE,
528 .name = "IOP3xx-I2C",
529 .bus = &platform_bus_type,
530 .probe = iop3xx_i2c_probe, 525 .probe = iop3xx_i2c_probe,
531 .remove = iop3xx_i2c_remove 526 .remove = iop3xx_i2c_remove,
527 .driver = {
528 .owner = THIS_MODULE,
529 .name = "IOP3xx-I2C",
530 },
532}; 531};
533 532
534static int __init 533static int __init
535i2c_iop3xx_init (void) 534i2c_iop3xx_init (void)
536{ 535{
537 return driver_register(&iop3xx_i2c_driver); 536 return platform_driver_register(&iop3xx_i2c_driver);
538} 537}
539 538
540static void __exit 539static void __exit
541i2c_iop3xx_exit (void) 540i2c_iop3xx_exit (void)
542{ 541{
543 driver_unregister(&iop3xx_i2c_driver); 542 platform_driver_unregister(&iop3xx_i2c_driver);
544 return; 543 return;
545} 544}
546 545
diff --git a/drivers/i2c/busses/i2c-ixp2000.c b/drivers/i2c/busses/i2c-ixp2000.c
index 64552a376f2d..cef024a7d048 100644
--- a/drivers/i2c/busses/i2c-ixp2000.c
+++ b/drivers/i2c/busses/i2c-ixp2000.c
@@ -86,12 +86,11 @@ struct ixp2000_i2c_data {
86 struct i2c_algo_bit_data algo_data; 86 struct i2c_algo_bit_data algo_data;
87}; 87};
88 88
89static int ixp2000_i2c_remove(struct device *dev) 89static int ixp2000_i2c_remove(struct platform_device *plat_dev)
90{ 90{
91 struct platform_device *plat_dev = to_platform_device(dev); 91 struct ixp2000_i2c_data *drv_data = platform_get_drvdata(plat_dev);
92 struct ixp2000_i2c_data *drv_data = dev_get_drvdata(&plat_dev->dev);
93 92
94 dev_set_drvdata(&plat_dev->dev, NULL); 93 platform_set_drvdata(plat_dev, NULL);
95 94
96 i2c_bit_del_bus(&drv_data->adapter); 95 i2c_bit_del_bus(&drv_data->adapter);
97 96
@@ -100,10 +99,9 @@ static int ixp2000_i2c_remove(struct device *dev)
100 return 0; 99 return 0;
101} 100}
102 101
103static int ixp2000_i2c_probe(struct device *dev) 102static int ixp2000_i2c_probe(struct platform_device *plat_dev)
104{ 103{
105 int err; 104 int err;
106 struct platform_device *plat_dev = to_platform_device(dev);
107 struct ixp2000_i2c_pins *gpio = plat_dev->dev.platform_data; 105 struct ixp2000_i2c_pins *gpio = plat_dev->dev.platform_data;
108 struct ixp2000_i2c_data *drv_data = 106 struct ixp2000_i2c_data *drv_data =
109 kzalloc(sizeof(struct ixp2000_i2c_data), GFP_KERNEL); 107 kzalloc(sizeof(struct ixp2000_i2c_data), GFP_KERNEL);
@@ -139,27 +137,28 @@ static int ixp2000_i2c_probe(struct device *dev)
139 return err; 137 return err;
140 } 138 }
141 139
142 dev_set_drvdata(&plat_dev->dev, drv_data); 140 platform_set_drvdata(plat_dev, drv_data);
143 141
144 return 0; 142 return 0;
145} 143}
146 144
147static struct device_driver ixp2000_i2c_driver = { 145static struct platform_driver ixp2000_i2c_driver = {
148 .owner = THIS_MODULE,
149 .name = "IXP2000-I2C",
150 .bus = &platform_bus_type,
151 .probe = ixp2000_i2c_probe, 146 .probe = ixp2000_i2c_probe,
152 .remove = ixp2000_i2c_remove, 147 .remove = ixp2000_i2c_remove,
148 .driver = {
149 .name = "IXP2000-I2C",
150 .owner = THIS_MODULE,
151 },
153}; 152};
154 153
155static int __init ixp2000_i2c_init(void) 154static int __init ixp2000_i2c_init(void)
156{ 155{
157 return driver_register(&ixp2000_i2c_driver); 156 return platform_driver_register(&ixp2000_i2c_driver);
158} 157}
159 158
160static void __exit ixp2000_i2c_exit(void) 159static void __exit ixp2000_i2c_exit(void)
161{ 160{
162 driver_unregister(&ixp2000_i2c_driver); 161 platform_driver_unregister(&ixp2000_i2c_driver);
163} 162}
164 163
165module_init(ixp2000_i2c_init); 164module_init(ixp2000_i2c_init);
diff --git a/drivers/i2c/busses/i2c-ixp4xx.c b/drivers/i2c/busses/i2c-ixp4xx.c
index cc652c350814..aa36855fa995 100644
--- a/drivers/i2c/busses/i2c-ixp4xx.c
+++ b/drivers/i2c/busses/i2c-ixp4xx.c
@@ -87,12 +87,11 @@ struct ixp4xx_i2c_data {
87 struct i2c_algo_bit_data algo_data; 87 struct i2c_algo_bit_data algo_data;
88}; 88};
89 89
90static int ixp4xx_i2c_remove(struct device *dev) 90static int ixp4xx_i2c_remove(struct platform_device *plat_dev)
91{ 91{
92 struct platform_device *plat_dev = to_platform_device(dev); 92 struct ixp4xx_i2c_data *drv_data = platform_get_drvdata(plat_dev);
93 struct ixp4xx_i2c_data *drv_data = dev_get_drvdata(&plat_dev->dev);
94 93
95 dev_set_drvdata(&plat_dev->dev, NULL); 94 platform_set_drvdata(plat_dev, NULL);
96 95
97 i2c_bit_del_bus(&drv_data->adapter); 96 i2c_bit_del_bus(&drv_data->adapter);
98 97
@@ -101,10 +100,9 @@ static int ixp4xx_i2c_remove(struct device *dev)
101 return 0; 100 return 0;
102} 101}
103 102
104static int ixp4xx_i2c_probe(struct device *dev) 103static int ixp4xx_i2c_probe(struct platform_device *plat_dev)
105{ 104{
106 int err; 105 int err;
107 struct platform_device *plat_dev = to_platform_device(dev);
108 struct ixp4xx_i2c_pins *gpio = plat_dev->dev.platform_data; 106 struct ixp4xx_i2c_pins *gpio = plat_dev->dev.platform_data;
109 struct ixp4xx_i2c_data *drv_data = 107 struct ixp4xx_i2c_data *drv_data =
110 kzalloc(sizeof(struct ixp4xx_i2c_data), GFP_KERNEL); 108 kzalloc(sizeof(struct ixp4xx_i2c_data), GFP_KERNEL);
@@ -148,27 +146,28 @@ static int ixp4xx_i2c_probe(struct device *dev)
148 return err; 146 return err;
149 } 147 }
150 148
151 dev_set_drvdata(&plat_dev->dev, drv_data); 149 platform_set_drvdata(plat_dev, drv_data);
152 150
153 return 0; 151 return 0;
154} 152}
155 153
156static struct device_driver ixp4xx_i2c_driver = { 154static struct platform_driver ixp4xx_i2c_driver = {
157 .owner = THIS_MODULE,
158 .name = "IXP4XX-I2C",
159 .bus = &platform_bus_type,
160 .probe = ixp4xx_i2c_probe, 155 .probe = ixp4xx_i2c_probe,
161 .remove = ixp4xx_i2c_remove, 156 .remove = ixp4xx_i2c_remove,
157 .driver = {
158 .name = "IXP4XX-I2C",
159 .owner = THIS_MODULE,
160 },
162}; 161};
163 162
164static int __init ixp4xx_i2c_init(void) 163static int __init ixp4xx_i2c_init(void)
165{ 164{
166 return driver_register(&ixp4xx_i2c_driver); 165 return platform_driver_register(&ixp4xx_i2c_driver);
167} 166}
168 167
169static void __exit ixp4xx_i2c_exit(void) 168static void __exit ixp4xx_i2c_exit(void)
170{ 169{
171 driver_unregister(&ixp4xx_i2c_driver); 170 platform_driver_unregister(&ixp4xx_i2c_driver);
172} 171}
173 172
174module_init(ixp4xx_i2c_init); 173module_init(ixp4xx_i2c_init);
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index 65b939a059e9..5ccd338a9dc9 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -288,11 +288,10 @@ static struct i2c_adapter mpc_ops = {
288 .retries = 1 288 .retries = 1
289}; 289};
290 290
291static int fsl_i2c_probe(struct device *device) 291static int fsl_i2c_probe(struct platform_device *pdev)
292{ 292{
293 int result = 0; 293 int result = 0;
294 struct mpc_i2c *i2c; 294 struct mpc_i2c *i2c;
295 struct platform_device *pdev = to_platform_device(device);
296 struct fsl_i2c_platform_data *pdata; 295 struct fsl_i2c_platform_data *pdata;
297 struct resource *r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 296 struct resource *r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
298 297
@@ -323,7 +322,7 @@ static int fsl_i2c_probe(struct device *device)
323 } 322 }
324 323
325 mpc_i2c_setclock(i2c); 324 mpc_i2c_setclock(i2c);
326 dev_set_drvdata(device, i2c); 325 platform_set_drvdata(pdev, i2c);
327 326
328 i2c->adap = mpc_ops; 327 i2c->adap = mpc_ops;
329 i2c_set_adapdata(&i2c->adap, i2c); 328 i2c_set_adapdata(&i2c->adap, i2c);
@@ -345,12 +344,12 @@ static int fsl_i2c_probe(struct device *device)
345 return result; 344 return result;
346}; 345};
347 346
348static int fsl_i2c_remove(struct device *device) 347static int fsl_i2c_remove(struct platform_device *pdev)
349{ 348{
350 struct mpc_i2c *i2c = dev_get_drvdata(device); 349 struct mpc_i2c *i2c = platform_get_drvdata(pdev);
351 350
352 i2c_del_adapter(&i2c->adap); 351 i2c_del_adapter(&i2c->adap);
353 dev_set_drvdata(device, NULL); 352 platform_set_drvdata(pdev, NULL);
354 353
355 if (i2c->irq != 0) 354 if (i2c->irq != 0)
356 free_irq(i2c->irq, i2c); 355 free_irq(i2c->irq, i2c);
@@ -361,22 +360,23 @@ static int fsl_i2c_remove(struct device *device)
361}; 360};
362 361
363/* Structure for a device driver */ 362/* Structure for a device driver */
364static struct device_driver fsl_i2c_driver = { 363static struct platform_driver fsl_i2c_driver = {
365 .owner = THIS_MODULE,
366 .name = "fsl-i2c",
367 .bus = &platform_bus_type,
368 .probe = fsl_i2c_probe, 364 .probe = fsl_i2c_probe,
369 .remove = fsl_i2c_remove, 365 .remove = fsl_i2c_remove,
366 .driver = {
367 .owner = THIS_MODULE,
368 .name = "fsl-i2c",
369 },
370}; 370};
371 371
372static int __init fsl_i2c_init(void) 372static int __init fsl_i2c_init(void)
373{ 373{
374 return driver_register(&fsl_i2c_driver); 374 return platform_driver_register(&fsl_i2c_driver);
375} 375}
376 376
377static void __exit fsl_i2c_exit(void) 377static void __exit fsl_i2c_exit(void)
378{ 378{
379 driver_unregister(&fsl_i2c_driver); 379 platform_driver_unregister(&fsl_i2c_driver);
380} 380}
381 381
382module_init(fsl_i2c_init); 382module_init(fsl_i2c_init);
diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c
index 6b48027b2ee3..afd7634e5cc9 100644
--- a/drivers/i2c/busses/i2c-mv64xxx.c
+++ b/drivers/i2c/busses/i2c-mv64xxx.c
@@ -492,11 +492,10 @@ mv64xxx_i2c_unmap_regs(struct mv64xxx_i2c_data *drv_data)
492} 492}
493 493
494static int __devinit 494static int __devinit
495mv64xxx_i2c_probe(struct device *dev) 495mv64xxx_i2c_probe(struct platform_device *pd)
496{ 496{
497 struct platform_device *pd = to_platform_device(dev);
498 struct mv64xxx_i2c_data *drv_data; 497 struct mv64xxx_i2c_data *drv_data;
499 struct mv64xxx_i2c_pdata *pdata = dev->platform_data; 498 struct mv64xxx_i2c_pdata *pdata = pd->dev.platform_data;
500 int rc; 499 int rc;
501 500
502 if ((pd->id != 0) || !pdata) 501 if ((pd->id != 0) || !pdata)
@@ -526,7 +525,7 @@ mv64xxx_i2c_probe(struct device *dev)
526 drv_data->adapter.class = I2C_CLASS_HWMON; 525 drv_data->adapter.class = I2C_CLASS_HWMON;
527 drv_data->adapter.timeout = pdata->timeout; 526 drv_data->adapter.timeout = pdata->timeout;
528 drv_data->adapter.retries = pdata->retries; 527 drv_data->adapter.retries = pdata->retries;
529 dev_set_drvdata(dev, drv_data); 528 platform_set_drvdata(pd, drv_data);
530 i2c_set_adapdata(&drv_data->adapter, drv_data); 529 i2c_set_adapdata(&drv_data->adapter, drv_data);
531 530
532 if (request_irq(drv_data->irq, mv64xxx_i2c_intr, 0, 531 if (request_irq(drv_data->irq, mv64xxx_i2c_intr, 0,
@@ -555,9 +554,9 @@ mv64xxx_i2c_probe(struct device *dev)
555} 554}
556 555
557static int __devexit 556static int __devexit
558mv64xxx_i2c_remove(struct device *dev) 557mv64xxx_i2c_remove(struct platform_device *dev)
559{ 558{
560 struct mv64xxx_i2c_data *drv_data = dev_get_drvdata(dev); 559 struct mv64xxx_i2c_data *drv_data = platform_get_drvdata(dev);
561 int rc; 560 int rc;
562 561
563 rc = i2c_del_adapter(&drv_data->adapter); 562 rc = i2c_del_adapter(&drv_data->adapter);
@@ -568,24 +567,25 @@ mv64xxx_i2c_remove(struct device *dev)
568 return rc; 567 return rc;
569} 568}
570 569
571static struct device_driver mv64xxx_i2c_driver = { 570static struct platform_driver mv64xxx_i2c_driver = {
572 .owner = THIS_MODULE,
573 .name = MV64XXX_I2C_CTLR_NAME,
574 .bus = &platform_bus_type,
575 .probe = mv64xxx_i2c_probe, 571 .probe = mv64xxx_i2c_probe,
576 .remove = mv64xxx_i2c_remove, 572 .remove = mv64xxx_i2c_remove,
573 .driver = {
574 .owner = THIS_MODULE,
575 .name = MV64XXX_I2C_CTLR_NAME,
576 },
577}; 577};
578 578
579static int __init 579static int __init
580mv64xxx_i2c_init(void) 580mv64xxx_i2c_init(void)
581{ 581{
582 return driver_register(&mv64xxx_i2c_driver); 582 return platform_driver_register(&mv64xxx_i2c_driver);
583} 583}
584 584
585static void __exit 585static void __exit
586mv64xxx_i2c_exit(void) 586mv64xxx_i2c_exit(void)
587{ 587{
588 driver_unregister(&mv64xxx_i2c_driver); 588 platform_driver_unregister(&mv64xxx_i2c_driver);
589} 589}
590 590
591module_init(mv64xxx_i2c_init); 591module_init(mv64xxx_i2c_init);
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index 67ccbea24ba4..70f7ab829d36 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -936,10 +936,10 @@ static struct pxa_i2c i2c_pxa = {
936 }, 936 },
937}; 937};
938 938
939static int i2c_pxa_probe(struct device *dev) 939static int i2c_pxa_probe(struct platform_device *dev)
940{ 940{
941 struct pxa_i2c *i2c = &i2c_pxa; 941 struct pxa_i2c *i2c = &i2c_pxa;
942 struct i2c_pxa_platform_data *plat = dev->platform_data; 942 struct i2c_pxa_platform_data *plat = dev->dev.platform_data;
943 int ret; 943 int ret;
944 944
945#ifdef CONFIG_PXA27x 945#ifdef CONFIG_PXA27x
@@ -968,7 +968,7 @@ static int i2c_pxa_probe(struct device *dev)
968 i2c_pxa_reset(i2c); 968 i2c_pxa_reset(i2c);
969 969
970 i2c->adap.algo_data = i2c; 970 i2c->adap.algo_data = i2c;
971 i2c->adap.dev.parent = dev; 971 i2c->adap.dev.parent = &dev->dev;
972 972
973 ret = i2c_add_adapter(&i2c->adap); 973 ret = i2c_add_adapter(&i2c->adap);
974 if (ret < 0) { 974 if (ret < 0) {
@@ -976,7 +976,7 @@ static int i2c_pxa_probe(struct device *dev)
976 goto err_irq; 976 goto err_irq;
977 } 977 }
978 978
979 dev_set_drvdata(dev, i2c); 979 platform_set_drvdata(dev, i2c);
980 980
981#ifdef CONFIG_I2C_PXA_SLAVE 981#ifdef CONFIG_I2C_PXA_SLAVE
982 printk(KERN_INFO "I2C: %s: PXA I2C adapter, slave address %d\n", 982 printk(KERN_INFO "I2C: %s: PXA I2C adapter, slave address %d\n",
@@ -993,11 +993,11 @@ static int i2c_pxa_probe(struct device *dev)
993 return ret; 993 return ret;
994} 994}
995 995
996static int i2c_pxa_remove(struct device *dev) 996static int i2c_pxa_remove(struct platform_device *dev)
997{ 997{
998 struct pxa_i2c *i2c = dev_get_drvdata(dev); 998 struct pxa_i2c *i2c = platform_get_drvdata(dev);
999 999
1000 dev_set_drvdata(dev, NULL); 1000 platform_set_drvdata(dev, NULL);
1001 1001
1002 i2c_del_adapter(&i2c->adap); 1002 i2c_del_adapter(&i2c->adap);
1003 free_irq(IRQ_I2C, i2c); 1003 free_irq(IRQ_I2C, i2c);
@@ -1006,21 +1006,22 @@ static int i2c_pxa_remove(struct device *dev)
1006 return 0; 1006 return 0;
1007} 1007}
1008 1008
1009static struct device_driver i2c_pxa_driver = { 1009static struct platform_driver i2c_pxa_driver = {
1010 .name = "pxa2xx-i2c",
1011 .bus = &platform_bus_type,
1012 .probe = i2c_pxa_probe, 1010 .probe = i2c_pxa_probe,
1013 .remove = i2c_pxa_remove, 1011 .remove = i2c_pxa_remove,
1012 .driver = {
1013 .name = "pxa2xx-i2c",
1014 },
1014}; 1015};
1015 1016
1016static int __init i2c_adap_pxa_init(void) 1017static int __init i2c_adap_pxa_init(void)
1017{ 1018{
1018 return driver_register(&i2c_pxa_driver); 1019 return platform_driver_register(&i2c_pxa_driver);
1019} 1020}
1020 1021
1021static void i2c_adap_pxa_exit(void) 1022static void i2c_adap_pxa_exit(void)
1022{ 1023{
1023 return driver_unregister(&i2c_pxa_driver); 1024 return platform_driver_unregister(&i2c_pxa_driver);
1024} 1025}
1025 1026
1026module_init(i2c_adap_pxa_init); 1027module_init(i2c_adap_pxa_init);
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 1b582262e677..58cfd3111ef6 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -760,24 +760,23 @@ static void s3c24xx_i2c_free(struct s3c24xx_i2c *i2c)
760 * called by the bus driver when a suitable device is found 760 * called by the bus driver when a suitable device is found
761*/ 761*/
762 762
763static int s3c24xx_i2c_probe(struct device *dev) 763static int s3c24xx_i2c_probe(struct platform_device *pdev)
764{ 764{
765 struct platform_device *pdev = to_platform_device(dev);
766 struct s3c24xx_i2c *i2c = &s3c24xx_i2c; 765 struct s3c24xx_i2c *i2c = &s3c24xx_i2c;
767 struct resource *res; 766 struct resource *res;
768 int ret; 767 int ret;
769 768
770 /* find the clock and enable it */ 769 /* find the clock and enable it */
771 770
772 i2c->dev = dev; 771 i2c->dev = &pdev->dev;
773 i2c->clk = clk_get(dev, "i2c"); 772 i2c->clk = clk_get(&pdev->dev, "i2c");
774 if (IS_ERR(i2c->clk)) { 773 if (IS_ERR(i2c->clk)) {
775 dev_err(dev, "cannot get clock\n"); 774 dev_err(&pdev->dev, "cannot get clock\n");
776 ret = -ENOENT; 775 ret = -ENOENT;
777 goto out; 776 goto out;
778 } 777 }
779 778
780 dev_dbg(dev, "clock source %p\n", i2c->clk); 779 dev_dbg(&pdev->dev, "clock source %p\n", i2c->clk);
781 780
782 clk_use(i2c->clk); 781 clk_use(i2c->clk);
783 clk_enable(i2c->clk); 782 clk_enable(i2c->clk);
@@ -786,7 +785,7 @@ static int s3c24xx_i2c_probe(struct device *dev)
786 785
787 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 786 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
788 if (res == NULL) { 787 if (res == NULL) {
789 dev_err(dev, "cannot find IO resource\n"); 788 dev_err(&pdev->dev, "cannot find IO resource\n");
790 ret = -ENOENT; 789 ret = -ENOENT;
791 goto out; 790 goto out;
792 } 791 }
@@ -795,7 +794,7 @@ static int s3c24xx_i2c_probe(struct device *dev)
795 pdev->name); 794 pdev->name);
796 795
797 if (i2c->ioarea == NULL) { 796 if (i2c->ioarea == NULL) {
798 dev_err(dev, "cannot request IO\n"); 797 dev_err(&pdev->dev, "cannot request IO\n");
799 ret = -ENXIO; 798 ret = -ENXIO;
800 goto out; 799 goto out;
801 } 800 }
@@ -803,17 +802,17 @@ static int s3c24xx_i2c_probe(struct device *dev)
803 i2c->regs = ioremap(res->start, (res->end-res->start)+1); 802 i2c->regs = ioremap(res->start, (res->end-res->start)+1);
804 803
805 if (i2c->regs == NULL) { 804 if (i2c->regs == NULL) {
806 dev_err(dev, "cannot map IO\n"); 805 dev_err(&pdev->dev, "cannot map IO\n");
807 ret = -ENXIO; 806 ret = -ENXIO;
808 goto out; 807 goto out;
809 } 808 }
810 809
811 dev_dbg(dev, "registers %p (%p, %p)\n", i2c->regs, i2c->ioarea, res); 810 dev_dbg(&pdev->dev, "registers %p (%p, %p)\n", i2c->regs, i2c->ioarea, res);
812 811
813 /* setup info block for the i2c core */ 812 /* setup info block for the i2c core */
814 813
815 i2c->adap.algo_data = i2c; 814 i2c->adap.algo_data = i2c;
816 i2c->adap.dev.parent = dev; 815 i2c->adap.dev.parent = &pdev->dev;
817 816
818 /* initialise the i2c controller */ 817 /* initialise the i2c controller */
819 818
@@ -827,7 +826,7 @@ static int s3c24xx_i2c_probe(struct device *dev)
827 826
828 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 827 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
829 if (res == NULL) { 828 if (res == NULL) {
830 dev_err(dev, "cannot find IRQ\n"); 829 dev_err(&pdev->dev, "cannot find IRQ\n");
831 ret = -ENOENT; 830 ret = -ENOENT;
832 goto out; 831 goto out;
833 } 832 }
@@ -836,23 +835,23 @@ static int s3c24xx_i2c_probe(struct device *dev)
836 pdev->name, i2c); 835 pdev->name, i2c);
837 836
838 if (ret != 0) { 837 if (ret != 0) {
839 dev_err(dev, "cannot claim IRQ\n"); 838 dev_err(&pdev->dev, "cannot claim IRQ\n");
840 goto out; 839 goto out;
841 } 840 }
842 841
843 i2c->irq = res; 842 i2c->irq = res;
844 843
845 dev_dbg(dev, "irq resource %p (%ld)\n", res, res->start); 844 dev_dbg(&pdev->dev, "irq resource %p (%ld)\n", res, res->start);
846 845
847 ret = i2c_add_adapter(&i2c->adap); 846 ret = i2c_add_adapter(&i2c->adap);
848 if (ret < 0) { 847 if (ret < 0) {
849 dev_err(dev, "failed to add bus to i2c core\n"); 848 dev_err(&pdev->dev, "failed to add bus to i2c core\n");
850 goto out; 849 goto out;
851 } 850 }
852 851
853 dev_set_drvdata(dev, i2c); 852 platform_set_drvdata(pdev, i2c);
854 853
855 dev_info(dev, "%s: S3C I2C adapter\n", i2c->adap.dev.bus_id); 854 dev_info(&pdev->dev, "%s: S3C I2C adapter\n", i2c->adap.dev.bus_id);
856 855
857 out: 856 out:
858 if (ret < 0) 857 if (ret < 0)
@@ -866,22 +865,22 @@ static int s3c24xx_i2c_probe(struct device *dev)
866 * called when device is removed from the bus 865 * called when device is removed from the bus
867*/ 866*/
868 867
869static int s3c24xx_i2c_remove(struct device *dev) 868static int s3c24xx_i2c_remove(struct platform_device *pdev)
870{ 869{
871 struct s3c24xx_i2c *i2c = dev_get_drvdata(dev); 870 struct s3c24xx_i2c *i2c = platform_get_drvdata(pdev);
872 871
873 if (i2c != NULL) { 872 if (i2c != NULL) {
874 s3c24xx_i2c_free(i2c); 873 s3c24xx_i2c_free(i2c);
875 dev_set_drvdata(dev, NULL); 874 platform_set_drvdata(pdev, NULL);
876 } 875 }
877 876
878 return 0; 877 return 0;
879} 878}
880 879
881#ifdef CONFIG_PM 880#ifdef CONFIG_PM
882static int s3c24xx_i2c_resume(struct device *dev) 881static int s3c24xx_i2c_resume(struct platform_device *dev)
883{ 882{
884 struct s3c24xx_i2c *i2c = dev_get_drvdata(dev); 883 struct s3c24xx_i2c *i2c = platform_get_drvdata(dev);
885 884
886 if (i2c != NULL) 885 if (i2c != NULL)
887 s3c24xx_i2c_init(i2c); 886 s3c24xx_i2c_init(i2c);
@@ -895,33 +894,35 @@ static int s3c24xx_i2c_resume(struct device *dev)
895 894
896/* device driver for platform bus bits */ 895/* device driver for platform bus bits */
897 896
898static struct device_driver s3c2410_i2c_driver = { 897static struct platform_driver s3c2410_i2c_driver = {
899 .owner = THIS_MODULE,
900 .name = "s3c2410-i2c",
901 .bus = &platform_bus_type,
902 .probe = s3c24xx_i2c_probe, 898 .probe = s3c24xx_i2c_probe,
903 .remove = s3c24xx_i2c_remove, 899 .remove = s3c24xx_i2c_remove,
904 .resume = s3c24xx_i2c_resume, 900 .resume = s3c24xx_i2c_resume,
901 .driver = {
902 .owner = THIS_MODULE,
903 .name = "s3c2410-i2c",
904 },
905}; 905};
906 906
907static struct device_driver s3c2440_i2c_driver = { 907static struct platform_driver s3c2440_i2c_driver = {
908 .owner = THIS_MODULE,
909 .name = "s3c2440-i2c",
910 .bus = &platform_bus_type,
911 .probe = s3c24xx_i2c_probe, 908 .probe = s3c24xx_i2c_probe,
912 .remove = s3c24xx_i2c_remove, 909 .remove = s3c24xx_i2c_remove,
913 .resume = s3c24xx_i2c_resume, 910 .resume = s3c24xx_i2c_resume,
911 .driver = {
912 .owner = THIS_MODULE,
913 .name = "s3c2440-i2c",
914 },
914}; 915};
915 916
916static int __init i2c_adap_s3c_init(void) 917static int __init i2c_adap_s3c_init(void)
917{ 918{
918 int ret; 919 int ret;
919 920
920 ret = driver_register(&s3c2410_i2c_driver); 921 ret = platform_driver_register(&s3c2410_i2c_driver);
921 if (ret == 0) { 922 if (ret == 0) {
922 ret = driver_register(&s3c2440_i2c_driver); 923 ret = platform_driver_register(&s3c2440_i2c_driver);
923 if (ret) 924 if (ret)
924 driver_unregister(&s3c2410_i2c_driver); 925 platform_driver_unregister(&s3c2410_i2c_driver);
925 } 926 }
926 927
927 return ret; 928 return ret;
@@ -929,8 +930,8 @@ static int __init i2c_adap_s3c_init(void)
929 930
930static void __exit i2c_adap_s3c_exit(void) 931static void __exit i2c_adap_s3c_exit(void)
931{ 932{
932 driver_unregister(&s3c2410_i2c_driver); 933 platform_driver_unregister(&s3c2410_i2c_driver);
933 driver_unregister(&s3c2440_i2c_driver); 934 platform_driver_unregister(&s3c2440_i2c_driver);
934} 935}
935 936
936module_init(i2c_adap_s3c_init); 937module_init(i2c_adap_s3c_init);