fbdev: don't show logo if driver or fbcon are modular
[safe/jmp/linux-2.6] / drivers / video / fbmem.c
index 81b6cd2..08c292d 100644 (file)
  * for more details.
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
 
+#include <linux/compat.h>
 #include <linux/types.h>
 #include <linux/errno.h>
-#include <linux/sched.h>
 #include <linux/smp_lock.h>
 #include <linux/kernel.h>
 #include <linux/major.h>
 #include <linux/slab.h>
 #include <linux/mm.h>
 #include <linux/mman.h>
-#include <linux/tty.h>
+#include <linux/vt.h>
 #include <linux/init.h>
 #include <linux/linux_logo.h>
 #include <linux/proc_fs.h>
@@ -31,9 +30,7 @@
 #ifdef CONFIG_KMOD
 #include <linux/kmod.h>
 #endif
-#include <linux/devfs_fs_kernel.h>
 #include <linux/err.h>
-#include <linux/kernel.h>
 #include <linux/device.h>
 #include <linux/efi.h>
 
@@ -54,9 +51,8 @@
 
 #define FBPIXMAPSIZE   (1024 * 8)
 
-static struct notifier_block *fb_notifier_list;
-struct fb_info *registered_fb[FB_MAX];
-int num_registered_fb;
+struct fb_info *registered_fb[FB_MAX] __read_mostly;
+int num_registered_fb __read_mostly;
 
 /*
  * Helpers
@@ -161,7 +157,6 @@ char* fb_get_buffer_offset(struct fb_info *info, struct fb_pixmap *buf, u32 size
 }
 
 #ifdef CONFIG_LOGO
-#include <linux/linux_logo.h>
 
 static inline unsigned safe_shift(unsigned d, int n)
 {
@@ -206,7 +201,7 @@ static void  fb_set_logo_truepalette(struct fb_info *info,
                                            const struct linux_logo *logo,
                                            u32 *palette)
 {
-       unsigned char mask[9] = { 0,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff };
+       static const unsigned char mask[] = { 0,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff };
        unsigned char redmask, greenmask, bluemask;
        int redshift, greenshift, blueshift;
        int i;
@@ -321,7 +316,7 @@ static struct logo_data {
        int needs_truepalette;
        int needs_cmapreset;
        const struct linux_logo *logo;
-} fb_logo;
+} fb_logo __read_mostly;
 
 static void fb_rotate_logo_ud(const u8 *in, u8 *out, u32 width, u32 height)
 {
@@ -335,11 +330,11 @@ static void fb_rotate_logo_ud(const u8 *in, u8 *out, u32 width, u32 height)
 
 static void fb_rotate_logo_cw(const u8 *in, u8 *out, u32 width, u32 height)
 {
-       int i, j, w = width - 1;
+       int i, j, h = height - 1;
 
        for (i = 0; i < height; i++)
                for (j = 0; j < width; j++)
-                       out[height * j + w - i] = *in++;
+                               out[height * j + h - i] = *in++;
 }
 
 static void fb_rotate_logo_ccw(const u8 *in, u8 *out, u32 width, u32 height)
@@ -357,61 +352,61 @@ static void fb_rotate_logo(struct fb_info *info, u8 *dst,
        u32 tmp;
 
        if (rotate == FB_ROTATE_UD) {
-               image->dx = info->var.xres - image->width;
-               image->dy = info->var.yres - image->height;
                fb_rotate_logo_ud(image->data, dst, image->width,
                                  image->height);
+               image->dx = info->var.xres - image->width - image->dx;
+               image->dy = info->var.yres - image->height - image->dy;
        } else if (rotate == FB_ROTATE_CW) {
-               tmp = image->width;
-               image->width = image->height;
-               image->height = tmp;
-               image->dx = info->var.xres - image->height;
                fb_rotate_logo_cw(image->data, dst, image->width,
                                  image->height);
-       } else if (rotate == FB_ROTATE_CCW) {
                tmp = image->width;
                image->width = image->height;
                image->height = tmp;
-               image->dy = info->var.yres - image->width;
+               tmp = image->dy;
+               image->dy = image->dx;
+               image->dx = info->var.xres - image->width - tmp;
+       } else if (rotate == FB_ROTATE_CCW) {
                fb_rotate_logo_ccw(image->data, dst, image->width,
                                   image->height);
+               tmp = image->width;
+               image->width = image->height;
+               image->height = tmp;
+               tmp = image->dx;
+               image->dx = image->dy;
+               image->dy = info->var.yres - image->height - tmp;
        }
 
        image->data = dst;
 }
 
 static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
-                           int rotate)
+                           int rotate, unsigned int num)
 {
-       int x;
+       unsigned int x;
 
        if (rotate == FB_ROTATE_UR) {
-               for (x = 0; x < num_online_cpus() &&
-                            x * (fb_logo.logo->width + 8) <=
-                            info->var.xres - fb_logo.logo->width; x++) {
+               for (x = 0;
+                    x < num && image->dx + image->width <= info->var.xres;
+                    x++) {
                        info->fbops->fb_imageblit(info, image);
-                       image->dx += fb_logo.logo->width + 8;
+                       image->dx += image->width + 8;
                }
        } else if (rotate == FB_ROTATE_UD) {
-               for (x = 0; x < num_online_cpus() &&
-                            x * (fb_logo.logo->width + 8) <=
-                            info->var.xres - fb_logo.logo->width; x++) {
+               for (x = 0; x < num && image->dx >= 0; x++) {
                        info->fbops->fb_imageblit(info, image);
-                       image->dx -= fb_logo.logo->width + 8;
+                       image->dx -= image->width + 8;
                }
        } else if (rotate == FB_ROTATE_CW) {
-               for (x = 0; x < num_online_cpus() &&
-                            x * (fb_logo.logo->width + 8) <=
-                            info->var.yres - fb_logo.logo->width; x++) {
+               for (x = 0;
+                    x < num && image->dy + image->height <= info->var.yres;
+                    x++) {
                        info->fbops->fb_imageblit(info, image);
-                       image->dy += fb_logo.logo->width + 8;
+                       image->dy += image->height + 8;
                }
        } else if (rotate == FB_ROTATE_CCW) {
-               for (x = 0; x < num_online_cpus() &&
-                            x * (fb_logo.logo->width + 8) <=
-                            info->var.yres - fb_logo.logo->width; x++) {
+               for (x = 0; x < num && image->dy >= 0; x++) {
                        info->fbops->fb_imageblit(info, image);
-                       image->dy -= fb_logo.logo->width + 8;
+                       image->dy -= image->height + 8;
                }
        }
 }
@@ -423,7 +418,8 @@ int fb_prepare_logo(struct fb_info *info, int rotate)
 
        memset(&fb_logo, 0, sizeof(struct logo_data));
 
-       if (info->flags & FBINFO_MISC_TILEBLITTING)
+       if (info->flags & FBINFO_MISC_TILEBLITTING ||
+           info->flags & FBINFO_MODULE)
                return 0;
 
        if (info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
@@ -434,6 +430,11 @@ int fb_prepare_logo(struct fb_info *info, int rotate)
                        depth = info->var.green.length;
        }
 
+       if (info->fix.visual == FB_VISUAL_STATIC_PSEUDOCOLOR && depth > 4) {
+               /* assume console colormap */
+               depth = 4;
+       }
+
        if (depth >= 8) {
                switch (info->fix.visual) {
                case FB_VISUAL_TRUECOLOR:
@@ -451,13 +452,17 @@ int fb_prepare_logo(struct fb_info *info, int rotate)
 
        /* Return if no suitable logo was found */
        fb_logo.logo = fb_find_logo(depth);
+
+       if (!fb_logo.logo) {
+               return 0;
+       }
        
        if (rotate == FB_ROTATE_UR || rotate == FB_ROTATE_UD)
                yres = info->var.yres;
        else
                yres = info->var.xres;
 
-       if (fb_logo.logo && fb_logo.logo->height > yres) {
+       if (fb_logo.logo->height > yres) {
                fb_logo.logo = NULL;
                return 0;
        }
@@ -479,7 +484,8 @@ int fb_show_logo(struct fb_info *info, int rotate)
        struct fb_image image;
 
        /* Return if the frame buffer is not mapped or suspended */
-       if (fb_logo.logo == NULL || info->state != FBINFO_STATE_RUNNING)
+       if (fb_logo.logo == NULL || info->state != FBINFO_STATE_RUNNING ||
+           info->flags & FBINFO_MODULE)
                return 0;
 
        image.depth = 8;
@@ -528,7 +534,7 @@ int fb_show_logo(struct fb_info *info, int rotate)
                        fb_rotate_logo(info, logo_rotate, &image, rotate);
        }
 
-       fb_do_show_logo(info, &image, rotate);
+       fb_do_show_logo(info, &image, rotate, num_online_cpus());
 
        kfree(palette);
        if (saved_pseudo_palette != NULL)
@@ -549,7 +555,8 @@ static int fbmem_read_proc(char *buf, char **start, off_t offset,
        int clen;
 
        clen = 0;
-       for (fi = registered_fb; fi < &registered_fb[FB_MAX] && len < 4000; fi++)
+       for (fi = registered_fb; fi < &registered_fb[FB_MAX] && clen < 4000;
+            fi++)
                if (*fi)
                        clen += sprintf(buf + clen, "%d %s\n",
                                        (*fi)->node,
@@ -566,7 +573,7 @@ static ssize_t
 fb_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;
+       struct inode *inode = file->f_path.dentry->d_inode;
        int fbidx = iminor(inode);
        struct fb_info *info = registered_fb[fbidx];
        u32 *buffer, *dst;
@@ -584,17 +591,19 @@ fb_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
                return info->fbops->fb_read(file, buf, count, ppos);
        
        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 >= total_size)
-           count = total_size;
+               count = total_size;
+
        if (count + p > total_size)
                count = total_size - p;
 
-       cnt = 0;
        buffer = kmalloc((count > PAGE_SIZE) ? PAGE_SIZE : count,
                         GFP_KERNEL);
        if (!buffer)
@@ -631,6 +640,7 @@ fb_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
        }
 
        kfree(buffer);
+
        return (err) ? err : cnt;
 }
 
@@ -638,12 +648,12 @@ static ssize_t
 fb_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;
+       struct inode *inode = file->f_path.dentry->d_inode;
        int fbidx = iminor(inode);
        struct fb_info *info = registered_fb[fbidx];
        u32 *buffer, *src;
        u32 __iomem *dst;
-       int c, i, cnt = 0, err;
+       int c, i, cnt = 0, err = 0;
        unsigned long total_size;
 
        if (!info || !info->screen_base)
@@ -656,19 +666,25 @@ fb_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
                return info->fbops->fb_write(file, buf, count, ppos);
        
        total_size = info->screen_size;
+
        if (total_size == 0)
                total_size = info->fix.smem_len;
 
        if (p > total_size)
-           return -ENOSPC;
-       if (count >= total_size)
-           count = total_size;
-       err = 0;
+               return -EFBIG;
+
+       if (count > total_size) {
+               err = -EFBIG;
+               count = total_size;
+       }
+
        if (count + p > total_size) {
-           count = total_size - p;
-           err = -ENOSPC;
+               if (!err)
+                       err = -ENOSPC;
+
+               count = total_size - p;
        }
-       cnt = 0;
+
        buffer = kmalloc((count > PAGE_SIZE) ? PAGE_SIZE : count,
                         GFP_KERNEL);
        if (!buffer)
@@ -682,12 +698,15 @@ fb_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
        while (count) {
                c = (count > PAGE_SIZE) ? PAGE_SIZE : count;
                src = buffer;
+
                if (copy_from_user(src, buf, c)) {
                        err = -EFAULT;
                        break;
                }
+
                for (i = c >> 2; i--; )
                        fb_writel(*src++, dst++);
+
                if (c & 3) {
                        u8 *src8 = (u8 *) src;
                        u8 __iomem *dst8 = (u8 __iomem *) dst;
@@ -697,14 +716,16 @@ fb_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
 
                        dst = (u32 __iomem *) dst8;
                }
+
                *ppos += c;
                buf += c;
                cnt += c;
                count -= c;
        }
+
        kfree(buffer);
 
-       return (err) ? err : cnt;
+       return (cnt) ? cnt : err;
 }
 
 #ifdef CONFIG_KMOD
