diff options
author | Wolfram Sang <wsa+renesas@sang-engineering.com> | 2014-05-02 15:15:11 -0400 |
---|---|---|
committer | Wolfram Sang <wsa@the-dreams.de> | 2014-05-22 04:09:23 -0400 |
commit | 4fd31c2eb7bf19927524bca1c5c17e6bb0f4f6eb (patch) | |
tree | ce60977168cd69aebc2c9c2e69c60e82df96aa19 | |
parent | 5aacb66656121ba8c917a905e0eef192c0b22212 (diff) |
i2c: sh_mobile: devm conversion, low hanging fruits
Convert the easy parts to devm. irqs will be converted in a seperate
patch to keep diffs readable.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
-rw-r--r-- | drivers/i2c/busses/i2c-sh_mobile.c | 41 |
1 files changed, 10 insertions, 31 deletions
diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c index 2e481abd50ce..c47d11493b97 100644 --- a/drivers/i2c/busses/i2c-sh_mobile.c +++ b/drivers/i2c/busses/i2c-sh_mobile.c | |||
@@ -655,45 +655,33 @@ static int sh_mobile_i2c_probe(struct platform_device *dev) | |||
655 | struct sh_mobile_i2c_data *pd; | 655 | struct sh_mobile_i2c_data *pd; |
656 | struct i2c_adapter *adap; | 656 | struct i2c_adapter *adap; |
657 | struct resource *res; | 657 | struct resource *res; |
658 | int size; | ||
659 | int ret; | 658 | int ret; |
660 | u32 bus_speed; | 659 | u32 bus_speed; |
661 | 660 | ||
662 | pd = kzalloc(sizeof(struct sh_mobile_i2c_data), GFP_KERNEL); | 661 | pd = devm_kzalloc(&dev->dev, sizeof(struct sh_mobile_i2c_data), GFP_KERNEL); |
663 | if (pd == NULL) { | 662 | if (!pd) |
664 | dev_err(&dev->dev, "cannot allocate private data\n"); | ||
665 | return -ENOMEM; | 663 | return -ENOMEM; |
666 | } | ||
667 | 664 | ||
668 | pd->clk = clk_get(&dev->dev, NULL); | 665 | pd->clk = devm_clk_get(&dev->dev, NULL); |
669 | if (IS_ERR(pd->clk)) { | 666 | if (IS_ERR(pd->clk)) { |
670 | dev_err(&dev->dev, "cannot get clock\n"); | 667 | dev_err(&dev->dev, "cannot get clock\n"); |
671 | ret = PTR_ERR(pd->clk); | 668 | return PTR_ERR(pd->clk); |
672 | goto err; | ||
673 | } | 669 | } |
674 | 670 | ||
675 | ret = sh_mobile_i2c_hook_irqs(dev, 1); | 671 | ret = sh_mobile_i2c_hook_irqs(dev, 1); |
676 | if (ret) { | 672 | if (ret) { |
677 | dev_err(&dev->dev, "cannot request IRQ\n"); | 673 | dev_err(&dev->dev, "cannot request IRQ\n"); |
678 | goto err_clk; | 674 | return ret; |
679 | } | 675 | } |
680 | 676 | ||
681 | pd->dev = &dev->dev; | 677 | pd->dev = &dev->dev; |
682 | platform_set_drvdata(dev, pd); | 678 | platform_set_drvdata(dev, pd); |
683 | 679 | ||
684 | res = platform_get_resource(dev, IORESOURCE_MEM, 0); | 680 | res = platform_get_resource(dev, IORESOURCE_MEM, 0); |
685 | if (res == NULL) { | ||
686 | dev_err(&dev->dev, "cannot find IO resource\n"); | ||
687 | ret = -ENOENT; | ||
688 | goto err_irq; | ||
689 | } | ||
690 | 681 | ||
691 | size = resource_size(res); | 682 | pd->reg = devm_ioremap_resource(&dev->dev, res); |
692 | 683 | if (IS_ERR(pd->reg)) { | |
693 | pd->reg = ioremap(res->start, size); | 684 | ret = PTR_ERR(pd->reg); |
694 | if (pd->reg == NULL) { | ||
695 | dev_err(&dev->dev, "cannot map IO\n"); | ||
696 | ret = -ENXIO; | ||
697 | goto err_irq; | 685 | goto err_irq; |
698 | } | 686 | } |
699 | 687 | ||
@@ -710,7 +698,7 @@ static int sh_mobile_i2c_probe(struct platform_device *dev) | |||
710 | /* The IIC blocks on SH-Mobile ARM processors | 698 | /* The IIC blocks on SH-Mobile ARM processors |
711 | * come with two new bits in ICIC. | 699 | * come with two new bits in ICIC. |
712 | */ | 700 | */ |
713 | if (size > 0x17) | 701 | if (resource_size(res) > 0x17) |
714 | pd->flags |= IIC_FLAG_HAS_ICIC67; | 702 | pd->flags |= IIC_FLAG_HAS_ICIC67; |
715 | 703 | ||
716 | sh_mobile_i2c_init(pd); | 704 | sh_mobile_i2c_init(pd); |
@@ -747,7 +735,7 @@ static int sh_mobile_i2c_probe(struct platform_device *dev) | |||
747 | ret = i2c_add_numbered_adapter(adap); | 735 | ret = i2c_add_numbered_adapter(adap); |
748 | if (ret < 0) { | 736 | if (ret < 0) { |
749 | dev_err(&dev->dev, "cannot add numbered adapter\n"); | 737 | dev_err(&dev->dev, "cannot add numbered adapter\n"); |
750 | goto err_all; | 738 | goto err_irq; |
751 | } | 739 | } |
752 | 740 | ||
753 | dev_info(&dev->dev, | 741 | dev_info(&dev->dev, |
@@ -756,14 +744,8 @@ static int sh_mobile_i2c_probe(struct platform_device *dev) | |||
756 | 744 | ||
757 | return 0; | 745 | return 0; |
758 | 746 | ||
759 | err_all: | ||
760 | iounmap(pd->reg); | ||
761 | err_irq: | 747 | err_irq: |
762 | sh_mobile_i2c_hook_irqs(dev, 0); | 748 | sh_mobile_i2c_hook_irqs(dev, 0); |
763 | err_clk: | ||
764 | clk_put(pd->clk); | ||
765 | err: | ||
766 | kfree(pd); | ||
767 | return ret; | 749 | return ret; |
768 | } | 750 | } |
769 | 751 | ||
@@ -772,11 +754,8 @@ static int sh_mobile_i2c_remove(struct platform_device *dev) | |||
772 | struct sh_mobile_i2c_data *pd = platform_get_drvdata(dev); | 754 | struct sh_mobile_i2c_data *pd = platform_get_drvdata(dev); |
773 | 755 | ||
774 | i2c_del_adapter(&pd->adap); | 756 | i2c_del_adapter(&pd->adap); |
775 | iounmap(pd->reg); | ||
776 | sh_mobile_i2c_hook_irqs(dev, 0); | 757 | sh_mobile_i2c_hook_irqs(dev, 0); |
777 | clk_put(pd->clk); | ||
778 | pm_runtime_disable(&dev->dev); | 758 | pm_runtime_disable(&dev->dev); |
779 | kfree(pd); | ||
780 | return 0; | 759 | return 0; |
781 | } | 760 | } |
782 | 761 | ||