drm/exynos/hdmi: improve clock routines
authorAndrzej Hajda <a.hajda@samsung.com>
Mon, 24 Oct 2016 11:53:22 +0000 (13:53 +0200)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Wed, 14 Dec 2016 04:54:10 +0000 (13:54 +0900)
The patch:
- adds unwind code to hdmi_clk_enable_gates,
- simplifies code,
- moves routines up, to match mainline.

Change-Id: I79055471688400b6f449c87d210ae698166acb68
Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
drivers/gpu/drm/exynos/exynos_hdmi.c

index 44edff8573d9832d4570e4d28b4c3bb1295e6f6f..eab5b4fabdb9ece2059dce5c8f10506e667179d1 100644 (file)
@@ -792,6 +792,54 @@ static int hdmiphy_reg_write_buf(struct hdmi_context *hdata,
        }
 }
 
+static int hdmi_clk_enable_gates(struct hdmi_context *hdata)
+{
+       int i, ret;
+
+       for (i = 0; i < hdata->drv_data->clk_gates.count; ++i) {
+               ret = clk_prepare_enable(hdata->clk_gates[i]);
+               if (!ret)
+                       continue;
+
+               dev_err(hdata->dev, "Cannot enable clock '%s', %d\n",
+                       hdata->drv_data->clk_gates.data[i], ret);
+               while (i--)
+                       clk_disable_unprepare(hdata->clk_gates[i]);
+               return ret;
+       }
+
+       return 0;
+}
+
+static void hdmi_clk_disable_gates(struct hdmi_context *hdata)
+{
+       int i = hdata->drv_data->clk_gates.count;
+
+       while (i--)
+               clk_disable_unprepare(hdata->clk_gates[i]);
+}
+
+static int hdmi_clk_set_parents(struct hdmi_context *hdata, bool to_phy)
+{
+       struct device *dev = hdata->dev;
+       int ret = 0;
+       int i;
+
+       for (i = 0; i < hdata->drv_data->clk_muxes.count; i += 3) {
+               struct clk **c = &hdata->clk_muxes[i];
+
+               ret = clk_set_parent(c[2], c[to_phy]);
+               if (!ret)
+                       continue;
+
+               dev_err(dev, "Cannot set clock parent of '%s' to '%s', %d\n",
+                       hdata->drv_data->clk_muxes.data[i + 2],
+                       hdata->drv_data->clk_muxes.data[i + to_phy], ret);
+       }
+
+       return ret;
+}
+
 static u8 hdmi_chksum(struct hdmi_context *hdata,
                        u32 start, u8 len, u32 hdr_sum)
 {
@@ -1230,51 +1278,6 @@ static void hdmi_conf_init(struct hdmi_context *hdata)
        }
 }
 
-static int hdmi_clk_enable_gates(struct hdmi_context *hdata)
-{
-       int ret = 0;
-       int i;
-
-       for (i = 0; i < hdata->drv_data->clk_gates.count; ++i) {
-               ret = clk_prepare_enable(hdata->clk_gates[i]);
-               if (ret)
-                       dev_err(hdata->dev, "Cannot enable clock '%s', %d\n",
-                               hdata->drv_data->clk_gates.data[i], ret);
-       }
-
-       return ret;
-}
-
-static void hdmi_clk_disable_gates(struct hdmi_context *hdata)
-{
-       int i;
-
-       i = hdata->drv_data->clk_gates.count;
-
-       while (i--)
-               clk_disable_unprepare(hdata->clk_gates[i]);
-}
-
-static int hdmi_clk_set_parents(struct hdmi_context *hdata, bool to_phy)
-{
-       struct device *dev = hdata->dev;
-       int ret = 0;
-       int i;
-
-       for (i = 0; i < hdata->drv_data->clk_muxes.count; i += 3) {
-               struct clk **c = &hdata->clk_muxes[i];
-
-               ret = clk_set_parent(c[2], c[to_phy]);
-               if (ret)
-                       dev_err(dev, "Cannot set clock parent of '%s' to '%s', %d\n",
-                               hdata->drv_data->clk_muxes.data[i + 2],
-                               hdata->drv_data->clk_muxes.data[i + to_phy],
-                               ret);
-       }
-
-       return ret;
-}
-
 static void hdmi_v13_mode_apply(struct hdmi_context *hdata)
 {
        struct drm_display_mode *m = &hdata->current_mode;
@@ -1802,8 +1805,8 @@ static int hdmi_clks_get(struct hdmi_context *hdata,
                if (IS_ERR(clk)) {
                        int ret = PTR_ERR(clk);
 
-                       dev_err(dev, "Cannot get clock %s, %d\n", names->data[i],
-                               ret);
+                       dev_err(dev, "Cannot get clock %s, %d\n",
+                               names->data[i], ret);
 
                        return ret;
                }