[media] s5p-mfc: Added support for clk_prepare
authorKamil Debski <k.debski@samsung.com>
Thu, 16 Feb 2012 13:51:56 +0000 (10:51 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Thu, 8 Mar 2012 10:42:52 +0000 (07:42 -0300)
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/s5p-mfc/s5p_mfc_pm.c

index f6a3035c4fb76df06eb584c61197c925c930e5a2..738a607be43c9b05b7a7040195fb4bea625a5cab 100644 (file)
@@ -41,15 +41,29 @@ int s5p_mfc_init_pm(struct s5p_mfc_dev *dev)
        pm->clock_gate = clk_get(&dev->plat_dev->dev, MFC_GATE_CLK_NAME);
        if (IS_ERR(pm->clock_gate)) {
                mfc_err("Failed to get clock-gating control\n");
-               ret = -ENOENT;
+               ret = PTR_ERR(pm->clock_gate);
                goto err_g_ip_clk;
        }
+
+       ret = clk_prepare(pm->clock_gate);
+       if (ret) {
+               mfc_err("Failed to preapre clock-gating control\n");
+               goto err_p_ip_clk;
+       }
+
        pm->clock = clk_get(&dev->plat_dev->dev, MFC_CLKNAME);
        if (IS_ERR(pm->clock)) {
                mfc_err("Failed to get MFC clock\n");
-               ret = -ENOENT;
+               ret = PTR_ERR(pm->clock);
                goto err_g_ip_clk_2;
        }
+
+       ret = clk_prepare(pm->clock);
+       if (ret) {
+               mfc_err("Failed to prepare MFC clock\n");
+               goto err_p_ip_clk_2;
+       }
+
        atomic_set(&pm->power, 0);
 #ifdef CONFIG_PM_RUNTIME
        pm->device = &dev->plat_dev->dev;
@@ -59,7 +73,11 @@ int s5p_mfc_init_pm(struct s5p_mfc_dev *dev)
        atomic_set(&clk_ref, 0);
 #endif
        return 0;
+err_p_ip_clk_2:
+       clk_put(pm->clock);
 err_g_ip_clk_2:
+       clk_unprepare(pm->clock_gate);
+err_p_ip_clk:
        clk_put(pm->clock_gate);
 err_g_ip_clk:
        return ret;
@@ -67,7 +85,9 @@ err_g_ip_clk:
 
 void s5p_mfc_final_pm(struct s5p_mfc_dev *dev)
 {
+       clk_unprepare(pm->clock_gate);
        clk_put(pm->clock_gate);
+       clk_unprepare(pm->clock);
        clk_put(pm->clock);
 #ifdef CONFIG_PM_RUNTIME
        pm_runtime_disable(pm->device);