Merge tag 'drm-misc-next-2022-08-20-1' of git://anongit.freedesktop.org/drm/drm-misc...
[linux-block.git] / drivers / video / fbdev / arkfb.c
index 453daa072f534a214b8090ec20937f8b26378282..a317d9fe1d67de4864af27bc928126335e547e68 100644 (file)
@@ -782,7 +782,12 @@ static int arkfb_set_par(struct fb_info *info)
                return -EINVAL;
        }
 
-       ark_set_pixclock(info, (hdiv * info->var.pixclock) / hmul);
+       value = (hdiv * info->var.pixclock) / hmul;
+       if (!value) {
+               fb_dbg(info, "invalid pixclock\n");
+               value = 1;
+       }
+       ark_set_pixclock(info, value);
        svga_set_timings(par->state.vgabase, &ark_timing_regs, &(info->var), hmul, hdiv,
                         (info->var.vmode & FB_VMODE_DOUBLE)     ? 2 : 1,
                         (info->var.vmode & FB_VMODE_INTERLACED) ? 2 : 1,
@@ -793,6 +798,8 @@ static int arkfb_set_par(struct fb_info *info)
        value = ((value * hmul / hdiv) / 8) - 5;
        vga_wcrt(par->state.vgabase, 0x42, (value + 1) / 2);
 
+       if (screen_size > info->screen_size)
+               screen_size = info->screen_size;
        memset_io(info->screen_base, 0x00, screen_size);
        /* Device and screen back on */
        svga_wcrt_mask(par->state.vgabase, 0x17, 0x80, 0x80);