rt2x00: Cleanup symbol exports
[safe/jmp/linux-2.6] / drivers / video / neofb.c
index deaf820..5246b04 100644 (file)
 #include <linux/init.h>
 #ifdef CONFIG_TOSHIBA
 #include <linux/toshiba.h>
-extern int tosh_smm(SMMRegisters *regs);
 #endif
 
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/pgtable.h>
 #include <asm/system.h>
-#include <asm/uaccess.h>
 
 #ifdef CONFIG_MTRR
 #include <asm/mtrr.h>
@@ -557,14 +555,16 @@ static int
 neofb_open(struct fb_info *info, int user)
 {
        struct neofb_par *par = info->par;
-       int cnt = atomic_read(&par->ref_count);
 
-       if (!cnt) {
+       mutex_lock(&par->open_lock);
+       if (!par->ref_count) {
                memset(&par->state, 0, sizeof(struct vgastate));
                par->state.flags = VGA_SAVE_MODE | VGA_SAVE_FONTS;
                save_vga(&par->state);
        }
-       atomic_inc(&par->ref_count);
+       par->ref_count++;
+       mutex_unlock(&par->open_lock);
+
        return 0;
 }
 
@@ -572,14 +572,18 @@ static int
 neofb_release(struct fb_info *info, int user)
 {
        struct neofb_par *par = info->par;
-       int cnt = atomic_read(&par->ref_count);
 
-       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) {
                restore_vga(&par->state);
        }
-       atomic_dec(&par->ref_count);
+       par->ref_count--;
+       mutex_unlock(&par->open_lock);
+
        return 0;
 }
 
@@ -660,6 +664,7 @@ neofb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
        var->red.msb_right = 0;
        var->green.msb_right = 0;
        var->blue.msb_right = 0;
+       var->transp.msb_right = 0;
 
        switch (var->bits_per_pixel) {
        case 8:         /* PSEUDOCOLOUR, 256 */
@@ -1280,34 +1285,36 @@ static int neofb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
        if (regno >= fb->cmap.len || regno > 255)
                return -EINVAL;
 
-       switch (fb->var.bits_per_pixel) {
-       case 8:
+       if (fb->var.bits_per_pixel <= 8) {
                outb(regno, 0x3c8);
 
                outb(red >> 10, 0x3c9);
                outb(green >> 10, 0x3c9);
                outb(blue >> 10, 0x3c9);
-               break;
-       case 16:
-               ((u32 *) fb->pseudo_palette)[regno] =
+       } else if (regno < 16) {
+               switch (fb->var.bits_per_pixel) {
+               case 16:
+                       ((u32 *) fb->pseudo_palette)[regno] =
                                ((red & 0xf800)) | ((green & 0xfc00) >> 5) |
                                ((blue & 0xf800) >> 11);
-               break;
-       case 24:
-               ((u32 *) fb->pseudo_palette)[regno] =
+                       break;
+               case 24:
+                       ((u32 *) fb->pseudo_palette)[regno] =
                                ((red & 0xff00) << 8) | ((green & 0xff00)) |
                                ((blue & 0xff00) >> 8);
-               break;
+                       break;
 #ifdef NO_32BIT_SUPPORT_YET
-       case 32:
-               ((u32 *) fb->pseudo_palette)[regno] =
+               case 32:
+                       ((u32 *) fb->pseudo_palette)[regno] =
                                ((transp & 0xff00) << 16) | ((red & 0xff00) << 8) |
                                ((green & 0xff00)) | ((blue & 0xff00) >> 8);
-               break;
+                       break;
 #endif
-       default:
-               return 1;
+               default:
+                       return 1;
+               }
        }
+
        return 0;
 }
 
@@ -2048,6 +2055,7 @@ static struct fb_info *__devinit neo_alloc_fb_info(struct pci_dev *dev, const st
 
        info->fix.accel = id->driver_data;
 
+       mutex_init(&par->open_lock);
        par->pci_burst = !nopciburst;
        par->lcd_stretch = !nostretch;
        par->libretto = libretto;
@@ -2058,40 +2066,49 @@ static struct fb_info *__devinit neo_alloc_fb_info(struct pci_dev *dev, const st
 
        switch (info->fix.accel) {
        case FB_ACCEL_NEOMAGIC_NM2070:
-               sprintf(info->fix.id, "MagicGraph 128");
+               snprintf(info->fix.id, sizeof(info->fix.id),
+                               "MagicGraph 128");
                break;
        case FB_ACCEL_NEOMAGIC_NM2090:
-               sprintf(info->fix.id, "MagicGraph 128V");
+               snprintf(info->fix.id, sizeof(info->fix.id),
+                               "MagicGraph 128V");
                break;
        case FB_ACCEL_NEOMAGIC_NM2093:
-               sprintf(info->fix.id, "MagicGraph 128ZV");
+               snprintf(info->fix.id, sizeof(info->fix.id),
+                               "MagicGraph 128ZV");
                break;
        case FB_ACCEL_NEOMAGIC_NM2097:
-               sprintf(info->fix.id, "MagicGraph 128ZV+");
+               snprintf(info->fix.id, sizeof(info->fix.id),
+                               "MagicGraph 128ZV+");
                break;
        case FB_ACCEL_NEOMAGIC_NM2160:
-               sprintf(info->fix.id, "MagicGraph 128XD");
+               snprintf(info->fix.id, sizeof(info->fix.id),
+                               "MagicGraph 128XD");
                break;
        case FB_ACCEL_NEOMAGIC_NM2200:
-               sprintf(info->fix.id, "MagicGraph 256AV");
+               snprintf(info->fix.id, sizeof(info->fix.id),
+                               "MagicGraph 256AV");
                info->flags |= FBINFO_HWACCEL_IMAGEBLIT |
                               FBINFO_HWACCEL_COPYAREA |
                               FBINFO_HWACCEL_FILLRECT;
                break;
        case FB_ACCEL_NEOMAGIC_NM2230:
-               sprintf(info->fix.id, "MagicGraph 256AV+");
+               snprintf(info->fix.id, sizeof(info->fix.id),
+                               "MagicGraph 256AV+");
                info->flags |= FBINFO_HWACCEL_IMAGEBLIT |
                               FBINFO_HWACCEL_COPYAREA |
                               FBINFO_HWACCEL_FILLRECT;
                break;
        case FB_ACCEL_NEOMAGIC_NM2360:
-               sprintf(info->fix.id, "MagicGraph 256ZX");
+               snprintf(info->fix.id, sizeof(info->fix.id),
+                               "MagicGraph 256ZX");
                info->flags |= FBINFO_HWACCEL_IMAGEBLIT |
                               FBINFO_HWACCEL_COPYAREA |
                               FBINFO_HWACCEL_FILLRECT;
                break;
        case FB_ACCEL_NEOMAGIC_NM2380:
-               sprintf(info->fix.id, "MagicGraph 256XL+");
+               snprintf(info->fix.id, sizeof(info->fix.id),
+                               "MagicGraph 256XL+");
                info->flags |= FBINFO_HWACCEL_IMAGEBLIT |
                               FBINFO_HWACCEL_COPYAREA |
                               FBINFO_HWACCEL_FILLRECT;