Commit e3e7f914 authored by Benjamin Herrenschmidt's avatar Benjamin Herrenschmidt Committed by Linus Torvalds

[PATCH] fbdev/radeonfb: Remove bugus radeonfb_read/write

This patch kills the bogus radeonfb_read/write routines. In order to do so,
it adds a new member to fb_info, along with screen_base, which is screen_size,
indicating the mapped area. The default fb_read/write will now use that instead
of fix->smem_len if it is non-0, and radeonfb now sets it to the mapped size
of the framebuffer.
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 358c65b2
...@@ -1702,68 +1702,6 @@ int radeonfb_set_par(struct fb_info *info) ...@@ -1702,68 +1702,6 @@ int radeonfb_set_par(struct fb_info *info)
} }
static ssize_t radeonfb_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
{
unsigned long p = *ppos;
struct inode *inode = file->f_dentry->d_inode;
int fbidx = iminor(inode);
struct fb_info *info = registered_fb[fbidx];
struct radeonfb_info *rinfo = info->par;
if (p >= rinfo->mapped_vram)
return 0;
if (count >= rinfo->mapped_vram)
count = rinfo->mapped_vram;
if (count + p > rinfo->mapped_vram)
count = rinfo->mapped_vram - p;
radeonfb_sync(info);
if (count) {
void __iomem *base_addr;
base_addr = info->screen_base;
count -= copy_to_user(buf, base_addr+p, count); /* Ayee!! */
if (!count)
return -EFAULT;
*ppos += count;
}
return count;
}
static ssize_t radeonfb_write(struct file *file, const char __user *buf, size_t count,
loff_t *ppos)
{
unsigned long p = *ppos;
struct inode *inode = file->f_dentry->d_inode;
int fbidx = iminor(inode);
struct fb_info *info = registered_fb[fbidx];
struct radeonfb_info *rinfo = info->par;
int err;
if (p > rinfo->mapped_vram)
return -ENOSPC;
if (count >= rinfo->mapped_vram)
count = rinfo->mapped_vram;
err = 0;
if (count + p > rinfo->mapped_vram) {
count = rinfo->mapped_vram - p;
err = -ENOSPC;
}
radeonfb_sync(info);
if (count) {
void __iomem *base_addr;
base_addr = info->screen_base;
count -= copy_from_user(base_addr+p, buf, count); /* Ayee!! */
*ppos += count;
err = -EFAULT;
}
if (count)
return count;
return err;
}
static struct fb_ops radeonfb_ops = { static struct fb_ops radeonfb_ops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.fb_check_var = radeonfb_check_var, .fb_check_var = radeonfb_check_var,
...@@ -1776,8 +1714,6 @@ static struct fb_ops radeonfb_ops = { ...@@ -1776,8 +1714,6 @@ static struct fb_ops radeonfb_ops = {
.fb_fillrect = radeonfb_fillrect, .fb_fillrect = radeonfb_fillrect,
.fb_copyarea = radeonfb_copyarea, .fb_copyarea = radeonfb_copyarea,
.fb_imageblit = radeonfb_imageblit, .fb_imageblit = radeonfb_imageblit,
.fb_read = radeonfb_read,
.fb_write = radeonfb_write,
.fb_cursor = soft_cursor, .fb_cursor = soft_cursor,
}; };
...@@ -1796,7 +1732,7 @@ static int __devinit radeon_set_fbinfo (struct radeonfb_info *rinfo) ...@@ -1796,7 +1732,7 @@ static int __devinit radeon_set_fbinfo (struct radeonfb_info *rinfo)
| FBINFO_HWACCEL_YPAN; | FBINFO_HWACCEL_YPAN;
info->fbops = &radeonfb_ops; info->fbops = &radeonfb_ops;
info->screen_base = rinfo->fb_base; info->screen_base = rinfo->fb_base;
info->screen_size = rinfo->mapped_vram;
/* Fill fix common fields */ /* Fill fix common fields */
strlcpy(info->fix.id, rinfo->name, sizeof(info->fix.id)); strlcpy(info->fix.id, rinfo->name, sizeof(info->fix.id));
info->fix.smem_start = rinfo->fb_base_phys; info->fix.smem_start = rinfo->fb_base_phys;
...@@ -2243,12 +2179,6 @@ static int radeonfb_pci_register (struct pci_dev *pdev, ...@@ -2243,12 +2179,6 @@ static int radeonfb_pci_register (struct pci_dev *pdev,
RTRACE("radeonfb: mapped %ldk videoram\n", rinfo->mapped_vram/1024); RTRACE("radeonfb: mapped %ldk videoram\n", rinfo->mapped_vram/1024);
/* Argh. Scary arch !!! */
#ifdef CONFIG_PPC64
rinfo->fb_base = IO_TOKEN_TO_ADDR(rinfo->fb_base);
#endif
/* /*
* Check for required workaround for PLL accesses * Check for required workaround for PLL accesses
*/ */
......
...@@ -506,6 +506,7 @@ fb_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) ...@@ -506,6 +506,7 @@ fb_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
struct fb_info *info = registered_fb[fbidx]; struct fb_info *info = registered_fb[fbidx];
u32 *buffer, *dst, *src; u32 *buffer, *dst, *src;
int c, i, cnt = 0, err = 0; int c, i, cnt = 0, err = 0;
unsigned long total_size;
if (!info || ! info->screen_base) if (!info || ! info->screen_base)
return -ENODEV; return -ENODEV;
...@@ -516,12 +517,16 @@ fb_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) ...@@ -516,12 +517,16 @@ fb_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
if (info->fbops->fb_read) if (info->fbops->fb_read)
return info->fbops->fb_read(file, buf, count, ppos); return info->fbops->fb_read(file, buf, count, ppos);
if (p >= info->fix.smem_len) total_size = info->screen_size;
if (total_size == 0)
total_size = info->fix.smem_len;
if (p >= total_size)
return 0; return 0;
if (count >= info->fix.smem_len) if (count >= total_size)
count = info->fix.smem_len; count = total_size;
if (count + p > info->fix.smem_len) if (count + p > total_size)
count = info->fix.smem_len - p; count = total_size - p;
cnt = 0; cnt = 0;
buffer = kmalloc((count > PAGE_SIZE) ? PAGE_SIZE : count, buffer = kmalloc((count > PAGE_SIZE) ? PAGE_SIZE : count,
...@@ -572,6 +577,7 @@ fb_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) ...@@ -572,6 +577,7 @@ fb_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
struct fb_info *info = registered_fb[fbidx]; struct fb_info *info = registered_fb[fbidx];
u32 *buffer, *dst, *src; u32 *buffer, *dst, *src;
int c, i, cnt = 0, err; int c, i, cnt = 0, err;
unsigned long total_size;
if (!info || !info->screen_base) if (!info || !info->screen_base)
return -ENODEV; return -ENODEV;
...@@ -582,13 +588,17 @@ fb_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) ...@@ -582,13 +588,17 @@ fb_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
if (info->fbops->fb_write) if (info->fbops->fb_write)
return info->fbops->fb_write(file, buf, count, ppos); return info->fbops->fb_write(file, buf, count, ppos);
if (p > info->fix.smem_len) total_size = info->screen_size;
if (total_size == 0)
total_size = info->fix.smem_len;
if (p > total_size)
return -ENOSPC; return -ENOSPC;
if (count >= info->fix.smem_len) if (count >= total_size)
count = info->fix.smem_len; count = total_size;
err = 0; err = 0;
if (count + p > info->fix.smem_len) { if (count + p > total_size) {
count = info->fix.smem_len - p; count = total_size - p;
err = -ENOSPC; err = -ENOSPC;
} }
cnt = 0; cnt = 0;
......
...@@ -603,6 +603,7 @@ struct fb_info { ...@@ -603,6 +603,7 @@ struct fb_info {
struct fb_cmap cmap; /* Current cmap */ struct fb_cmap cmap; /* Current cmap */
struct fb_ops *fbops; struct fb_ops *fbops;
char __iomem *screen_base; /* Virtual address */ char __iomem *screen_base; /* Virtual address */
unsigned long screen_size; /* Amount of ioremapped VRAM or 0 */
int currcon; /* Current VC. */ int currcon; /* Current VC. */
void *pseudo_palette; /* Fake palette of 16 colors */ void *pseudo_palette; /* Fake palette of 16 colors */
#define FBINFO_STATE_RUNNING 0 #define FBINFO_STATE_RUNNING 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