@@ -717,14 +738,30 @@ static void try_to_load(int fb)
 int
 fb_pan_display(struct fb_info *info, struct fb_var_screeninfo *var)
 {
+       struct fb_fix_screeninfo *fix = &info->fix;
         int xoffset = var->xoffset;
         int yoffset = var->yoffset;
-        int err;
+        int err = 0, yres = info->var.yres;
+
+       if (var->yoffset > 0) {
+               if (var->vmode & FB_VMODE_YWRAP) {
+                       if (!fix->ywrapstep || (var->yoffset % fix->ywrapstep))
+                               err = -EINVAL;
+                       else
+                               yres = 0;
+               } else if (!fix->ypanstep || (var->yoffset % fix->ypanstep))
+                       err = -EINVAL;
+       }
+
+       if (var->xoffset > 0 && (!fix->xpanstep ||
+                                (var->xoffset % fix->xpanstep)))
+               err = -EINVAL;
+
+        if (err || !info->fbops->fb_pan_display || xoffset < 0 ||
+           yoffset < 0 || var->yoffset + yres > info->var.yres_virtual ||
+           var->xoffset + info->var.xres > info->var.xres_virtual)
+               return -EINVAL;
 
-        if (xoffset < 0 || yoffset < 0 || !info->fbops->fb_pan_display ||
-            xoffset + info->var.xres > info->var.xres_virtual ||
-            yoffset + info->var.yres > info->var.yres_virtual)
-                return -EINVAL;
        if ((err = info->fbops->fb_pan_display(var, info)))
                return err;
         info->var.xoffset = var->xoffset;
@@ -755,8 +792,7 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var)
 
                    event.info = info;
                    event.data = &mode1;
