drm/radeon/rv740: fix backend setup
[safe/jmp/linux-2.6] / drivers / video / fbmem.c
index 53eb396..99bbd28 100644 (file)
@@ -16,7 +16,6 @@
 #include <linux/compat.h>
 #include <linux/types.h>
 #include <linux/errno.h>
-#include <linux/smp_lock.h>
 #include <linux/kernel.h>
 #include <linux/major.h>
 #include <linux/slab.h>
@@ -872,8 +871,8 @@ fb_pan_display(struct fb_info *info, struct fb_var_screeninfo *var)
                err = -EINVAL;
 
        if (err || !info->fbops->fb_pan_display ||
-           var->yoffset + yres > info->var.yres_virtual ||
-           var->xoffset + info->var.xres > info->var.xres_virtual)
+           var->yoffset > info->var.yres_virtual - yres ||
+           var->xoffset > info->var.xres_virtual - info->var.xres)
                return -EINVAL;
 
        if ((err = info->fbops->fb_pan_display(var, info)))
@@ -955,6 +954,7 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var)
                        goto done;
 
                if ((var->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW) {
+                       struct fb_var_screeninfo old_var;
                        struct fb_videomode mode;
 
                        if (info->fbops->fb_get_caps) {
@@ -964,10 +964,20 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var)
                                        goto done;
                        }
 
+                       old_var = info->var;
                        info->var = *var;
 
-                       if (info->fbops->fb_set_par)
-                               info->fbops->fb_set_par(info);
+                       if (info->fbops->fb_set_par) {
+                               ret = info->fbops->fb_set_par(info);
+
+                               if (ret) {
+                                       info->var = old_var;
+                                       printk(KERN_WARNING "detected "
+                                               "fb_set_par error, "
+                                               "error code: %d\n", ret);
+                                       goto done;
+                               }
+                       }
 
                        fb_pan_display(info, &info->var);
                        fb_set_cmap(&info->cmap, info);
@@ -1513,6 +1523,8 @@ register_framebuffer(struct fb_info *fb_info)
                if (!registered_fb[i])
                        break;
        fb_info->node = i;
+       mutex_init(&fb_info->lock);
+       mutex_init(&fb_info->mm_lock);
 
        fb_info->dev = device_create(fb_class, fb_info->device,
                                     MKDEV(FB_MAJOR, i), NULL, "fb%d", i);
@@ -1788,7 +1800,7 @@ static int __init video_setup(char *options)
                global = 1;
        }
 
-       if (!global && !strstr(options, "fb:")) {
+       if (!global && !strchr(options, ':')) {
                fb_mode_option = options;
                global = 1;
        }