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) ...@@ -1974,7 +1974,7 @@ int __init atyfb_do_init(void)
info->fix = atyfb_fix; info->fix = atyfb_fix;
info->par = default_par; info->par = default_par;
info->device = &pdev->dev;
#ifdef __sparc__ #ifdef __sparc__
/* /*
* Map memory-mapped registers. * Map memory-mapped registers.
......
...@@ -416,7 +416,7 @@ chipsfb_pci_init(struct pci_dev *dp, const struct pci_device_id *ent) ...@@ -416,7 +416,7 @@ chipsfb_pci_init(struct pci_dev *dp, const struct pci_device_id *ent)
release_mem_region(addr, size); release_mem_region(addr, size);
return -ENOMEM; return -ENOMEM;
} }
p->device = &dp->dev;
init_chips(p, addr); init_chips(p, addr);
#ifdef CONFIG_PMAC_PBOOK #ifdef CONFIG_PMAC_PBOOK
......
...@@ -1399,6 +1399,8 @@ static int __devinit cyberpro_common_probe(struct cfb_info *cfb) ...@@ -1399,6 +1399,8 @@ static int __devinit cyberpro_common_probe(struct cfb_info *cfb)
cfb->fb.var.xres, cfb->fb.var.yres, cfb->fb.var.xres, cfb->fb.var.yres,
h_sync / 1000, h_sync % 1000, v_sync); h_sync / 1000, h_sync % 1000, v_sync);
if (cfb->dev)
cfb->fb.device = &cfb->dev->dev;
err = register_framebuffer(&cfb->fb); err = register_framebuffer(&cfb->fb);
failed: failed:
......
...@@ -1141,7 +1141,8 @@ register_framebuffer(struct fb_info *fb_info) ...@@ -1141,7 +1141,8 @@ register_framebuffer(struct fb_info *fb_info)
break; break;
fb_info->node = i; 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)) { if (IS_ERR(c)) {
/* Not fatal */ /* Not fatal */
printk(KERN_WARNING "Unable to create class_device for framebuffer %d; errno = %ld\n", i, PTR_ERR(c)); 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) ...@@ -51,6 +51,8 @@ struct fb_info *framebuffer_alloc(size_t size, struct device *dev)
if (size) if (size)
info->par = p + fb_info_size; info->par = p + fb_info_size;
info->device = dev;
return info; return info;
#undef PADDING #undef PADDING
#undef BYTES_PER_LONG #undef BYTES_PER_LONG
......
...@@ -1855,20 +1855,13 @@ static int __devinit i810fb_init_pci (struct pci_dev *dev, ...@@ -1855,20 +1855,13 @@ static int __devinit i810fb_init_pci (struct pci_dev *dev,
int i, err = -1, vfreq, hfreq, pixclock; int i, err = -1, vfreq, hfreq, pixclock;
i = 0; 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))) { info = framebuffer_alloc(sizeof(struct i810fb_par), &dev->dev);
i810fb_release_resource(info, par); if (!info)
return -ENOMEM; return -ENOMEM;
}
memset(par, 0, sizeof(struct i810fb_par));
par = (struct i810fb_par *) info->par;
par->dev = dev; par->dev = dev;
info->par = par;
if (!(info->pixmap.addr = kmalloc(64*1024, GFP_KERNEL))) { if (!(info->pixmap.addr = kmalloc(64*1024, GFP_KERNEL))) {
i810fb_release_resource(info, par); i810fb_release_resource(info, par);
...@@ -1941,38 +1934,36 @@ static int __devinit i810fb_init_pci (struct pci_dev *dev, ...@@ -1941,38 +1934,36 @@ static int __devinit i810fb_init_pci (struct pci_dev *dev,
static void i810fb_release_resource(struct fb_info *info, static void i810fb_release_resource(struct fb_info *info,
struct i810fb_par *par) struct i810fb_par *par)
{ {
if (par) { unset_mtrr(par);
unset_mtrr(par); if (par->drm_agp) {
if (par->drm_agp) { drm_agp_t *agp = par->drm_agp;
drm_agp_t *agp = par->drm_agp; struct gtt_data *gtt = &par->i810_gtt;
struct gtt_data *gtt = &par->i810_gtt;
if (par->i810_gtt.i810_cursor_memory)
if (par->i810_gtt.i810_cursor_memory) agp->free_memory(gtt->i810_cursor_memory);
agp->free_memory(gtt->i810_cursor_memory); if (par->i810_gtt.i810_fb_memory)
if (par->i810_gtt.i810_fb_memory) agp->free_memory(gtt->i810_fb_memory);
agp->free_memory(gtt->i810_fb_memory);
inter_module_put("drm_agp");
inter_module_put("drm_agp"); par->drm_agp = NULL;
par->drm_agp = NULL; }
}
if (par->mmio_start_virtual) if (par->mmio_start_virtual)
iounmap(par->mmio_start_virtual); iounmap(par->mmio_start_virtual);
if (par->aperture.virtual) if (par->aperture.virtual)
iounmap(par->aperture.virtual); iounmap(par->aperture.virtual);
if (par->res_flags & FRAMEBUFFER_REQ) if (par->res_flags & FRAMEBUFFER_REQ)
release_mem_region(par->aperture.physical, release_mem_region(par->aperture.physical,
par->aperture.size); par->aperture.size);
if (par->res_flags & MMIO_REQ) if (par->res_flags & MMIO_REQ)
release_mem_region(par->mmio_start_phys, MMIO_SIZE); release_mem_region(par->mmio_start_phys, MMIO_SIZE);
if (par->res_flags & PCI_DEVICE_ENABLED) if (par->res_flags & PCI_DEVICE_ENABLED)
pci_disable_device(par->dev); pci_disable_device(par->dev);
framebuffer_release(info);
kfree(par);
}
kfree(info);
} }
static void __exit i810fb_remove_pci(struct pci_dev *dev) static void __exit i810fb_remove_pci(struct pci_dev *dev)
......
...@@ -531,6 +531,7 @@ int __init igafb_init(void) ...@@ -531,6 +531,7 @@ int __init igafb_init(void)
info->var = default_var; info->var = default_var;
info->fix = igafb_fix; info->fix = igafb_fix;
info->pseudo_palette = (void *)(par + 1); info->pseudo_palette = (void *)(par + 1);
info->device = &pdev->dev;
if (!iga_init(info, par)) { if (!iga_init(info, par)) {
iounmap((void *)par->io_base); iounmap((void *)par->io_base);
......
...@@ -1524,6 +1524,7 @@ imsttfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1524,6 +1524,7 @@ imsttfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
par->cmap_regs = (__u8 *)ioremap(addr + 0x840000, 0x1000); par->cmap_regs = (__u8 *)ioremap(addr + 0x840000, 0x1000);
info->par = par; info->par = par;
info->pseudo_palette = (void *) (par + 1); info->pseudo_palette = (void *) (par + 1);
info->device = &pdev->dev;
init_imstt(info); init_imstt(info);
pci_set_drvdata(pdev, info); pci_set_drvdata(pdev, info);
......
...@@ -735,6 +735,7 @@ static int __devinit kyrofb_probe(struct pci_dev *pdev, ...@@ -735,6 +735,7 @@ static int __devinit kyrofb_probe(struct pci_dev *pdev,
fb_memset(info->screen_base, 0, size); fb_memset(info->screen_base, 0, size);
info->device = &pdev->dev;
if (register_framebuffer(info) < 0) if (register_framebuffer(info) < 0)
goto out_unmap; goto out_unmap;
......
...@@ -1864,6 +1864,7 @@ static int initMatrox2(WPMINFO struct board* b){ ...@@ -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 /* 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 */ * 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) { if (register_framebuffer(&ACCESS_FBINFO(fbcon)) < 0) {
goto failVideoIO; goto failVideoIO;
} }
......
...@@ -939,6 +939,7 @@ static int __devinit pvr2fb_pci_probe(struct pci_dev *pdev, ...@@ -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_start = pci_resource_start(pdev, 1);
pvr2_fix.mmio_len = pci_resource_len(pdev, 1); pvr2_fix.mmio_len = pci_resource_len(pdev, 1);
fbinfo->device = &pdev->dev;
return pvr2fb_common_init(); return pvr2fb_common_init();
} }
......
...@@ -3040,7 +3040,7 @@ static int radeonfb_pci_register (struct pci_dev *pdev, ...@@ -3040,7 +3040,7 @@ static int radeonfb_pci_register (struct pci_dev *pdev,
pci_set_drvdata(pdev, rinfo); pci_set_drvdata(pdev, rinfo);
rinfo->next = board_list; rinfo->next = board_list;
board_list = rinfo; board_list = rinfo;
((struct fb_info *) rinfo)->device = &pdev->dev;
if (register_framebuffer ((struct fb_info *) rinfo) < 0) { if (register_framebuffer ((struct fb_info *) rinfo) < 0) {
printk ("radeonfb: could not register framebuffer\n"); printk ("radeonfb: could not register framebuffer\n");
iounmap(rinfo->fb_base); iounmap(rinfo->fb_base);
......
...@@ -1858,21 +1858,17 @@ static int __devinit rivafb_probe(struct pci_dev *pd, ...@@ -1858,21 +1858,17 @@ static int __devinit rivafb_probe(struct pci_dev *pd,
NVTRACE_ENTER(); NVTRACE_ENTER();
assert(pd != NULL); assert(pd != NULL);
info = kmalloc(sizeof(struct fb_info), GFP_KERNEL); info = framebuffer_alloc(sizeof(struct riva_par), &pd->dev);
if (!info) if (!info)
goto err_out; goto err_out;
default_par = kmalloc(sizeof(struct riva_par), GFP_KERNEL); default_par = (struct riva_par *) info->par;
if (!default_par)
goto err_out_kfree;
memset(info, 0, sizeof(struct fb_info));
memset(default_par, 0, sizeof(struct riva_par));
default_par->pdev = pd; default_par->pdev = pd;
info->pixmap.addr = kmalloc(64 * 1024, GFP_KERNEL); info->pixmap.addr = kmalloc(64 * 1024, GFP_KERNEL);
if (info->pixmap.addr == NULL) if (info->pixmap.addr == NULL)
goto err_out_kfree1; goto err_out_kfree;
memset(info->pixmap.addr, 0, 64 * 1024); memset(info->pixmap.addr, 0, 64 * 1024);
if (pci_enable_device(pd)) { if (pci_enable_device(pd)) {
...@@ -1896,7 +1892,7 @@ static int __devinit rivafb_probe(struct pci_dev *pd, ...@@ -1896,7 +1892,7 @@ static int __devinit rivafb_probe(struct pci_dev *pd,
if(default_par->riva.Architecture == 0) { if(default_par->riva.Architecture == 0) {
printk(KERN_ERR PFX "unknown NV_ARCH\n"); 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 || if(default_par->riva.Architecture == NV_ARCH_10 ||
default_par->riva.Architecture == NV_ARCH_20 || default_par->riva.Architecture == NV_ARCH_20 ||
...@@ -2001,7 +1997,6 @@ static int __devinit rivafb_probe(struct pci_dev *pd, ...@@ -2001,7 +1997,6 @@ static int __devinit rivafb_probe(struct pci_dev *pd,
fb_destroy_modedb(info->monspecs.modedb); fb_destroy_modedb(info->monspecs.modedb);
info->monspecs.modedb_len = 0; info->monspecs.modedb_len = 0;
info->monspecs.modedb = NULL; info->monspecs.modedb = NULL;
if (register_framebuffer(info) < 0) { if (register_framebuffer(info) < 0) {
printk(KERN_ERR PFX printk(KERN_ERR PFX
"error registering riva framebuffer\n"); "error registering riva framebuffer\n");
...@@ -2040,10 +2035,8 @@ static int __devinit rivafb_probe(struct pci_dev *pd, ...@@ -2040,10 +2035,8 @@ static int __devinit rivafb_probe(struct pci_dev *pd,
pci_disable_device(pd); pci_disable_device(pd);
err_out_enable: err_out_enable:
kfree(info->pixmap.addr); kfree(info->pixmap.addr);
err_out_kfree1:
kfree(default_par);
err_out_kfree: err_out_kfree:
kfree(info); framebuffer_release(info);
err_out: err_out:
return -ENODEV; return -ENODEV;
} }
...@@ -2077,8 +2070,7 @@ static void __exit rivafb_remove(struct pci_dev *pd) ...@@ -2077,8 +2070,7 @@ static void __exit rivafb_remove(struct pci_dev *pd)
pci_release_regions(pd); pci_release_regions(pd);
pci_disable_device(pd); pci_disable_device(pd);
kfree(info->pixmap.addr); kfree(info->pixmap.addr);
kfree(par); framebuffer_release(info);
kfree(info);
pci_set_drvdata(pd, NULL); pci_set_drvdata(pd, NULL);
NVTRACE_LEAVE(); NVTRACE_LEAVE();
} }
......
...@@ -1507,6 +1507,7 @@ static int __devinit sstfb_probe(struct pci_dev *pdev, ...@@ -1507,6 +1507,7 @@ static int __devinit sstfb_probe(struct pci_dev *pdev,
fb_alloc_cmap(&info->cmap, 256, 0); fb_alloc_cmap(&info->cmap, 256, 0);
/* register fb */ /* register fb */
info->device = &pdev->dev;
if (register_framebuffer(info) < 0) { if (register_framebuffer(info) < 0) {
eprintk("can't register framebuffer.\n"); eprintk("can't register framebuffer.\n");
goto fail; goto fail;
......
...@@ -1454,6 +1454,7 @@ tgafb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1454,6 +1454,7 @@ tgafb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent)
tgafb_set_par(&all->info); tgafb_set_par(&all->info);
tgafb_init_fix(&all->info); tgafb_init_fix(&all->info);
all->info.device = &pdev->dev;
if (register_framebuffer(&all->info) < 0) { if (register_framebuffer(&all->info) < 0) {
printk(KERN_ERR "tgafb: Could not register framebuffer\n"); printk(KERN_ERR "tgafb: Could not register framebuffer\n");
ret = -EINVAL; ret = -EINVAL;
......
...@@ -1164,6 +1164,7 @@ static int __devinit trident_pci_probe(struct pci_dev * dev, const struct pci_de ...@@ -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.accel_flags &= ~FB_ACCELF_TEXT;
default_var.activate |= FB_ACTIVATE_NOW; default_var.activate |= FB_ACTIVATE_NOW;
fb_info.var = default_var; fb_info.var = default_var;
fb_info.device = &dev->dev;
if (register_framebuffer(&fb_info) < 0) { if (register_framebuffer(&fb_info) < 0) {
output("Could not register Trident framebuffer\n"); output("Could not register Trident framebuffer\n");
return -EINVAL; return -EINVAL;
......
...@@ -601,6 +601,7 @@ struct fb_info { ...@@ -601,6 +601,7 @@ struct fb_info {
struct fb_cmap cmap; /* Current cmap */ struct fb_cmap cmap; /* Current cmap */
struct list_head modelist; /* mode list */ struct list_head modelist; /* mode list */
struct fb_ops *fbops; struct fb_ops *fbops;
struct device *device;
char __iomem *screen_base; /* Virtual address */ char __iomem *screen_base; /* Virtual address */
unsigned long screen_size; /* Amount of ioremapped VRAM or 0 */ unsigned long screen_size; /* Amount of ioremapped VRAM or 0 */
int currcon; /* Current VC. */ 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