[media] s5p-fimc: convert to clk_prepare()/clk_unprepare()
authorSylwester Nawrocki <s.nawrocki@samsung.com>
Mon, 30 Jan 2012 14:39:30 +0000 (11:39 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Thu, 8 Mar 2012 10:37:27 +0000 (07:37 -0300)
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/s5p-fimc/fimc-core.c
drivers/media/video/s5p-fimc/mipi-csis.c

index 81bcbb9492ea0a6d425375a57f3600837082d773..a6b4580edd775bd2ea184a5d4e486e1d38c0c998 100644 (file)
@@ -1602,24 +1602,35 @@ static void fimc_clk_put(struct fimc_dev *fimc)
 {
        int i;
        for (i = 0; i < fimc->num_clocks; i++) {
-               if (fimc->clock[i])
-                       clk_put(fimc->clock[i]);
+               if (IS_ERR_OR_NULL(fimc->clock[i]))
+                       continue;
+               clk_unprepare(fimc->clock[i]);
+               clk_put(fimc->clock[i]);
+               fimc->clock[i] = NULL;
        }
 }
 
 static int fimc_clk_get(struct fimc_dev *fimc)
 {
-       int i;
+       int i, ret;
+
        for (i = 0; i < fimc->num_clocks; i++) {
                fimc->clock[i] = clk_get(&fimc->pdev->dev, fimc_clocks[i]);
-               if (!IS_ERR_OR_NULL(fimc->clock[i]))
-                       continue;
-               dev_err(&fimc->pdev->dev, "failed to get fimc clock: %s\n",
-                       fimc_clocks[i]);
-               return -ENXIO;
+               if (IS_ERR(fimc->clock[i]))
+                       goto err;
+               ret = clk_prepare(fimc->clock[i]);
+               if (ret < 0) {
+                       clk_put(fimc->clock[i]);
+                       fimc->clock[i] = NULL;
+                       goto err;
+               }
        }
-
        return 0;
+err:
+       fimc_clk_put(fimc);
+       dev_err(&fimc->pdev->dev, "failed to get clock: %s\n",
+               fimc_clocks[i]);
+       return -ENXIO;
 }
 
 static int fimc_m2m_suspend(struct fimc_dev *fimc)
index 130335cf62fdc391fbb7862348b76832f6cbdbb3..58c40750abc21a4fdea9ce16caa18dc7db7385f4 100644 (file)
@@ -258,26 +258,36 @@ static void s5pcsis_clk_put(struct csis_state *state)
 {
        int i;
 
-       for (i = 0; i < NUM_CSIS_CLOCKS; i++)
-               if (!IS_ERR_OR_NULL(state->clock[i]))
-                       clk_put(state->clock[i]);
+       for (i = 0; i < NUM_CSIS_CLOCKS; i++) {
+               if (IS_ERR_OR_NULL(state->clock[i]))
+                       continue;
+               clk_unprepare(state->clock[i]);
+               clk_put(state->clock[i]);
+               state->clock[i] = NULL;
+       }
 }
 
 static int s5pcsis_clk_get(struct csis_state *state)
 {
        struct device *dev = &state->pdev->dev;
-       int i;
+       int i, ret;
 
        for (i = 0; i < NUM_CSIS_CLOCKS; i++) {
                state->clock[i] = clk_get(dev, csi_clock_name[i]);
-               if (IS_ERR(state->clock[i])) {
-                       s5pcsis_clk_put(state);
-                       dev_err(dev, "failed to get clock: %s\n",
-                               csi_clock_name[i]);
-                       return -ENXIO;
+               if (IS_ERR(state->clock[i]))
+                       goto err;
+               ret = clk_prepare(state->clock[i]);
+               if (ret < 0) {
+                       clk_put(state->clock[i]);
+                       state->clock[i] = NULL;
+                       goto err;
                }
        }
        return 0;
+err:
+       s5pcsis_clk_put(state);
+       dev_err(dev, "failed to get clock: %s\n", csi_clock_name[i]);
+       return -ENXIO;
 }
 
 static int s5pcsis_s_power(struct v4l2_subdev *sd, int on)