Commit c72fab81 authored by Colin Ian King's avatar Colin Ian King Committed by Bartlomiej Zolnierkiewicz

video: fbdev: vga16fb: fix setting of pixclock because a pass-by-value error

The pixclock is being set locally because it is being passed as a
pass-by-value argument rather than pass-by-reference, so the computed
pixclock is never being set in var->pixclock. Fix this by passing
by reference.

[This dates back to 2002, I found the offending commit from the git
history git://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git ]

Addresses-Coverity: ("Unused value")
Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Jani Nikula <jani.nikula@intel.com>
[b.zolnierkie: minor patch summary fixup]
[b.zolnierkie: removed "Fixes:" tag (not in upstream tree)]
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200723170227.996229-1-colin.king@canonical.com
parent bcee1609
...@@ -243,7 +243,7 @@ static void vga16fb_update_fix(struct fb_info *info) ...@@ -243,7 +243,7 @@ static void vga16fb_update_fix(struct fb_info *info)
} }
static void vga16fb_clock_chip(struct vga16fb_par *par, static void vga16fb_clock_chip(struct vga16fb_par *par,
unsigned int pixclock, unsigned int *pixclock,
const struct fb_info *info, const struct fb_info *info,
int mul, int div) int mul, int div)
{ {
...@@ -259,14 +259,14 @@ static void vga16fb_clock_chip(struct vga16fb_par *par, ...@@ -259,14 +259,14 @@ static void vga16fb_clock_chip(struct vga16fb_par *par,
{ 0 /* bad */, 0x00, 0x00}}; { 0 /* bad */, 0x00, 0x00}};
int err; int err;
pixclock = (pixclock * mul) / div; *pixclock = (*pixclock * mul) / div;
best = vgaclocks; best = vgaclocks;
err = pixclock - best->pixclock; err = *pixclock - best->pixclock;
if (err < 0) err = -err; if (err < 0) err = -err;
for (ptr = vgaclocks + 1; ptr->pixclock; ptr++) { for (ptr = vgaclocks + 1; ptr->pixclock; ptr++) {
int tmp; int tmp;
tmp = pixclock - ptr->pixclock; tmp = *pixclock - ptr->pixclock;
if (tmp < 0) tmp = -tmp; if (tmp < 0) tmp = -tmp;
if (tmp < err) { if (tmp < err) {
err = tmp; err = tmp;
...@@ -275,7 +275,7 @@ static void vga16fb_clock_chip(struct vga16fb_par *par, ...@@ -275,7 +275,7 @@ static void vga16fb_clock_chip(struct vga16fb_par *par,
} }
par->misc |= best->misc; par->misc |= best->misc;
par->clkdiv = best->seq_clock_mode; par->clkdiv = best->seq_clock_mode;
pixclock = (best->pixclock * div) / mul; *pixclock = (best->pixclock * div) / mul;
} }
#define FAIL(X) return -EINVAL #define FAIL(X) return -EINVAL
...@@ -497,10 +497,10 @@ static int vga16fb_check_var(struct fb_var_screeninfo *var, ...@@ -497,10 +497,10 @@ static int vga16fb_check_var(struct fb_var_screeninfo *var,
if (mode & MODE_8BPP) if (mode & MODE_8BPP)
/* pixel clock == vga clock / 2 */ /* pixel clock == vga clock / 2 */
vga16fb_clock_chip(par, var->pixclock, info, 1, 2); vga16fb_clock_chip(par, &var->pixclock, info, 1, 2);
else else
/* pixel clock == vga clock */ /* pixel clock == vga clock */
vga16fb_clock_chip(par, var->pixclock, info, 1, 1); vga16fb_clock_chip(par, &var->pixclock, info, 1, 1);
var->red.offset = var->green.offset = var->blue.offset = var->red.offset = var->green.offset = var->blue.offset =
var->transp.offset = 0; var->transp.offset = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment