From: Tobias Jakobi Date: Thu, 5 May 2016 16:23:38 +0000 (+0200) Subject: drm/exynos: fimd: harden fimd_calc_clkdiv() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=fa9971d62a8cfc085b07b3eda1f45c236acc7d70;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git drm/exynos: fimd: harden fimd_calc_clkdiv() Don't use the vrefresh field of the DRM mode since this one is supposed to only be used for debug purpose. Instead use the clock field which should also provide much more precise information. Also sanitize the case in which the clock value should be zero. We then just default to the maximum clock divisor. Signed-off-by: Tobias Jakobi Reviewed-by: Andrzej Hajda Signed-off-by: Inki Dae --- diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c index cec508f9a335..3efe1aa89416 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c @@ -397,9 +397,16 @@ static void fimd_clear_channels(struct exynos_drm_crtc *crtc) static u32 fimd_calc_clkdiv(struct fimd_context *ctx, const struct drm_display_mode *mode) { - unsigned long ideal_clk = mode->htotal * mode->vtotal * mode->vrefresh; + unsigned long ideal_clk; u32 clkdiv; + if (mode->clock == 0) { + DRM_ERROR("Mode has zero clock value.\n"); + return 0xff; + } + + ideal_clk = mode->clock * 1000; + if (ctx->i80_if) { /* * The frame done interrupt should be occurred prior to the