diff options
author | Roland Stigge <stigge@antcom.de> | 2012-04-22 05:59:47 -0400 |
---|---|---|
committer | Roland Stigge <stigge@antcom.de> | 2012-04-22 05:59:47 -0400 |
commit | 1451ba3a5fa52d874e03a3380d053f3e6a5fcae4 (patch) | |
tree | e40a2b10951eabace15836d658eea8848d47564c /drivers/i2c | |
parent | c4cea7fc1bfd8a36d08f8114efcb11d649d97d5a (diff) |
i2c-pnx.c: Use resources in platforms
As a precondition for device tree conversion, the platforms using i2c-pnx.c are
converted to using mem and irq resources instead of platform data.
Signed-off-by: Roland Stigge <stigge@antcom.de>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | drivers/i2c/busses/i2c-pnx.c | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/drivers/i2c/busses/i2c-pnx.c b/drivers/i2c/busses/i2c-pnx.c index eb8ad538c79f..6fb97aef0465 100644 --- a/drivers/i2c/busses/i2c-pnx.c +++ b/drivers/i2c/busses/i2c-pnx.c | |||
@@ -568,14 +568,7 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev) | |||
568 | int ret = 0; | 568 | int ret = 0; |
569 | struct i2c_pnx_algo_data *alg_data; | 569 | struct i2c_pnx_algo_data *alg_data; |
570 | unsigned long freq; | 570 | unsigned long freq; |
571 | struct i2c_pnx_data *i2c_pnx = pdev->dev.platform_data; | 571 | struct resource *res; |
572 | |||
573 | if (!i2c_pnx || !i2c_pnx->name) { | ||
574 | dev_err(&pdev->dev, "%s: no platform data supplied\n", | ||
575 | __func__); | ||
576 | ret = -EINVAL; | ||
577 | goto out; | ||
578 | } | ||
579 | 572 | ||
580 | alg_data = kzalloc(sizeof(*alg_data), GFP_KERNEL); | 573 | alg_data = kzalloc(sizeof(*alg_data), GFP_KERNEL); |
581 | if (!alg_data) { | 574 | if (!alg_data) { |
@@ -585,13 +578,10 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev) | |||
585 | 578 | ||
586 | platform_set_drvdata(pdev, alg_data); | 579 | platform_set_drvdata(pdev, alg_data); |
587 | 580 | ||
588 | strlcpy(alg_data->adapter.name, i2c_pnx->name, | ||
589 | sizeof(alg_data->adapter.name)); | ||
590 | alg_data->adapter.dev.parent = &pdev->dev; | 581 | alg_data->adapter.dev.parent = &pdev->dev; |
591 | alg_data->adapter.algo = &pnx_algorithm; | 582 | alg_data->adapter.algo = &pnx_algorithm; |
592 | alg_data->adapter.algo_data = alg_data; | 583 | alg_data->adapter.algo_data = alg_data; |
593 | alg_data->adapter.nr = pdev->id; | 584 | alg_data->adapter.nr = pdev->id; |
594 | alg_data->i2c_pnx = i2c_pnx; | ||
595 | 585 | ||
596 | alg_data->clk = clk_get(&pdev->dev, NULL); | 586 | alg_data->clk = clk_get(&pdev->dev, NULL); |
597 | if (IS_ERR(alg_data->clk)) { | 587 | if (IS_ERR(alg_data->clk)) { |
@@ -603,17 +593,27 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev) | |||
603 | alg_data->mif.timer.function = i2c_pnx_timeout; | 593 | alg_data->mif.timer.function = i2c_pnx_timeout; |
604 | alg_data->mif.timer.data = (unsigned long)alg_data; | 594 | alg_data->mif.timer.data = (unsigned long)alg_data; |
605 | 595 | ||
596 | snprintf(alg_data->adapter.name, sizeof(alg_data->adapter.name), | ||
597 | "%s", pdev->name); | ||
598 | |||
606 | /* Register I/O resource */ | 599 | /* Register I/O resource */ |
607 | if (!request_mem_region(i2c_pnx->base, I2C_PNX_REGION_SIZE, | 600 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
601 | if (!res) { | ||
602 | dev_err(&pdev->dev, "Unable to get mem resource.\n"); | ||
603 | ret = -EBUSY; | ||
604 | goto out_clkget; | ||
605 | } | ||
606 | if (!request_mem_region(res->start, I2C_PNX_REGION_SIZE, | ||
608 | pdev->name)) { | 607 | pdev->name)) { |
609 | dev_err(&pdev->dev, | 608 | dev_err(&pdev->dev, |
610 | "I/O region 0x%08x for I2C already in use.\n", | 609 | "I/O region 0x%08x for I2C already in use.\n", |
611 | i2c_pnx->base); | 610 | res->start); |
612 | ret = -ENODEV; | 611 | ret = -ENODEV; |
613 | goto out_clkget; | 612 | goto out_clkget; |
614 | } | 613 | } |
615 | 614 | ||
616 | alg_data->ioaddr = ioremap(i2c_pnx->base, I2C_PNX_REGION_SIZE); | 615 | alg_data->base = res->start; |
616 | alg_data->ioaddr = ioremap(res->start, I2C_PNX_REGION_SIZE); | ||
617 | if (!alg_data->ioaddr) { | 617 | if (!alg_data->ioaddr) { |
618 | dev_err(&pdev->dev, "Couldn't ioremap I2C I/O region\n"); | 618 | dev_err(&pdev->dev, "Couldn't ioremap I2C I/O region\n"); |
619 | ret = -ENOMEM; | 619 | ret = -ENOMEM; |
@@ -650,7 +650,12 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev) | |||
650 | } | 650 | } |
651 | init_completion(&alg_data->mif.complete); | 651 | init_completion(&alg_data->mif.complete); |
652 | 652 | ||
653 | ret = request_irq(i2c_pnx->irq, i2c_pnx_interrupt, | 653 | alg_data->irq = platform_get_irq(pdev, 0); |
654 | if (alg_data->irq < 0) { | ||
655 | dev_err(&pdev->dev, "Failed to get IRQ from platform resource\n"); | ||
656 | goto out_irq; | ||
657 | } | ||
658 | ret = request_irq(alg_data->irq, i2c_pnx_interrupt, | ||
654 | 0, pdev->name, alg_data); | 659 | 0, pdev->name, alg_data); |
655 | if (ret) | 660 | if (ret) |
656 | goto out_clock; | 661 | goto out_clock; |
@@ -663,38 +668,36 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev) | |||
663 | } | 668 | } |
664 | 669 | ||
665 | dev_dbg(&pdev->dev, "%s: Master at %#8x, irq %d.\n", | 670 | dev_dbg(&pdev->dev, "%s: Master at %#8x, irq %d.\n", |
666 | alg_data->adapter.name, i2c_pnx->base, i2c_pnx->irq); | 671 | alg_data->adapter.name, res->start, alg_data->irq); |
667 | 672 | ||
668 | return 0; | 673 | return 0; |
669 | 674 | ||
670 | out_irq: | 675 | out_irq: |
671 | free_irq(i2c_pnx->irq, alg_data); | 676 | free_irq(alg_data->irq, alg_data); |
672 | out_clock: | 677 | out_clock: |
673 | clk_disable(alg_data->clk); | 678 | clk_disable(alg_data->clk); |
674 | out_unmap: | 679 | out_unmap: |
675 | iounmap(alg_data->ioaddr); | 680 | iounmap(alg_data->ioaddr); |
676 | out_release: | 681 | out_release: |
677 | release_mem_region(i2c_pnx->base, I2C_PNX_REGION_SIZE); | 682 | release_mem_region(res->start, I2C_PNX_REGION_SIZE); |
678 | out_clkget: | 683 | out_clkget: |
679 | clk_put(alg_data->clk); | 684 | clk_put(alg_data->clk); |
680 | out_drvdata: | 685 | out_drvdata: |
681 | kfree(alg_data); | 686 | kfree(alg_data); |
682 | err_kzalloc: | 687 | err_kzalloc: |
683 | platform_set_drvdata(pdev, NULL); | 688 | platform_set_drvdata(pdev, NULL); |
684 | out: | ||
685 | return ret; | 689 | return ret; |
686 | } | 690 | } |
687 | 691 | ||
688 | static int __devexit i2c_pnx_remove(struct platform_device *pdev) | 692 | static int __devexit i2c_pnx_remove(struct platform_device *pdev) |
689 | { | 693 | { |
690 | struct i2c_pnx_algo_data *alg_data = platform_get_drvdata(pdev); | 694 | struct i2c_pnx_algo_data *alg_data = platform_get_drvdata(pdev); |
691 | struct i2c_pnx_data *i2c_pnx = alg_data->i2c_pnx; | ||
692 | 695 | ||
693 | free_irq(i2c_pnx->irq, alg_data); | 696 | free_irq(alg_data->irq, alg_data); |
694 | i2c_del_adapter(&alg_data->adapter); | 697 | i2c_del_adapter(&alg_data->adapter); |
695 | clk_disable(alg_data->clk); | 698 | clk_disable(alg_data->clk); |
696 | iounmap(alg_data->ioaddr); | 699 | iounmap(alg_data->ioaddr); |
697 | release_mem_region(i2c_pnx->base, I2C_PNX_REGION_SIZE); | 700 | release_mem_region(alg_data->base, I2C_PNX_REGION_SIZE); |
698 | clk_put(alg_data->clk); | 701 | clk_put(alg_data->clk); |
699 | kfree(alg_data); | 702 | kfree(alg_data); |
700 | platform_set_drvdata(pdev, NULL); | 703 | platform_set_drvdata(pdev, NULL); |