-                   ret = notifier_call_chain(&fb_notifier_list,
-                                             FB_EVENT_MODE_DELETE, &event);
+                   ret = fb_notifier_call_chain(FB_EVENT_MODE_DELETE, &event);
                }
 
                if (!ret)
@@ -801,8 +837,7 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var)
 
                                info->flags &= ~FBINFO_MISC_USEREVENT;
                                event.info = info;
-                               notifier_call_chain(&fb_notifier_list, evnt,
-                                                   &event);
+                               fb_notifier_call_chain(evnt, &event);
                        }
                }
        }
@@ -825,7 +860,7 @@ fb_blank(struct fb_info *info, int blank)
 
                event.info = info;
                event.data = &blank;
-               notifier_call_chain(&fb_notifier_list, FB_EVENT_BLANK, &event);
+               fb_notifier_call_chain(FB_EVENT_BLANK, &event);
        }
 
        return ret;
@@ -896,8 +931,7 @@ fb_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
                con2fb.framebuffer = -1;
                event.info = info;
                event.data = &con2fb;
-               notifier_call_chain(&fb_notifier_list,
-                                   FB_EVENT_GET_CONSOLE_MAP, &event);
+               fb_notifier_call_chain(FB_EVENT_GET_CONSOLE_MAP, &event);
                return copy_to_user(argp, &con2fb,
                                    sizeof(con2fb)) ? -EFAULT : 0;
        case FBIOPUT_CON2FBMAP:
