X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fvideo%2Fi810%2Fi810_main.c;h=a24e680d2b9c0f90e3a82f443583b5a03951171d;hb=b691da35ba94d5fa0a32589d99b6546be2bf4cfa;hp=a6ca02f2156a810b03cc91161e1aba4644a7531e;hpb=0612ec48762bf8712db1925b2e67246d2237ebab;p=linux-2.6 diff --git a/drivers/video/i810/i810_main.c b/drivers/video/i810/i810_main.c index a6ca02f215..a24e680d2b 100644 --- a/drivers/video/i810/i810_main.c +++ b/drivers/video/i810/i810_main.c @@ -142,7 +142,7 @@ static int hsync2 __devinitdata; static int vsync1 __devinitdata; static int vsync2 __devinitdata; static int xres __devinitdata; -static int yres __devinitdata; +static int yres; static int vyres __devinitdata; static int sync __devinitdata; static int extvga __devinitdata; @@ -1049,7 +1049,7 @@ static int i810_check_params(struct fb_var_screeninfo *var, mode_valid = 1; if (!mode_valid && info->monspecs.modedb_len) { - struct fb_videomode *mode; + const struct fb_videomode *mode; mode = fb_find_best_mode(var, &info->modelist); if (mode) { @@ -1235,9 +1235,9 @@ static int i810fb_getcolreg(u8 regno, u8 *red, u8 *green, u8 *blue, static int i810fb_open(struct fb_info *info, int user) { struct i810fb_par *par = info->par; - u32 count = atomic_read(&par->use_count); - - if (count == 0) { + + mutex_lock(&par->open_lock); + if (par->use_count == 0) { memset(&par->state, 0, sizeof(struct vgastate)); par->state.flags = VGA_SAVE_CMAP; par->state.vgabase = par->mmio_start_virtual; @@ -1246,7 +1246,8 @@ static int i810fb_open(struct fb_info *info, int user) i810_save_vga_state(par); } - atomic_inc(&par->use_count); + par->use_count++; + mutex_unlock(&par->open_lock); return 0; } @@ -1254,18 +1255,20 @@ static int i810fb_open(struct fb_info *info, int user) static int i810fb_release(struct fb_info *info, int user) { struct i810fb_par *par = info->par; - u32 count; - - count = atomic_read(&par->use_count); - if (count == 0) + + mutex_lock(&par->open_lock); + if (par->use_count == 0) { + mutex_unlock(&par->open_lock); return -EINVAL; + } - if (count == 1) { + if (par->use_count == 1) { i810_restore_vga_state(par); restore_vga(&par->state); } - atomic_dec(&par->use_count); + par->use_count--; + mutex_unlock(&par->open_lock); return 0; } @@ -1473,7 +1476,7 @@ static int i810fb_cursor(struct fb_info *info, struct fb_cursor *cursor) struct i810fb_par *par = info->par; u8 __iomem *mmio = par->mmio_start_virtual; - if (!par->dev_flags & LOCKUP) + if (par->dev_flags & LOCKUP) return -ENXIO; if (cursor->image.width > 64 || cursor->image.height > 64) @@ -1554,15 +1557,17 @@ static struct fb_ops i810fb_ops __devinitdata = { /*********************************************************************** * Power Management * ***********************************************************************/ -static int i810fb_suspend(struct pci_dev *dev, pm_message_t state) +static int i810fb_suspend(struct pci_dev *dev, pm_message_t mesg) { struct fb_info *info = pci_get_drvdata(dev); struct i810fb_par *par = info->par; - par->cur_state = state.event; + par->cur_state = mesg.event; - if (state.event == PM_EVENT_FREEZE) { - dev->dev.power.power_state = state; + switch (mesg.event) { + case PM_EVENT_FREEZE: + case PM_EVENT_PRETHAW: + dev->dev.power.power_state = mesg; return 0; } @@ -1578,7 +1583,7 @@ static int i810fb_suspend(struct pci_dev *dev, pm_message_t state) pci_save_state(dev); pci_disable_device(dev); - pci_set_power_state(dev, pci_choose_state(dev, state)); + pci_set_power_state(dev, pci_choose_state(dev, mesg)); release_console_sem(); return 0; @@ -1600,7 +1605,10 @@ static int i810fb_resume(struct pci_dev *dev) acquire_console_sem(); pci_set_power_state(dev, PCI_D0); pci_restore_state(dev); - pci_enable_device(dev); + + if (pci_enable_device(dev)) + goto fail; + pci_set_master(dev); agp_bind_memory(par->i810_gtt.i810_fb_memory, par->fb.offset); @@ -1609,6 +1617,7 @@ static int i810fb_resume(struct pci_dev *dev) i810fb_set_par(info); fb_set_suspend (info, 0); info->fbops->fb_blank(VESA_NO_BLANKING, info); +fail: release_console_sem(); return 0; } @@ -1708,7 +1717,7 @@ static int __devinit i810_alloc_agp_mem(struct fb_info *info) * @info: pointer to device specific info structure * * DESCRIPTION: - * Sets the the user monitor's horizontal and vertical + * Sets the user monitor's horizontal and vertical * frequency limits */ static void __devinit i810_init_monspecs(struct fb_info *info) @@ -1746,6 +1755,8 @@ static void __devinit i810_init_monspecs(struct fb_info *info) static void __devinit i810_init_defaults(struct i810fb_par *par, struct fb_info *info) { + mutex_init(&par->open_lock); + if (voffset) v_offset_default = voffset; else if (par->aperture.size > 32 * 1024 * 1024) @@ -1913,7 +1924,7 @@ static void __devinit i810fb_find_init_mode(struct fb_info *info) fb_videomode_to_modelist(specs->modedb, specs->modedb_len, &info->modelist); if (specs->modedb != NULL) { - struct fb_videomode *m; + const struct fb_videomode *m; if (xres && yres) { if ((m = fb_find_best_mode(&var, &info->modelist))) { @@ -2010,11 +2021,10 @@ static int __devinit i810fb_init_pci (struct pci_dev *dev, par = info->par; par->dev = dev; - if (!(info->pixmap.addr = kmalloc(8*1024, GFP_KERNEL))) { + if (!(info->pixmap.addr = kzalloc(8*1024, GFP_KERNEL))) { i810fb_release_resource(info, par); return -ENOMEM; } - memset(info->pixmap.addr, 0, 8*1024); info->pixmap.size = 8*1024; info->pixmap.buf_align = 8; info->pixmap.access_align = 32;