diff options
Diffstat (limited to 'drivers/pinctrl/pinctrl-coh901.c')
-rw-r--r-- | drivers/pinctrl/pinctrl-coh901.c | 62 |
1 files changed, 19 insertions, 43 deletions
diff --git a/drivers/pinctrl/pinctrl-coh901.c b/drivers/pinctrl/pinctrl-coh901.c index 152efae3df8f..5c7daf9169e8 100644 --- a/drivers/pinctrl/pinctrl-coh901.c +++ b/drivers/pinctrl/pinctrl-coh901.c | |||
@@ -65,7 +65,6 @@ struct u300_gpio { | |||
65 | struct gpio_chip chip; | 65 | struct gpio_chip chip; |
66 | struct list_head port_list; | 66 | struct list_head port_list; |
67 | struct clk *clk; | 67 | struct clk *clk; |
68 | struct resource *memres; | ||
69 | void __iomem *base; | 68 | void __iomem *base; |
70 | struct device *dev; | 69 | struct device *dev; |
71 | u32 stride; | 70 | u32 stride; |
@@ -663,17 +662,16 @@ static int __init u300_gpio_probe(struct platform_device *pdev) | |||
663 | { | 662 | { |
664 | struct u300_gpio_platform *plat = dev_get_platdata(&pdev->dev); | 663 | struct u300_gpio_platform *plat = dev_get_platdata(&pdev->dev); |
665 | struct u300_gpio *gpio; | 664 | struct u300_gpio *gpio; |
665 | struct resource *memres; | ||
666 | int err = 0; | 666 | int err = 0; |
667 | int portno; | 667 | int portno; |
668 | u32 val; | 668 | u32 val; |
669 | u32 ifr; | 669 | u32 ifr; |
670 | int i; | 670 | int i; |
671 | 671 | ||
672 | gpio = kzalloc(sizeof(struct u300_gpio), GFP_KERNEL); | 672 | gpio = devm_kzalloc(&pdev->dev, sizeof(struct u300_gpio), GFP_KERNEL); |
673 | if (gpio == NULL) { | 673 | if (gpio == NULL) |
674 | dev_err(&pdev->dev, "failed to allocate memory\n"); | ||
675 | return -ENOMEM; | 674 | return -ENOMEM; |
676 | } | ||
677 | 675 | ||
678 | gpio->chip = u300_gpio_chip; | 676 | gpio->chip = u300_gpio_chip; |
679 | gpio->chip.ngpio = plat->ports * U300_GPIO_PINS_PER_PORT; | 677 | gpio->chip.ngpio = plat->ports * U300_GPIO_PINS_PER_PORT; |
@@ -681,37 +679,29 @@ static int __init u300_gpio_probe(struct platform_device *pdev) | |||
681 | gpio->chip.base = plat->gpio_base; | 679 | gpio->chip.base = plat->gpio_base; |
682 | gpio->dev = &pdev->dev; | 680 | gpio->dev = &pdev->dev; |
683 | 681 | ||
684 | /* Get GPIO clock */ | 682 | memres = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
685 | gpio->clk = clk_get(gpio->dev, NULL); | 683 | if (!memres) { |
684 | dev_err(gpio->dev, "could not get GPIO memory resource\n"); | ||
685 | return -ENODEV; | ||
686 | } | ||
687 | |||
688 | gpio->base = devm_request_and_ioremap(&pdev->dev, memres); | ||
689 | if (!gpio->base) { | ||
690 | dev_err(gpio->dev, "could not get remap memory\n"); | ||
691 | return -ENOMEM; | ||
692 | } | ||
693 | |||
694 | gpio->clk = devm_clk_get(gpio->dev, NULL); | ||
686 | if (IS_ERR(gpio->clk)) { | 695 | if (IS_ERR(gpio->clk)) { |
687 | err = PTR_ERR(gpio->clk); | 696 | err = PTR_ERR(gpio->clk); |
688 | dev_err(gpio->dev, "could not get GPIO clock\n"); | 697 | dev_err(gpio->dev, "could not get GPIO clock\n"); |
689 | goto err_no_clk; | 698 | return err; |
690 | } | 699 | } |
700 | |||
691 | err = clk_prepare_enable(gpio->clk); | 701 | err = clk_prepare_enable(gpio->clk); |
692 | if (err) { | 702 | if (err) { |
693 | dev_err(gpio->dev, "could not enable GPIO clock\n"); | 703 | dev_err(gpio->dev, "could not enable GPIO clock\n"); |
694 | goto err_no_clk_enable; | 704 | return err; |
695 | } | ||
696 | |||
697 | gpio->memres = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
698 | if (!gpio->memres) { | ||
699 | dev_err(gpio->dev, "could not get GPIO memory resource\n"); | ||
700 | err = -ENODEV; | ||
701 | goto err_no_resource; | ||
702 | } | ||
703 | |||
704 | if (!request_mem_region(gpio->memres->start, | ||
705 | resource_size(gpio->memres), | ||
706 | "GPIO Controller")) { | ||
707 | err = -ENODEV; | ||
708 | goto err_no_ioregion; | ||
709 | } | ||
710 | |||
711 | gpio->base = ioremap(gpio->memres->start, resource_size(gpio->memres)); | ||
712 | if (!gpio->base) { | ||
713 | err = -ENOMEM; | ||
714 | goto err_no_ioremap; | ||
715 | } | 705 | } |
716 | 706 | ||
717 | dev_info(gpio->dev, | 707 | dev_info(gpio->dev, |
@@ -810,16 +800,7 @@ err_no_chip: | |||
810 | err_no_domain: | 800 | err_no_domain: |
811 | err_no_port: | 801 | err_no_port: |
812 | u300_gpio_free_ports(gpio); | 802 | u300_gpio_free_ports(gpio); |
813 | iounmap(gpio->base); | ||
814 | err_no_ioremap: | ||
815 | release_mem_region(gpio->memres->start, resource_size(gpio->memres)); | ||
816 | err_no_ioregion: | ||
817 | err_no_resource: | ||
818 | clk_disable_unprepare(gpio->clk); | 803 | clk_disable_unprepare(gpio->clk); |
819 | err_no_clk_enable: | ||
820 | clk_put(gpio->clk); | ||
821 | err_no_clk: | ||
822 | kfree(gpio); | ||
823 | dev_info(&pdev->dev, "module ERROR:%d\n", err); | 804 | dev_info(&pdev->dev, "module ERROR:%d\n", err); |
824 | return err; | 805 | return err; |
825 | } | 806 | } |
@@ -838,13 +819,8 @@ static int __exit u300_gpio_remove(struct platform_device *pdev) | |||
838 | return err; | 819 | return err; |
839 | } | 820 | } |
840 | u300_gpio_free_ports(gpio); | 821 | u300_gpio_free_ports(gpio); |
841 | iounmap(gpio->base); | ||
842 | release_mem_region(gpio->memres->start, | ||
843 | resource_size(gpio->memres)); | ||
844 | clk_disable_unprepare(gpio->clk); | 822 | clk_disable_unprepare(gpio->clk); |
845 | clk_put(gpio->clk); | ||
846 | platform_set_drvdata(pdev, NULL); | 823 | platform_set_drvdata(pdev, NULL); |
847 | kfree(gpio); | ||
848 | return 0; | 824 | return 0; |
849 | } | 825 | } |
850 | 826 | ||