@@ -915,9 +949,8 @@ fb_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
                    return -EINVAL;
                event.info = info;
                event.data = &con2fb;
-               return notifier_call_chain(&fb_notifier_list,
-                                          FB_EVENT_SET_CONSOLE_MAP,
-                                          &event);
+               return fb_notifier_call_chain(FB_EVENT_SET_CONSOLE_MAP,
+                                             &event);
        case FBIOBLANK:
                acquire_console_sem();
                info->flags |= FBINFO_MISC_USEREVENT;
@@ -928,23 +961,159 @@ fb_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
        default:
                if (fb->fb_ioctl == NULL)
                        return -EINVAL;
-               return fb->fb_ioctl(inode, file, cmd, arg, info);
+               return fb->fb_ioctl(info, cmd, arg);
        }
 }
 
 #ifdef CONFIG_COMPAT
+struct fb_fix_screeninfo32 {
+       char                    id[16];
+       compat_caddr_t          smem_start;
+       u32                     smem_len;
+       u32                     type;
+       u32                     type_aux;
+       u32                     visual;
+       u16                     xpanstep;
+       u16                     ypanstep;
+       u16                     ywrapstep;
+       u32                     line_length;
+       compat_caddr_t          mmio_start;
+       u32                     mmio_len;
+       u32                     accel;
+       u16                     reserved[3];
+};
+
+struct fb_cmap32 {
+       u32                     start;
+       u32                     len;
+       compat_caddr_t  red;
+       compat_caddr_t  green;
+       compat_caddr_t  blue;
+       compat_caddr_t  transp;
+};
+
+static int fb_getput_cmap(struct inode *inode, struct file *file,
+                       unsigned int cmd, unsigned long arg)
+{
+       struct fb_cmap_user __user *cmap;
+       struct fb_cmap32 __user *cmap32;
+       __u32 data;
+       int err;
+
+       cmap = compat_alloc_user_space(sizeof(*cmap));
+       cmap32 = compat_ptr(arg);
+
+       if (copy_in_user(&cmap->start, &cmap32->start, 2 * sizeof(__u32)))
+               return -EFAULT;
+
+       if (get_user(data, &cmap32->red) ||
+           put_user(compat_ptr(data), &cmap->red) ||
+           get_user(data, &cmap32->green) ||
+           put_user(compat_ptr(data), &cmap->green) ||
+           get_user(data, &cmap32->blue) ||
+           put_user(compat_ptr(data), &cmap->blue) ||
+           get_user(data, &cmap32->transp) ||
+           put_user(compat_ptr(data), &cmap->transp))
+               return -EFAULT;
+
+       err = fb_ioctl(inode, file, cmd, (unsigned long) cmap);
+
+       if (!err) {
+               if (copy_in_user(&cmap32->start,
+                                &cmap->start,
+                                2 * sizeof(__u32)))
+                       err = -EFAULT;
+       }
+       return err;
+}
+
+static int do_fscreeninfo_to_user(struct fb_fix_screeninfo *fix,
+                                 struct fb_fix_screeninfo32 __user *fix32)
+{
+       __u32 data;
+       int err;
+
+       err = copy_to_user(&fix32->id, &fix->id, sizeof(fix32->id));
+
+       data = (__u32) (unsigned long) fix->smem_start;
+       err |= put_user(data, &fix32->smem_start);
+
+       err |= put_user(fix->smem_len, &fix32->smem_len);
+       err |= put_user(fix->type, &fix32->type);
+       err |= put_user(fix->type_aux, &fix32->type_aux);
+       err |= put_user(fix->visual, &fix32->visual);
+       err |= put_user(fix->xpanstep, &fix32->xpanstep);
+       err |= put_user(fix->ypanstep, &fix32->ypanstep);
+       err |= put_user(fix->ywrapstep, &fix32->ywrapstep);
+       err |= put_user(fix->line_length, &fix32->line_length);
+
+       data = (__u32) (unsigned long) fix->mmio_start;
+       err |= put_user(data, &fix32->mmio_start);
+
+       err |= put_user(fix->mmio_len, &fix32->mmio_len);
+       err |= put_user(fix->accel, &fix32->accel);
+       err |= copy_to_user(fix32->reserved, fix->reserved,
+                           sizeof(fix->reserved));
+
+       return err;
+}
+
+static int fb_get_fscreeninfo(struct inode *inode, struct file *file,
+                               unsigned int cmd, unsigned long arg)
+{
+       mm_segment_t old_fs;
+       struct fb_fix_screeninfo fix;
+       struct fb_fix_screeninfo32 __user *fix32;
+       int err;
+
+       fix32 = compat_ptr(arg);
+
+       old_fs = get_fs();
+       set_fs(KERNEL_DS);
+       err = fb_ioctl(inode, file, cmd, (unsigned long) &fix);
+       set_fs(old_fs);
+
+       if (!err)
+               err = do_fscreeninfo_to_user(&fix, fix32);
+
+       return err;
+}
+
 static long
 fb_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
