Commit 03f779b6 authored by Antonino Daplas's avatar Antonino Daplas Committed by Linus Torvalds

[PATCH] fbdev: Pass struct device to class_simple_device_add

Swsusp turns off the display when a power-management-enabled framebuffer
driver is used.  According to Nigel Cunningham <ncunningham@linuxmail.org>,
the fix may involve the following:

"...I thought the best approach would be to use device classes to find the
struct dev for the frame buffer driver, and then use the same code I use for
storage devices to avoid suspending the frame buffer until later..."

Changes:

- pass info->device to class_simple_device_add()
- add struct device *device to struct fb_info
- store struct device in framebuffer_alloc()
- for drivers not using framebuffer_alloc(), store the struct during
  initalization
- port i810fb and rivafb to use framebuffer_alloc()
Signed-off-by: default avatarAntonino Daplas <adaplas@pol.net>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 899a94d1
......@@ -1974,7 +1974,7 @@ int __init atyfb_do_init(void)
info->fix = atyfb_fix;
info->par = default_par;
info->device = &pdev->dev;
#ifdef __sparc__
/*
* Map memory-mapped registers.
......
......@@ -416,7 +416,7 @@ chipsfb_pci_init(struct pci_dev *dp, const struct pci_device_id *ent)
release_mem_region(addr, size);
return -ENOMEM;
}
p->device = &dp->dev;
init_chips(p, addr);
#ifdef CONFIG_PMAC_PBOOK
......
......@@ -1399,6 +1399,8 @@ static int __devinit cyberpro_common_probe(struct cfb_info *cfb)
cfb->fb.var.xres, cfb->fb.var.yres,
h_sync / 1000, h_sync % 1000, v_sync);
if (cfb->dev)
cfb->fb.device = &cfb->dev->dev;
err = register_framebuffer(&cfb->fb);
failed:
......
......@@ -1141,7 +1141,8 @@ register_framebuffer(struct fb_info *fb_info)
break;
fb_info->node = i;
c = class_simple_device_add(fb_class, MKDEV(FB_MAJOR, i), NULL, "fb%d", i);
c = class_simple_device_add(fb_class, MKDEV(FB_MAJOR, i),
fb_info->device, "fb%d", i);
if (IS_ERR(c)) {
/* Not fatal */
printk(KERN_WARNING "Unable to create class_device for framebuffer %d; errno = %ld\n", i, PTR_ERR(c));
......
......@@ -51,6 +51,8 @@ struct fb_info *framebuffer_alloc(size_t size, struct device *dev)
if (size)
info->par = p + fb_info_size;
info->device = dev;
return info;
#undef PADDING
#undef BYTES_PER_LONG
......
......@@ -1855,20 +1855,13 @@ static int __devinit i810fb_init_pci (struct pci_dev *dev,
int i, err = -1, vfreq, hfreq, pixclock;
i = 0;
if (!(info = kmalloc(sizeof(struct fb_info), GFP_KERNEL))) {
i810fb_release_resource(info, par);
return -ENOMEM;
}
memset(info, 0, sizeof(struct fb_info));
if(!(par = kmalloc(sizeof(struct i810fb_par), GFP_KERNEL))) {
i810fb_release_resource(info, par);
info = framebuffer_alloc(sizeof(struct i810fb_par), &dev->dev);
if (!info)
return -ENOMEM;
}
memset(par, 0, sizeof(struct i810fb_par));
par = (struct i810fb_par *) info->par;
par->dev = dev;
info->par = par;
if (!(info->pixmap.addr = kmalloc(64*1024, GFP_KERNEL))) {
i810fb_release_resource(info, par);
......@@ -1941,38 +1934,36 @@ static int __devinit i810fb_init_pci (struct pci_dev *dev,
static void i810fb_release_resource(struct fb_info *info,
struct i810fb_par *par)
{
if (par) {
unset_mtrr(par);
if (par->drm_agp) {
drm_agp_t *agp = par->drm_agp;
struct gtt_data *gtt = &par->i810_gtt;
if (par->i810_gtt.i810_cursor_memory)
agp->free_memory(gtt->i810_cursor_memory);
if (par->i810_gtt.i810_fb_memory)
agp->free_memory(gtt->i810_fb_memory);
inter_module_put("drm_agp");
par->drm_agp = NULL;
}
unset_mtrr(par);
if (par->drm_agp) {
drm_agp_t *agp = par->drm_agp;
struct gtt_data *gtt = &par->i810_gtt;
if (par->i810_gtt.i810_cursor_memory)
agp->free_memory(gtt->i810_cursor_memory);
if (par->i810_gtt.i810_fb_memory)
agp->free_memory(gtt->i810_fb_memory);
inter_module_put("drm_agp");
par->drm_agp = NULL;
}
if (par->mmio_start_virtual)
iounmap(par->mmio_start_virtual);
if (par->aperture.virtual)
iounmap(par->aperture.virtual);
if (par->mmio_start_virtual)
iounmap(par->mmio_start_virtual);
if (par->aperture.virtual)
iounmap(par->aperture.virtual);
if (par->res_flags & FRAMEBUFFER_REQ)
release_mem_region(par->aperture.physical,
par->aperture.size);
if (par->res_flags & MMIO_REQ)
release_mem_region(par->mmio_start_phys, MMIO_SIZE);
if (par->res_flags & FRAMEBUFFER_REQ)
release_mem_region(par->aperture.physical,
par->aperture.size);
if (par->res_flags & MMIO_REQ)
release_mem_region(par->mmio_start_phys, MMIO_SIZE);
if (par->res_flags & PCI_DEVICE_ENABLED)
pci_disable_device(par->dev);
if (par->res_flags & PCI_DEVICE_ENABLED)
pci_disable_device(par->dev);
framebuffer_release(info);
kfree(par);
}
kfree(info);
}
static void __exit i810fb_remove_pci(struct pci_dev *dev)
......
......@@ -531,6 +531,7 @@ int __init igafb_init(void)
info->var = default_var;
info->fix = igafb_fix;
info->pseudo_palette = (void *)(par + 1);
info->device = &pdev->dev;
if (!iga_init(info, par)) {
iounmap((void *)par->io_base);
......
......@@ -1524,6 +1524,7 @@ imsttfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
par->cmap_regs = (__u8 *)ioremap(addr + 0x840000, 0x1000);
info->par = par;
info->pseudo_palette = (void *) (par + 1);
info->device = &pdev->dev;
init_imstt(info);
pci_set_drvdata(pdev, info);
......
......@@ -735,6 +735,7 @@ static int __devinit kyrofb_probe(struct pci_dev *pdev,
fb_memset(info->screen_base, 0, size);
info->device = &pdev->dev;
if (register_framebuffer(info) < 0)
goto out_unmap;
......
......@@ -1864,6 +1864,7 @@ static int initMatrox2(WPMINFO struct board* b){
/* We do not have to set currcon to 0... register_framebuffer do it for us on first console
* and we do not want currcon == 0 for subsequent framebuffers */
ACCESS_FBINFO(fbcon).device = &ACCESS_FBINFO(pcidev)->dev;
if (register_framebuffer(&ACCESS_FBINFO(fbcon)) < 0) {
goto failVideoIO;
}
......
......@@ -939,6 +939,7 @@ static int __devinit pvr2fb_pci_probe(struct pci_dev *pdev,
pvr2_fix.mmio_start = pci_resource_start(pdev, 1);
pvr2_fix.mmio_len = pci_resource_len(pdev, 1);
fbinfo->device = &pdev->dev;
return pvr2fb_common_init();
}
......
......@@ -3040,7 +3040,7 @@ static int radeonfb_pci_register (struct pci_dev *pdev,
pci_set_drvdata(pdev, rinfo);
rinfo->next = board_list;
board_list = rinfo;
((struct fb_info *) rinfo)->device = &pdev->dev;
if (register_framebuffer ((struct fb_info *) rinfo) < 0) {
printk ("radeonfb: could not register framebuffer\n");
iounmap(rinfo->fb_base);
......
......@@ -1858,21 +1858,17 @@ static int __devinit rivafb_probe(struct pci_dev *pd,
NVTRACE_ENTER();
assert(pd != NULL);
info = kmalloc(sizeof(struct fb_info), GFP_KERNEL);
info = framebuffer_alloc(sizeof(struct riva_par), &pd->dev);
if (!info)
goto err_out;
default_par = kmalloc(sizeof(struct riva_par), GFP_KERNEL);
if (!default_par)
goto err_out_kfree;
memset(info, 0, sizeof(struct fb_info));
memset(default_par, 0, sizeof(struct riva_par));
default_par = (struct riva_par *) info->par;
default_par->pdev = pd;
info->pixmap.addr = kmalloc(64 * 1024, GFP_KERNEL);
if (info->pixmap.addr == NULL)
goto err_out_kfree1;
goto err_out_kfree;
memset(info->pixmap.addr, 0, 64 * 1024);
if (pci_enable_device(pd)) {
......@@ -1896,7 +1892,7 @@ static int __devinit rivafb_probe(struct pci_dev *pd,
if(default_par->riva.Architecture == 0) {
printk(KERN_ERR PFX "unknown NV_ARCH\n");
goto err_out_kfree1;
goto err_out_free_base0;
}
if(default_par->riva.Architecture == NV_ARCH_10 ||
default_par->riva.Architecture == NV_ARCH_20 ||
......@@ -2001,7 +1997,6 @@ static int __devinit rivafb_probe(struct pci_dev *pd,
fb_destroy_modedb(info->monspecs.modedb);
info->monspecs.modedb_len = 0;
info->monspecs.modedb = NULL;
if (register_framebuffer(info) < 0) {
printk(KERN_ERR PFX
"error registering riva framebuffer\n");
......@@ -2040,10 +2035,8 @@ static int __devinit rivafb_probe(struct pci_dev *pd,
pci_disable_device(pd);
err_out_enable:
kfree(info->pixmap.addr);
err_out_kfree1:
kfree(default_par);
err_out_kfree:
kfree(info);
framebuffer_release(info);
err_out:
return -ENODEV;
}
......@@ -2077,8 +2070,7 @@ static void __exit rivafb_remove(struct pci_dev *pd)
pci_release_regions(pd);
pci_disable_device(pd);
kfree(info->pixmap.addr);
kfree(par);
kfree(info);
framebuffer_release(info);
pci_set_drvdata(pd, NULL);
NVTRACE_LEAVE();
}
......
......@@ -1507,6 +1507,7 @@ static int __devinit sstfb_probe(struct pci_dev *pdev,
fb_alloc_cmap(&info->cmap, 256, 0);
/* register fb */
info->device = &pdev->dev;
if (register_framebuffer(info) < 0) {
eprintk("can't register framebuffer.\n");
goto fail;
......
......@@ -1454,6 +1454,7 @@ tgafb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent)
tgafb_set_par(&all->info);
tgafb_init_fix(&all->info);
all->info.device = &pdev->dev;
if (register_framebuffer(&all->info) < 0) {
printk(KERN_ERR "tgafb: Could not register framebuffer\n");
ret = -EINVAL;
......
......@@ -1164,6 +1164,7 @@ static int __devinit trident_pci_probe(struct pci_dev * dev, const struct pci_de
default_var.accel_flags &= ~FB_ACCELF_TEXT;
default_var.activate |= FB_ACTIVATE_NOW;
fb_info.var = default_var;
fb_info.device = &dev->dev;
if (register_framebuffer(&fb_info) < 0) {
output("Could not register Trident framebuffer\n");
return -EINVAL;
......
......@@ -601,6 +601,7 @@ struct fb_info {
struct fb_cmap cmap; /* Current cmap */
struct list_head modelist; /* mode list */
struct fb_ops *fbops;
struct device *device;
char __iomem *screen_base; /* Virtual address */
unsigned long screen_size; /* Amount of ioremapped VRAM or 0 */
int currcon; /* Current VC. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment