aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPramod Gurav <pramod.gurav@smartplayin.com>2014-09-09 06:20:36 -0400
committerLinus Walleij <linus.walleij@linaro.org>2014-09-23 10:45:22 -0400
commit70e4197420a154a2a684b6e7b496dda70b20d9ec (patch)
tree0319a6cf1d53a9ab4db83f679a61cf671e50dd14
parent849a8c25c80a2cde824072813bf4aabbc79b8789 (diff)
pinctrl: at91: Fix failure path in at91_gpio_probe path
This fixes the whole error handling in probe function by capturing and returning error values on kernel function like clk_prepare, clk_enable, gpiochip_add etc. CC: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com> CC: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Pramod Gurav <pramod.gurav@smartplayin.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r--drivers/pinctrl/pinctrl-at91.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
index 22b82ad4461c..71a8e8c4f19c 100644
--- a/drivers/pinctrl/pinctrl-at91.c
+++ b/drivers/pinctrl/pinctrl-at91.c
@@ -1738,16 +1738,19 @@ static int at91_gpio_probe(struct platform_device *pdev)
1738 at91_chip->clock = devm_clk_get(&pdev->dev, NULL); 1738 at91_chip->clock = devm_clk_get(&pdev->dev, NULL);
1739 if (IS_ERR(at91_chip->clock)) { 1739 if (IS_ERR(at91_chip->clock)) {
1740 dev_err(&pdev->dev, "failed to get clock, ignoring.\n"); 1740 dev_err(&pdev->dev, "failed to get clock, ignoring.\n");
1741 ret = PTR_ERR(at91_chip->clock);
1741 goto err; 1742 goto err;
1742 } 1743 }
1743 1744
1744 if (clk_prepare(at91_chip->clock)) 1745 ret = clk_prepare(at91_chip->clock);
1745 goto err; 1746 if (ret)
1747 goto clk_prepare_err;
1746 1748
1747 /* enable PIO controller's clock */ 1749 /* enable PIO controller's clock */
1748 if (clk_enable(at91_chip->clock)) { 1750 ret = clk_enable(at91_chip->clock);
1751 if (ret) {
1749 dev_err(&pdev->dev, "failed to enable clock, ignoring.\n"); 1752 dev_err(&pdev->dev, "failed to enable clock, ignoring.\n");
1750 goto clk_err; 1753 goto clk_enable_err;
1751 } 1754 }
1752 1755
1753 at91_chip->chip = at91_gpio_template; 1756 at91_chip->chip = at91_gpio_template;
@@ -1772,7 +1775,7 @@ static int at91_gpio_probe(struct platform_device *pdev)
1772 1775
1773 if (!names) { 1776 if (!names) {
1774 ret = -ENOMEM; 1777 ret = -ENOMEM;
1775 goto clk_err; 1778 goto clk_enable_err;
1776 } 1779 }
1777 1780
1778 for (i = 0; i < chip->ngpio; i++) 1781 for (i = 0; i < chip->ngpio; i++)
@@ -1790,7 +1793,7 @@ static int at91_gpio_probe(struct platform_device *pdev)
1790 1793
1791 ret = gpiochip_add(chip); 1794 ret = gpiochip_add(chip);
1792 if (ret) 1795 if (ret)
1793 goto clk_err; 1796 goto gpiochip_add_err;
1794 1797
1795 gpio_chips[alias_idx] = at91_chip; 1798 gpio_chips[alias_idx] = at91_chip;
1796 gpio_banks = max(gpio_banks, alias_idx + 1); 1799 gpio_banks = max(gpio_banks, alias_idx + 1);
@@ -1803,8 +1806,11 @@ static int at91_gpio_probe(struct platform_device *pdev)
1803 1806
1804 return 0; 1807 return 0;
1805 1808
1806clk_err: 1809gpiochip_add_err:
1810 clk_disable(at91_chip->clock);
1811clk_enable_err:
1807 clk_unprepare(at91_chip->clock); 1812 clk_unprepare(at91_chip->clock);
1813clk_prepare_err:
1808err: 1814err:
1809 dev_err(&pdev->dev, "Failure %i for GPIO %i\n", ret, alias_idx); 1815 dev_err(&pdev->dev, "Failure %i for GPIO %i\n", ret, alias_idx);
1810 1816