-       int fbidx = iminor(file->f_dentry->d_inode);
+       struct inode *inode = file->f_path.dentry->d_inode;
+       int fbidx = iminor(inode);
        struct fb_info *info = registered_fb[fbidx];
        struct fb_ops *fb = info->fbops;
-       long ret;
+       long ret = -ENOIOCTLCMD;
 
-       if (fb->fb_compat_ioctl == NULL)
-               return -ENOIOCTLCMD;
        lock_kernel();
-       ret = fb->fb_compat_ioctl(file, cmd, arg, info);
+       switch(cmd) {
+       case FBIOGET_VSCREENINFO:
+       case FBIOPUT_VSCREENINFO:
+       case FBIOPAN_DISPLAY:
+       case FBIOGET_CON2FBMAP:
+       case FBIOPUT_CON2FBMAP:
+               arg = (unsigned long) compat_ptr(arg);
+       case FBIOBLANK:
+               ret = fb_ioctl(inode, file, cmd, arg);
+               break;
+
+       case FBIOGET_FSCREENINFO:
+               ret = fb_get_fscreeninfo(inode, file, cmd, arg);
+               break;
+
+       case FBIOGETCMAP:
+       case FBIOPUTCMAP:
+               ret = fb_getput_cmap(inode, file, cmd, arg);
+               break;
+
+       default:
+               if (fb->fb_compat_ioctl)
+                       ret = fb->fb_compat_ioctl(info, cmd, arg);
+               break;
+       }
        unlock_kernel();
        return ret;
 }
