@@ -369,40 +369,50 @@ int __init valkyriefb_init(void)
}
p->total_vram = 0x100000;
p->frame_buffer_phys = frame_buffer_phys;
+ err = -ENOMEM;
p->frame_buffer = __ioremap(frame_buffer_phys, p->total_vram, flags);
+ if (p->frame_buffer == NULL) {
+ pr_err("%s: %s failed\n", __func__, "Frame buffer mapping");
+ goto free_memory;
+ }
p->cmap_regs_phys = cmap_regs_phys;
p->cmap_regs = ioremap(p->cmap_regs_phys, 0x1000);
+ if (p->cmap_regs == NULL) {
+ pr_err("%s: %s failed\n", __func__, "cmap");
+ goto io_unmap_framebuffer;
+ }
p->valkyrie_regs_phys = cmap_regs_phys+0x6000;
p->valkyrie_regs = ioremap(p->valkyrie_regs_phys, 0x1000);
- err = -ENOMEM;
- if (p->frame_buffer == NULL || p->cmap_regs == NULL
- || p->valkyrie_regs == NULL) {
- printk(KERN_ERR "valkyriefb: couldn't map resources\n");
- goto out_free;
+ if (p->valkyrie_regs == NULL) {
+ pr_err("%s: %s failed\n", __func__, "ioremap");
+ goto io_unmap_cmap;
}
valkyrie_choose_mode(p);
mac_vmode_to_var(default_vmode, default_cmode, &p->info.var);
err = valkyrie_init_info(&p->info, p);
if (err < 0)
- goto out_free;
+ goto io_unmap_valkyrie;
valkyrie_init_fix(&p->info.fix, p);
if (valkyriefb_set_par(&p->info))
/* "can't happen" */
printk(KERN_ERR "valkyriefb: can't set default video mode\n");
if ((err = register_framebuffer(&p->info)) != 0)
- goto out_cmap_free;
+ goto dealloc_cmap;
fb_info(&p->info, "valkyrie frame buffer device\n");
return 0;
- out_cmap_free:
+dealloc_cmap:
fb_dealloc_cmap(&p->info.cmap);
- out_free:
- iounmap(p->frame_buffer);
- iounmap(p->cmap_regs);
+io_unmap_valkyrie:
iounmap(p->valkyrie_regs);
+io_unmap_cmap:
+ iounmap(p->cmap_regs);
+io_unmap_framebuffer:
+ iounmap(p->frame_buffer);
+free_memory:
kfree(p);
return err;
}