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: Jaya Kumar <jayakumar.lkml@gmail.com>
Cc: "Antonino A. Daplas" <adaplas@pol.net>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Jaya Kumar 2008-04-28 02:15:37 -07:00 committed by Linus Torvalds
parent 555514fabc
commit 963654a9c9
1 changed files with 27 additions and 25 deletions

View File

@ -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;
err = 0; if (p > total_size)
if ((count + p) > fbmemlength) { return -EFBIG;
count = fbmemlength - p;
err = -ENOSPC; if (count > total_size) {
err = -EFBIG;
count = total_size;
} }
if (count) { if (count + p > total_size) {
char *base_addr; if (!err)
err = -ENOSPC;
base_addr = (char __force *)info->screen_base; count = total_size - p;
count -= copy_from_user(base_addr + p, buf, count); }
*ppos += count;
dst = (void __force *) (info->screen_base + p);
if (copy_from_user(dst, buf, count))
err = -EFAULT; err = -EFAULT;
}
if (!err)
*ppos += count;
hecubafb_dpy_update(par); hecubafb_dpy_update(par);
if (count) return (err) ? err : count;
return count;
return err;
} }
static struct fb_ops hecubafb_ops = { static struct fb_ops hecubafb_ops = {