aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm
diff options
context:
space:
mode:
authorAaro Koskinen <Aaro.Koskinen@nokia.com>2010-12-20 21:48:15 -0500
committerTony Lindgren <tony@atomide.com>2010-12-20 21:48:15 -0500
commit434c23a7ef48763fd8d4adfb0edebb4237770f9d (patch)
tree31d5f523fa726c87e07ce1a061848ff275f98c87 /arch/arm
parentf7bb0d9ab29e3159e22c3bfc843bd37c7d3c91a0 (diff)
arm: mach-omap2: hsmmc_reset: fix clk_get() error handling
clk_get() return value should be checked with IS_ERR(). Furthermore, clocks should be put and disabled properly. Signed-off-by: Aaro Koskinen <aaro.koskinen@nokia.com> Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch/arm')
-rw-r--r--arch/arm/mach-omap2/devices.c44
1 files changed, 24 insertions, 20 deletions
diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index 5a0c148e23bc..1bca147ac91d 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -638,6 +638,7 @@ static struct platform_device dummy_pdev = {
638static void __init omap_hsmmc_reset(void) 638static void __init omap_hsmmc_reset(void)
639{ 639{
640 u32 i, nr_controllers; 640 u32 i, nr_controllers;
641 struct clk *iclk, *fclk;
641 642
642 if (cpu_is_omap242x()) 643 if (cpu_is_omap242x())
643 return; 644 return;
@@ -647,7 +648,6 @@ static void __init omap_hsmmc_reset(void)
647 648
648 for (i = 0; i < nr_controllers; i++) { 649 for (i = 0; i < nr_controllers; i++) {
649 u32 v, base = 0; 650 u32 v, base = 0;
650 struct clk *iclk, *fclk;
651 struct device *dev = &dummy_pdev.dev; 651 struct device *dev = &dummy_pdev.dev;
652 652
653 switch (i) { 653 switch (i) {
@@ -678,19 +678,16 @@ static void __init omap_hsmmc_reset(void)
678 dummy_pdev.id = i; 678 dummy_pdev.id = i;
679 dev_set_name(&dummy_pdev.dev, "mmci-omap-hs.%d", i); 679 dev_set_name(&dummy_pdev.dev, "mmci-omap-hs.%d", i);
680 iclk = clk_get(dev, "ick"); 680 iclk = clk_get(dev, "ick");
681 if (iclk && clk_enable(iclk)) 681 if (IS_ERR(iclk))
682 iclk = NULL; 682 goto err1;
683 if (clk_enable(iclk))
684 goto err2;
683 685
684 fclk = clk_get(dev, "fck"); 686 fclk = clk_get(dev, "fck");
685 if (fclk && clk_enable(fclk)) 687 if (IS_ERR(fclk))
686 fclk = NULL; 688 goto err3;
687 689 if (clk_enable(fclk))
688 if (!iclk || !fclk) { 690 goto err4;
689 printk(KERN_WARNING
690 "%s: Unable to enable clocks for MMC%d, "
691 "cannot reset.\n", __func__, i);
692 break;
693 }
694 691
695 omap_writel(MMCHS_SYSCONFIG_SWRESET, base + MMCHS_SYSCONFIG); 692 omap_writel(MMCHS_SYSCONFIG_SWRESET, base + MMCHS_SYSCONFIG);
696 v = omap_readl(base + MMCHS_SYSSTATUS); 693 v = omap_readl(base + MMCHS_SYSSTATUS);
@@ -698,15 +695,22 @@ static void __init omap_hsmmc_reset(void)
698 MMCHS_SYSSTATUS_RESETDONE)) 695 MMCHS_SYSSTATUS_RESETDONE))
699 cpu_relax(); 696 cpu_relax();
700 697
701 if (fclk) { 698 clk_disable(fclk);
702 clk_disable(fclk); 699 clk_put(fclk);
703 clk_put(fclk); 700 clk_disable(iclk);
704 } 701 clk_put(iclk);
705 if (iclk) {
706 clk_disable(iclk);
707 clk_put(iclk);
708 }
709 } 702 }
703 return;
704
705err4:
706 clk_put(fclk);
707err3:
708 clk_disable(iclk);
709err2:
710 clk_put(iclk);
711err1:
712 printk(KERN_WARNING "%s: Unable to enable clocks for MMC%d, "
713 "cannot reset.\n", __func__, i);
710} 714}
711#else 715#else
712static inline void omap_hsmmc_reset(void) {} 716static inline void omap_hsmmc_reset(void) {}