@@ -953,7 +1122,7 @@ fb_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 static int 
 fb_mmap(struct file *file, struct vm_area_struct * vma)
 {
-       int fbidx = iminor(file->f_dentry->d_inode);
+       int fbidx = iminor(file->f_path.dentry->d_inode);
        struct fb_info *info = registered_fb[fbidx];
        struct fb_ops *fb = info->fbops;
        unsigned long off;
@@ -970,7 +1139,7 @@ fb_mmap(struct file *file, struct vm_area_struct * vma)
        if (fb->fb_mmap) {
                int res;
                lock_kernel();
-               res = fb->fb_mmap(info, file, vma);
+               res = fb->fb_mmap(info, vma);
                unlock_kernel();
                return res;
        }
@@ -1004,11 +1173,6 @@ fb_mmap(struct file *file, struct vm_area_struct * vma)
        vma->vm_pgoff = off >> PAGE_SHIFT;
        /* This is an IO map - tell maydump to skip this VMA */
        vma->vm_flags |= VM_IO | VM_RESERVED;
-#if defined(__sparc_v9__)
-       if (io_remap_pfn_range(vma, vma->vm_start, off >> PAGE_SHIFT,
-                               vma->vm_end - vma->vm_start, vma->vm_page_prot))
-               return -EAGAIN;
-#else
 #if defined(__mc68000__)
 #if defined(CONFIG_SUN3)
        pgprot_val(vma->vm_page_prot) |= SUN3_PAGE_NOCACHE;
@@ -1030,7 +1194,7 @@ fb_mmap(struct file *file, struct vm_area_struct * vma)
 #elif defined(__i386__) || defined(__x86_64__)
        if (boot_cpu_data.x86 > 3)
                pgprot_val(vma->vm_page_prot) |= _PAGE_PCD;
-#elif defined(__mips__)
+#elif defined(__mips__) || defined(__sparc_v9__)
        vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
 #elif defined(__hppa__)
        pgprot_val(vma->vm_page_prot) |= _PAGE_NO_CACHE;
@@ -1047,7 +1211,6 @@ fb_mmap(struct file *file, struct vm_area_struct * vma)
        if (io_remap_pfn_range(vma, vma->vm_start, off >> PAGE_SHIFT,
                             vma->vm_end - vma->vm_start, vma->vm_page_prot))
                return -EAGAIN;
-#endif /* !__sparc_v9__ */
        return 0;
 #endif /* !sparc32 */
 }
@@ -1069,6 +1232,7 @@ fb_open(struct inode *inode, struct file *file)
                return -ENODEV;
        if (!try_module_get(info->fbops->owner))
                return -ENODEV;
