u16 reg16;
u8 reg, reg1;
u8 CR48, CR38;
+ int ret;
+
if (XGIfb_off)
return -ENXIO;
printk("XGIfb: Relocate IO address: %lx [%08lx]\n",
(unsigned long)pci_resource_start(pdev, 2), XGI_Pr.RelIO);
- if (pci_enable_device(pdev))
- return -EIO;
+ if (pci_enable_device(pdev)) {
+ ret = -EIO;
+ goto error;
+ }
XGIRegInit(&XGI_Pr, (unsigned long)XGIhw_ext.pjIOAddress);
if (reg1 != 0xa1) { /*I/O error */
printk("\nXGIfb: I/O error!!!");
- return -EIO;
+ ret = -EIO;
+ goto error;
}
switch (xgi_video_info.chip_id) {
XGIfb_CRT2_write_enable = IND_XGI_CRT2_WRITE_ENABLE_315;
break;
default:
- return -ENODEV;
+ ret = -ENODEV;
+ goto error;
}
printk("XGIfb:chipid = %x\n", xgi_video_info.chip);
XGIhw_ext.pSR = vmalloc(sizeof(struct XGI_DSReg) * SR_BUFFER_SIZE);
if (XGIhw_ext.pSR == NULL) {
printk(KERN_ERR "XGIfb: Fatal error: Allocating SRReg space failed.\n");
- return -ENODEV;
+ ret = -ENODEV;
+ goto error;
}
XGIhw_ext.pSR[0].jIdx = XGIhw_ext.pSR[0].jVal = 0xFF;
if (XGIhw_ext.pCR == NULL) {
vfree(XGIhw_ext.pSR);
printk(KERN_ERR "XGIfb: Fatal error: Allocating CRReg space failed.\n");
- return -ENODEV;
+ ret = -ENODEV;
+ goto error;
}
XGIhw_ext.pCR[0].jIdx = XGIhw_ext.pCR[0].jVal = 0xFF;
vfree(XGIhw_ext.pSR);
vfree(XGIhw_ext.pCR);
printk(KERN_INFO "XGIfb: Fatal error: Unable to determine RAM size.\n");
- return -ENODEV;
+ ret = -ENODEV;
+ goto error;
}
if ((xgifb_mode_idx < 0) || ((XGIbios_mode[xgifb_mode_idx].mode_no) != 0xFF)) {
printk(KERN_ERR "XGIfb: Is there another framebuffer driver active?\n");
vfree(XGIhw_ext.pSR);
vfree(XGIhw_ext.pCR);
- return -ENODEV;
+ ret = -ENODEV;
+ goto error;
}
if (!request_mem_region(xgi_video_info.mmio_base, XGIfb_mmio_size, "XGIfb MMIO")) {
release_mem_region(xgi_video_info.video_base, xgi_video_info.video_size);
vfree(XGIhw_ext.pSR);
vfree(XGIhw_ext.pCR);
- return -ENODEV;
+ ret = -ENODEV;
+ goto error;
}
xgi_video_info.video_vbase = XGIhw_ext.pjVideoMemoryAddress =
printk(KERN_INFO "XGIfb: Added MTRRs\n");
#endif
- if (register_framebuffer(fb_info) < 0)
- return -EINVAL;
+ if (register_framebuffer(fb_info) < 0) {
+ ret = -EINVAL;
+ goto error;
+ }
XGIfb_registered = 1;
dumpVGAReg();
return 0;
+
+error:
+ framebuffer_release(fb_info);
+ return ret;
}
/*****************************************************/