drm/rockchip: dw-mipi-dsi: organize dw_mipi_dsi_get_hcomponent_lbcc function
authorxubilv <xbl@rock-chips.com>
Mon, 17 Jul 2017 10:05:48 +0000 (18:05 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Thu, 20 Jul 2017 11:18:51 +0000 (19:18 +0800)
Use the common interface to calculate

Change-Id: I21836061d1442048efaba3b2930811b8a0aab0aa
Signed-off-by: xubilv <xbl@rock-chips.com>
drivers/gpu/drm/rockchip/dw-mipi-dsi.c

index b2994b6339584ef1a6adf76b1fb2ea6e3a5712de..6cf7da73e5772a5f832b50f0426c8ad359f4bd1d 100644 (file)
@@ -808,16 +808,16 @@ static void dw_mipi_dsi_command_mode_config(struct dw_mipi_dsi *dsi)
 static u32 dw_mipi_dsi_get_hcomponent_lbcc(struct dw_mipi_dsi *dsi,
                                           u32 hcomponent)
 {
-       u32 frac, lbcc;
+       u32 lbcc;
 
        lbcc = hcomponent * dsi->lane_mbps * MSEC_PER_SEC / 8;
 
-       frac = lbcc % dsi->mode.clock;
-       lbcc = lbcc / dsi->mode.clock;
-       if (frac)
-               lbcc++;
+       if (dsi->mode.clock == 0) {
+               dev_err(dsi->dev, "dsi mode clock is 0!\n");
+               return 0;
+       }
 
-       return lbcc;
+       return DIV_ROUND_CLOSEST_ULL(lbcc, dsi->mode.clock);
 }
 
 static void dw_mipi_dsi_line_timer_config(struct dw_mipi_dsi *dsi)