drivers/block/floppy.c: remove used once CHECK_READY macro
[safe/jmp/linux-2.6] / drivers / video / cg3.c
index 5741b46..b2319fa 100644 (file)
 #include <linux/init.h>
 #include <linux/fb.h>
 #include <linux/mm.h>
+#include <linux/of_device.h>
 
 #include <asm/io.h>
-#include <asm/oplib.h>
-#include <asm/prom.h>
-#include <asm/of_device.h>
 #include <asm/fbio.h>
 
 #include "sbuslib.h"
@@ -120,9 +118,7 @@ struct cg3_par {
 #define CG3_FLAG_BLANKED       0x00000001
 #define CG3_FLAG_RDI           0x00000002
 
-       unsigned long           physbase;
        unsigned long           which_io;
-       unsigned long           fbsize;
 };
 
 /**
@@ -233,17 +229,15 @@ static int cg3_mmap(struct fb_info *info, struct vm_area_struct *vma)
        struct cg3_par *par = (struct cg3_par *)info->par;
 
        return sbusfb_mmap_helper(cg3_mmap_map,
-                                 par->physbase, par->fbsize,
+                                 info->fix.smem_start, info->fix.smem_len,
                                  par->which_io,
                                  vma);
 }
 
 static int cg3_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg)
 {
-       struct cg3_par *par = (struct cg3_par *) info->par;
-
        return sbusfb_ioctl_helper(cmd, arg, info,
-                                  FBTYPE_SUN3COLOR, 8, par->fbsize);
+                                  FBTYPE_SUN3COLOR, 8, info->fix.smem_len);
 }
 
 /*
@@ -315,7 +309,7 @@ static u_char cg3_dacvals[] __devinitdata = {
        4, 0xff,        5, 0x00,        6, 0x70,        7, 0x00,        0
 };
 
-static void __devinit cg3_do_default_mode(struct cg3_par *par)
+static int __devinit cg3_do_default_mode(struct cg3_par *par)
 {
        enum cg3_type type;
        u8 *p;
@@ -332,10 +326,9 @@ static void __devinit cg3_do_default_mode(struct cg3_par *par)
                        else
                                type = CG3_AT_66HZ;
                } else {
-                       prom_printf("cgthree: can't handle SR %02x\n",
-                                   status);
-                       prom_halt();
-                       return;
+                       printk(KERN_ERR "cgthree: can't handle SR %02x\n",
+                              status);
+                       return -EINVAL;
                }
        }
 
@@ -351,6 +344,7 @@ static void __devinit cg3_do_default_mode(struct cg3_par *par)
                regp = (u8 __iomem *)&par->regs->cmap.control;
                sbus_writeb(p[1], regp);
        }
+       return 0;
 }
 
 static int __devinit cg3_probe(struct of_device *op,
@@ -370,10 +364,10 @@ static int __devinit cg3_probe(struct of_device *op,
 
        spin_lock_init(&par->lock);
 
-       par->physbase = op->resource[0].start;
+       info->fix.smem_start = op->resource[0].start;
        par->which_io = op->resource[0].flags & IORESOURCE_BITS;
 
-       sbusfb_fill_var(&info->var, dp->node, 8);
+       sbusfb_fill_var(&info->var, dp, 8);
        info->var.red.length = 8;
        info->var.green.length = 8;
        info->var.blue.length = 8;
@@ -384,7 +378,7 @@ static int __devinit cg3_probe(struct of_device *op,
 
        linebytes = of_getintprop_default(dp, "linebytes",
                                          info->var.xres);
-       par->fbsize = PAGE_ALIGN(linebytes * info->var.yres);
+       info->fix.smem_len = PAGE_ALIGN(linebytes * info->var.yres);
 
        par->regs = of_ioremap(&op->resource[0], CG3_REGS_OFFSET,
                               sizeof(struct cg3_regs), "cg3 regs");
@@ -394,14 +388,17 @@ static int __devinit cg3_probe(struct of_device *op,
        info->flags = FBINFO_DEFAULT;
        info->fbops = &cg3_ops;
        info->screen_base = of_ioremap(&op->resource[0], CG3_RAM_OFFSET,
-                                      par->fbsize, "cg3 ram");
+                                      info->fix.smem_len, "cg3 ram");
        if (!info->screen_base)
                goto out_unmap_regs;
 
-       cg3_blank(0, info);
+       cg3_blank(FB_BLANK_UNBLANK, info);
 
-       if (!of_find_property(dp, "width", NULL))
-               cg3_do_default_mode(par);
+       if (!of_find_property(dp, "width", NULL)) {
+               err = cg3_do_default_mode(par);
+               if (err)
+                       goto out_unmap_screen;
+       }
 
        if (fb_alloc_cmap(&info->cmap, 256, 0))
                goto out_unmap_screen;
@@ -416,8 +413,8 @@ static int __devinit cg3_probe(struct of_device *op,
 
        dev_set_drvdata(&op->dev, info);
 
-       printk("%s: cg3 at %lx:%lx\n",
-              dp->full_name, par->which_io, par->physbase);
+       printk(KERN_INFO "%s: cg3 at %lx:%lx\n",
+              dp->full_name, par->which_io, info->fix.smem_start);
 
        return 0;
 
@@ -425,7 +422,7 @@ out_dealloc_cmap:
        fb_dealloc_cmap(&info->cmap);
 
 out_unmap_screen:
-       of_iounmap(&op->resource[0], info->screen_base, par->fbsize);
+       of_iounmap(&op->resource[0], info->screen_base, info->fix.smem_len);
 
 out_unmap_regs:
        of_iounmap(&op->resource[0], par->regs, sizeof(struct cg3_regs));
@@ -446,7 +443,7 @@ static int __devexit cg3_remove(struct of_device *op)
        fb_dealloc_cmap(&info->cmap);
 
        of_iounmap(&op->resource[0], par->regs, sizeof(struct cg3_regs));
-       of_iounmap(&op->resource[0], info->screen_base, par->fbsize);
+       of_iounmap(&op->resource[0], info->screen_base, info->fix.smem_len);
 
        framebuffer_release(info);
 
@@ -455,7 +452,7 @@ static int __devexit cg3_remove(struct of_device *op)
        return 0;
 }
 
-static struct of_device_id cg3_match[] = {
+static const struct of_device_id cg3_match[] = {
        {
                .name = "cgthree",
        },