aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2009-11-21 07:25:27 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2010-02-12 12:32:41 -0500
commit9d7f73632c87ef1b6187eb539d1efd63c3cf0e36 (patch)
treed4eda1040089f76fa092dc96432d708064a84ad5 /drivers/i2c
parent44c5d739181886cff8e3903dfa38cd704f3d9640 (diff)
ARM: PNX4008: move i2c_adapter structure inside the drivers private data
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/busses/i2c-pnx.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/drivers/i2c/busses/i2c-pnx.c b/drivers/i2c/busses/i2c-pnx.c
index 1d66856a22fd..6b413c5300d3 100644
--- a/drivers/i2c/busses/i2c-pnx.c
+++ b/drivers/i2c/busses/i2c-pnx.c
@@ -551,8 +551,7 @@ static struct i2c_algorithm pnx_algorithm = {
551static int i2c_pnx_controller_suspend(struct platform_device *pdev, 551static int i2c_pnx_controller_suspend(struct platform_device *pdev,
552 pm_message_t state) 552 pm_message_t state)
553{ 553{
554 struct i2c_pnx_data *i2c_pnx = platform_get_drvdata(pdev); 554 struct i2c_pnx_algo_data *alg_data = platform_get_drvdata(pdev);
555 struct i2c_pnx_algo_data *alg_data = i2c_pnx->adapter->algo_data;
556 555
557 /* FIXME: shouldn't this be clk_disable? */ 556 /* FIXME: shouldn't this be clk_disable? */
558 clk_enable(alg_data->clk); 557 clk_enable(alg_data->clk);
@@ -562,8 +561,7 @@ static int i2c_pnx_controller_suspend(struct platform_device *pdev,
562 561
563static int i2c_pnx_controller_resume(struct platform_device *pdev) 562static int i2c_pnx_controller_resume(struct platform_device *pdev)
564{ 563{
565 struct i2c_pnx_data *i2c_pnx = platform_get_drvdata(pdev); 564 struct i2c_pnx_algo_data *alg_data = platform_get_drvdata(pdev);
566 struct i2c_pnx_algo_data *alg_data = i2c_pnx->adapter->algo_data;
567 565
568 return clk_enable(alg_data->clk); 566 return clk_enable(alg_data->clk);
569} 567}
@@ -580,7 +578,7 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev)
580 unsigned long freq; 578 unsigned long freq;
581 struct i2c_pnx_data *i2c_pnx = pdev->dev.platform_data; 579 struct i2c_pnx_data *i2c_pnx = pdev->dev.platform_data;
582 580
583 if (!i2c_pnx || !i2c_pnx->adapter) { 581 if (!i2c_pnx || !i2c_pnx->name) {
584 dev_err(&pdev->dev, "%s: no platform data supplied\n", 582 dev_err(&pdev->dev, "%s: no platform data supplied\n",
585 __func__); 583 __func__);
586 ret = -EINVAL; 584 ret = -EINVAL;
@@ -593,10 +591,15 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev)
593 goto err_kzalloc; 591 goto err_kzalloc;
594 } 592 }
595 593
596 platform_set_drvdata(pdev, i2c_pnx); 594 platform_set_drvdata(pdev, alg_data);
597 595
598 i2c_pnx->adapter->algo = &pnx_algorithm; 596 strlcpy(alg_data->adapter.name, i2c_pnx->name,
599 i2c_pnx->adapter->algo_data = alg_data; 597 sizeof(alg_data->adapter.name));
598 alg_data->adapter.dev.parent = &pdev->dev;
599 alg_data->adapter.algo = &pnx_algorithm;
600 alg_data->adapter.algo_data = alg_data;
601 alg_data->adapter.nr = pdev->id;
602 alg_data->i2c_pnx = i2c_pnx;
600 603
601 alg_data->clk = clk_get(&pdev->dev, NULL); 604 alg_data->clk = clk_get(&pdev->dev, NULL);
602 if (IS_ERR(alg_data->clk)) { 605 if (IS_ERR(alg_data->clk)) {
@@ -606,7 +609,7 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev)
606 609
607 init_timer(&alg_data->mif.timer); 610 init_timer(&alg_data->mif.timer);
608 alg_data->mif.timer.function = i2c_pnx_timeout; 611 alg_data->mif.timer.function = i2c_pnx_timeout;
609 alg_data->mif.timer.data = (unsigned long)i2c_pnx->adapter; 612 alg_data->mif.timer.data = (unsigned long)&alg_data->adapter;
610 613
611 /* Register I/O resource */ 614 /* Register I/O resource */
612 if (!request_mem_region(i2c_pnx->base, I2C_PNX_REGION_SIZE, 615 if (!request_mem_region(i2c_pnx->base, I2C_PNX_REGION_SIZE,
@@ -654,26 +657,24 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev)
654 init_completion(&alg_data->mif.complete); 657 init_completion(&alg_data->mif.complete);
655 658
656 ret = request_irq(i2c_pnx->irq, i2c_pnx_interrupt, 659 ret = request_irq(i2c_pnx->irq, i2c_pnx_interrupt,
657 0, pdev->name, i2c_pnx->adapter); 660 0, pdev->name, &alg_data->adapter);
658 if (ret) 661 if (ret)
659 goto out_clock; 662 goto out_clock;
660 663
661 /* Register this adapter with the I2C subsystem */ 664 /* Register this adapter with the I2C subsystem */
662 i2c_pnx->adapter->dev.parent = &pdev->dev; 665 ret = i2c_add_numbered_adapter(&alg_data->adapter);
663 i2c_pnx->adapter->nr = pdev->id;
664 ret = i2c_add_numbered_adapter(i2c_pnx->adapter);
665 if (ret < 0) { 666 if (ret < 0) {
666 dev_err(&pdev->dev, "I2C: Failed to add bus\n"); 667 dev_err(&pdev->dev, "I2C: Failed to add bus\n");
667 goto out_irq; 668 goto out_irq;
668 } 669 }
669 670
670 dev_dbg(&pdev->dev, "%s: Master at %#8x, irq %d.\n", 671 dev_dbg(&pdev->dev, "%s: Master at %#8x, irq %d.\n",
671 i2c_pnx->adapter->name, i2c_pnx->base, i2c_pnx->irq); 672 alg_data->adapter.name, i2c_pnx->base, i2c_pnx->irq);
672 673
673 return 0; 674 return 0;
674 675
675out_irq: 676out_irq:
676 free_irq(i2c_pnx->irq, i2c_pnx->adapter); 677 free_irq(i2c_pnx->irq, &alg_data->adapter);
677out_clock: 678out_clock:
678 clk_disable(alg_data->clk); 679 clk_disable(alg_data->clk);
679out_unmap: 680out_unmap:
@@ -692,12 +693,11 @@ out:
692 693
693static int __devexit i2c_pnx_remove(struct platform_device *pdev) 694static int __devexit i2c_pnx_remove(struct platform_device *pdev)
694{ 695{
695 struct i2c_pnx_data *i2c_pnx = platform_get_drvdata(pdev); 696 struct i2c_pnx_algo_data *alg_data = platform_get_drvdata(pdev);
696 struct i2c_adapter *adap = i2c_pnx->adapter; 697 struct i2c_pnx_data *i2c_pnx = alg_data->i2c_pnx;
697 struct i2c_pnx_algo_data *alg_data = adap->algo_data;
698 698
699 free_irq(i2c_pnx->irq, i2c_pnx->adapter); 699 free_irq(i2c_pnx->irq, &alg_data->adapter);
700 i2c_del_adapter(adap); 700 i2c_del_adapter(&alg_data->adapter);
701 clk_disable(alg_data->clk); 701 clk_disable(alg_data->clk);
702 iounmap(alg_data->ioaddr); 702 iounmap(alg_data->ioaddr);
703 release_mem_region(i2c_pnx->base, I2C_PNX_REGION_SIZE); 703 release_mem_region(i2c_pnx->base, I2C_PNX_REGION_SIZE);