]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/video/riva/fbdev.c
backlight: Remove unneeded owner field
[linux-2.6-omap-h63xx.git] / drivers / video / riva / fbdev.c
index 1a13966b7d5b04d5aaa3a45a0b72e68638982806..fd825711bb638ca104cbeea5dea42ce39bc77d2f 100644 (file)
@@ -347,7 +347,6 @@ static int riva_bl_get_brightness(struct backlight_device *bd)
 }
 
 static struct backlight_properties riva_bl_data = {
-       .owner    = THIS_MODULE,
        .get_brightness = riva_bl_get_brightness,
        .update_status  = riva_bl_update_status,
        .max_brightness = (FB_BACKLIGHT_LEVELS - 1),
@@ -894,7 +893,8 @@ out:
        return rc;
 }
 
-static void riva_update_var(struct fb_var_screeninfo *var, struct fb_videomode *modedb)
+static void riva_update_var(struct fb_var_screeninfo *var,
+                           const struct fb_videomode *modedb)
 {
        NVTRACE_ENTER();
        var->xres = var->xres_virtual = modedb->xres;
@@ -1101,10 +1101,10 @@ static int riva_get_cmap_len(const struct fb_var_screeninfo *var)
 static int rivafb_open(struct fb_info *info, int user)
 {
        struct riva_par *par = info->par;
-       int cnt = atomic_read(&par->ref_count);
 
        NVTRACE_ENTER();
-       if (!cnt) {
+       mutex_lock(&par->open_lock);
+       if (!par->ref_count) {
 #ifdef CONFIG_X86
                memset(&par->state, 0, sizeof(struct vgastate));
                par->state.flags = VGA_SAVE_MODE  | VGA_SAVE_FONTS;
@@ -1119,7 +1119,8 @@ static int rivafb_open(struct fb_info *info, int user)
        
                riva_save_state(par, &par->initial_state);
        }
-       atomic_inc(&par->ref_count);
+       par->ref_count++;
+       mutex_unlock(&par->open_lock);
        NVTRACE_LEAVE();
        return 0;
 }
@@ -1127,12 +1128,14 @@ static int rivafb_open(struct fb_info *info, int user)
 static int rivafb_release(struct fb_info *info, int user)
 {
        struct riva_par *par = info->par;
-       int cnt = atomic_read(&par->ref_count);
 
        NVTRACE_ENTER();
-       if (!cnt)
+       mutex_lock(&par->open_lock);
+       if (!par->ref_count) {
+               mutex_unlock(&par->open_lock);
                return -EINVAL;
-       if (cnt == 1) {
+       }
+       if (par->ref_count == 1) {
                par->riva.LockUnlock(&par->riva, 0);
                par->riva.LoadStateExt(&par->riva, &par->initial_state.ext);
                riva_load_state(par, &par->initial_state);
@@ -1141,14 +1144,15 @@ static int rivafb_release(struct fb_info *info, int user)
 #endif
                par->riva.LockUnlock(&par->riva, 1);
        }
-       atomic_dec(&par->ref_count);
+       par->ref_count--;
+       mutex_unlock(&par->open_lock);
        NVTRACE_LEAVE();
        return 0;
 }
 
 static int rivafb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
 {
-       struct fb_videomode *mode;
+       const struct fb_videomode *mode;
        struct riva_par *par = info->par;
        int nom, den;           /* translating from pixels->bytes */
        int mode_valid = 0;
@@ -1980,12 +1984,11 @@ static int __devinit rivafb_probe(struct pci_dev *pd,
        default_par = info->par;
        default_par->pdev = pd;
 
-       info->pixmap.addr = kmalloc(8 * 1024, GFP_KERNEL);
+       info->pixmap.addr = kzalloc(8 * 1024, GFP_KERNEL);
        if (info->pixmap.addr == NULL) {
                ret = -ENOMEM;
                goto err_framebuffer_release;
        }
-       memset(info->pixmap.addr, 0, 8 * 1024);
 
        ret = pci_enable_device(pd);
        if (ret < 0) {
@@ -1999,6 +2002,7 @@ static int __devinit rivafb_probe(struct pci_dev *pd,
                goto err_disable_device;
        }
 
+       mutex_init(&default_par->open_lock);
        default_par->riva.Architecture = riva_get_arch(pd);
 
        default_par->Chipset = (pd->vendor << 16) | pd->device;