Commit 963654a9 authored by Jaya Kumar's avatar Jaya Kumar Committed by Linus Torvalds

fbdev: hecubafb bugfix

This patch is a bugfix for hecubafb_write which would return an incorrect
error value for the bytecount from framebuffer writes.
Signed-off-by: default avatarJaya Kumar <jayakumar.lkml@gmail.com>
Cc: "Antonino A. Daplas" <adaplas@pol.net>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 555514fa
...@@ -270,41 +270,43 @@ static void hecubafb_imageblit(struct fb_info *info, ...@@ -270,41 +270,43 @@ static void hecubafb_imageblit(struct fb_info *info,
static ssize_t hecubafb_write(struct fb_info *info, const char __user *buf, static ssize_t hecubafb_write(struct fb_info *info, const char __user *buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
unsigned long p; struct hecubafb_par *par = info->par;
int err=-EINVAL; unsigned long p = *ppos;
struct hecubafb_par *par; void *dst;
unsigned int xres; int err = 0;
unsigned int fbmemlength; unsigned long total_size;
p = *ppos; if (info->state != FBINFO_STATE_RUNNING)
par = info->par; return -EPERM;
xres = info->var.xres;
fbmemlength = (xres * info->var.yres)/8;
if (p > fbmemlength) total_size = info->fix.smem_len;
return -ENOSPC;
if (p > total_size)
return -EFBIG;
if (count > total_size) {
err = -EFBIG;
count = total_size;
}
err = 0; if (count + p > total_size) {
if ((count + p) > fbmemlength) { if (!err)
count = fbmemlength - p;
err = -ENOSPC; err = -ENOSPC;
count = total_size - p;
} }
if (count) { dst = (void __force *) (info->screen_base + p);
char *base_addr;
base_addr = (char __force *)info->screen_base; if (copy_from_user(dst, buf, count))
count -= copy_from_user(base_addr + p, buf, count);
*ppos += count;
err = -EFAULT; err = -EFAULT;
}
hecubafb_dpy_update(par); if (!err)
*ppos += count;
if (count) hecubafb_dpy_update(par);
return count;
return err; return (err) ? err : count;
} }
static struct fb_ops hecubafb_ops = { static struct fb_ops hecubafb_ops = {
......
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