+       file->private_data = info;
        if (info->fbops->fb_open) {
                res = info->fbops->fb_open(info,1);
                if (res)
@@ -1080,11 +1244,9 @@ fb_open(struct inode *inode, struct file *file)
 static int 
 fb_release(struct inode *inode, struct file *file)
 {
-       int fbidx = iminor(inode);
-       struct fb_info *info;
+       struct fb_info * const info = file->private_data;
 
        lock_kernel();
-       info = registered_fb[fbidx];
        if (info->fbops->fb_release)
                info->fbops->fb_release(info,1);
        module_put(info->fbops->owner);
@@ -1092,7 +1254,7 @@ fb_release(struct inode *inode, struct file *file)
        return 0;
 }
 
-static struct file_operations fb_fops = {
+static const struct file_operations fb_fops = {
        .owner =        THIS_MODULE,
        .read =         fb_read,
        .write =        fb_write,
@@ -1106,10 +1268,13 @@ static struct file_operations fb_fops = {
 #ifdef HAVE_ARCH_FB_UNMAPPED_AREA
        .get_unmapped_area = get_fb_unmapped_area,
 #endif
+#ifdef CONFIG_FB_DEFERRED_IO
+       .fsync =        fb_deferred_io_fsync,
+#endif
 };
 
-static struct class *fb_class;
-
+struct class *fb_class;
+EXPORT_SYMBOL(fb_class);
 /**
  *     register_framebuffer - registers a frame buffer device
  *     @fb_info: frame buffer info structure
@@ -1135,14 +1300,14 @@ register_framebuffer(struct fb_info *fb_info)
                        break;
        fb_info->node = i;
 
-       fb_info->class_device = class_device_create(fb_class, NULL, MKDEV(FB_MAJOR, i),
-                                   fb_info->device, "fb%d", i);
-       if (IS_ERR(fb_info->class_device)) {
+       fb_info->dev = device_create(fb_class, fb_info->device,
+                                    MKDEV(FB_MAJOR, i), "fb%d", i);
+       if (IS_ERR(fb_info->dev)) {
                /* Not fatal */
-               printk(KERN_WARNING "Unable to create class_device for framebuffer %d; errno = %ld\n", i, PTR_ERR(fb_info->class_device));
-               fb_info->class_device = NULL;
+               printk(KERN_WARNING "Unable to create device for framebuffer %d; errno = %ld\n", i, PTR_ERR(fb_info->dev));
+               fb_info->dev = NULL;
        } else
-               fb_init_class_device(fb_info);
+               fb_init_device(fb_info);
 
        if (fb_info->pixmap.addr == NULL) {
                fb_info->pixmap.addr = kmalloc(FBPIXMAPSIZE, GFP_KERNEL);
@@ -1163,11 +1328,8 @@ register_framebuffer(struct fb_info *fb_info)
        fb_add_videomode(&mode, &fb_info->modelist);
        registered_fb[i] = fb_info;
 
-       devfs_mk_cdev(MKDEV(FB_MAJOR, i),
-                       S_IFCHR | S_IRUGO | S_IWUGO, "fb/%d", i);
        event.info = fb_info;
-       notifier_call_chain(&fb_notifier_list,
-                           FB_EVENT_FB_REGISTERED, &event);
+       fb_notifier_call_chain(FB_EVENT_FB_REGISTERED, &event);
        return 0;
 }
 
@@ -1185,42 +1347,27 @@ register_framebuffer(struct fb_info *fb_info)
 int
 unregister_framebuffer(struct fb_info *fb_info)
 {
+       struct fb_event event;
        int i;
 
        i = fb_info->node;
        if (!registered_fb[i])
                return -EINVAL;
-       devfs_remove("fb/%d", i);
 
-       if (fb_info->pixmap.addr && (fb_info->pixmap.flags & FB_PIXMAP_DEFAULT))
+       if (fb_info->pixmap.addr &&
+           (fb_info->pixmap.flags & FB_PIXMAP_DEFAULT))
                kfree(fb_info->pixmap.addr);
        fb_destroy_modelist(&fb_info->modelist);
        registered_fb[i]=NULL;
        num_registered_fb--;
-       fb_cleanup_class_device(fb_info);
-       class_device_destroy(fb_class, MKDEV(FB_MAJOR, i));
+       fb_cleanup_device(fb_info);
+       device_destroy(fb_class, MKDEV(FB_MAJOR, i));
+       event.info = fb_info;
+       fb_notifier_call_chain(FB_EVENT_FB_UNREGISTERED, &event);
        return 0;
 }
 
 /**
- *     fb_register_client - register a client notifier
- *     @nb: notifier block to callback on events
- */
-int fb_register_client(struct notifier_block *nb)
-{
-       return notifier_chain_register(&fb_notifier_list, nb);
-}
-
-/**
- *     fb_unregister_client - unregister a client notifier
- *     @nb: notifier block to callback on events
- */
-int fb_unregister_client(struct notifier_block *nb)
-{
-       return notifier_chain_unregister(&fb_notifier_list, nb);
-}
-
-/**
  *     fb_set_suspend - low level driver signals suspend
  *     @info: framebuffer affected
  *     @state: 0 = resuming, !=0 = suspending
@@ -1235,11 +1382,11 @@ void fb_set_suspend(struct fb_info *info, int state)
 
        event.info = info;
        if (state) {
-               notifier_call_chain(&fb_notifier_list, FB_EVENT_SUSPEND, &event);
+               fb_notifier_call_chain(FB_EVENT_SUSPEND, &event);
                info->state = FBINFO_STATE_SUSPENDED;
        } else {
                info->state = FBINFO_STATE_RUNNING;
-               notifier_call_chain(&fb_notifier_list, FB_EVENT_RESUME, &event);
+               fb_notifier_call_chain(FB_EVENT_RESUME, &event);
        }
 }
 
@@ -1257,7 +1404,6 @@ fbmem_init(void)
 {
        create_proc_read_entry("fb", 0, NULL, fbmem_read_proc, NULL);
 
-       devfs_mk_dir("fb");
        if (register_chrdev(FB_MAJOR,"fb",&fb_fops))
                printk("unable to get major %d for fb devs\n", FB_MAJOR);
 
@@ -1311,38 +1457,14 @@ int fb_new_modelist(struct fb_info *info)
 
        if (!list_empty(&info->modelist)) {
                event.info = info;
-               err = notifier_call_chain(&fb_notifier_list,
-                                          FB_EVENT_NEW_MODELIST,
-                                          &event);
+               err = fb_notifier_call_chain(FB_EVENT_NEW_MODELIST, &event);
        }
 
        return err;
 }
 
-/**
- * fb_con_duit - user<->fbcon passthrough
- * @info: struct fb_info
- * @event: notification event to be passed to fbcon
- * @data: private data
- *
- * DESCRIPTION
- * This function is an fbcon-user event passing channel
- * which bypasses fbdev.  This is hopefully temporary
- * until a user interface for fbcon is created
- */
-int fb_con_duit(struct fb_info *info, int event, void *data)
-{
-       struct fb_event evnt;
-
-       evnt.info = info;
-       evnt.data = data;
-
-       return notifier_call_chain(&fb_notifier_list, event, &evnt);
-}
-EXPORT_SYMBOL(fb_con_duit);
-
-static char *video_options[FB_MAX];
-static int ofonly;
+static char *video_options[FB_MAX] __read_mostly;
+static int ofonly __read_mostly;
 
 extern const char *global_mode_option;
 
@@ -1386,6 +1508,7 @@ int fb_get_options(char *name, char **option)
        return retval;
 }
 
+#ifndef MODULE
 /**
  *     video_setup - process command line options
  *     @options: string of options
@@ -1426,9 +1549,10 @@ static int __init video_setup(char *options)
                }
        }
 
-       return 0;
+       return 1;
 }
 __setup("video=", video_setup);
+#endif
 
     /*
      *  Visible symbols for modules
@@ -1445,9 +1569,6 @@ EXPORT_SYMBOL(fb_blank);
 EXPORT_SYMBOL(fb_pan_display);
 EXPORT_SYMBOL(fb_get_buffer_offset);
 EXPORT_SYMBOL(fb_set_suspend);
-EXPORT_SYMBOL(fb_register_client);
-EXPORT_SYMBOL(fb_unregister_client);
 EXPORT_SYMBOL(fb_get_options);
-EXPORT_SYMBOL(fb_new_modelist);
 
 MODULE_LICENSE("GPL");