V4L/DVB: media/IR/imon: precendence issue: ! vs ==
[safe/jmp/linux-2.6] / drivers / video / tcx.c
index e5a9ddb..c0c2b18 100644 (file)
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/string.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/fb.h>
 #include <linux/mm.h>
+#include <linux/of_device.h>
 
 #include <asm/io.h>
-#include <asm/prom.h>
-#include <asm/of_device.h>
 #include <asm/fbio.h>
 
 #include "sbuslib.h"
@@ -84,7 +82,7 @@ struct tcx_tec {
 
 struct tcx_thc {
        u32 thc_rev;
-        u32 thc_pad0[511];
+       u32 thc_pad0[511];
        u32 thc_hs;             /* hsync timing */
        u32 thc_hsdvs;
        u32 thc_hd;
@@ -117,40 +115,39 @@ struct tcx_par {
        u32                     flags;
 #define TCX_FLAG_BLANKED       0x00000001
 
-       unsigned long           physbase;
        unsigned long           which_io;
-       unsigned long           fbsize;
 
        struct sbus_mmap_map    mmap_map[TCX_MMAP_ENTRIES];
        int                     lowdepth;
 };
 
 /* Reset control plane so that WID is 8-bit plane. */
-static void __tcx_set_control_plane (struct tcx_par *par)
+static void __tcx_set_control_plane(struct fb_info *info)
 {
+       struct tcx_par *par = info->par;
        u32 __iomem *p, *pend;
-        
+
        if (par->lowdepth)
                return;
 
        p = par->cplane;
        if (p == NULL)
                return;
-       for (pend = p + par->fbsize; p < pend; p++) {
+       for (pend = p + info->fix.smem_len; p < pend; p++) {
                u32 tmp = sbus_readl(p);
 
                tmp &= 0xffffff;
                sbus_writel(tmp, p);
        }
 }
-                                                
-static void tcx_reset (struct fb_info *info)
+
+static void tcx_reset(struct fb_info *info)
 {
        struct tcx_par *par = (struct tcx_par *) info->par;
        unsigned long flags;
 
        spin_lock_irqsave(&par->lock, flags);
-       __tcx_set_control_plane(par);
+       __tcx_set_control_plane(info);
        spin_unlock_irqrestore(&par->lock, flags);
 }
 
@@ -305,7 +302,7 @@ static int tcx_mmap(struct fb_info *info, struct vm_area_struct *vma)
        struct tcx_par *par = (struct tcx_par *)info->par;
 
        return sbusfb_mmap_helper(par->mmap_map,
-                                 par->physbase, par->fbsize,
+                                 info->fix.smem_start, info->fix.smem_len,
                                  par->which_io, vma);
 }
 
@@ -317,7 +314,7 @@ static int tcx_ioctl(struct fb_info *info, unsigned int cmd,
        return sbusfb_ioctl_helper(cmd, arg, info,
                                   FBTYPE_TCXCOLOR,
                                   (par->lowdepth ? 8 : 24),
-                                  par->fbsize);
+                                  info->fix.smem_len);
 }
 
 /*
@@ -359,13 +356,14 @@ static void tcx_unmap_regs(struct of_device *op, struct fb_info *info,
                           par->bt, sizeof(struct bt_regs));
        if (par->cplane)
                of_iounmap(&op->resource[4],
-                          par->cplane, par->fbsize * sizeof(u32));
+                          par->cplane, info->fix.smem_len * sizeof(u32));
        if (info->screen_base)
                of_iounmap(&op->resource[0],
-                          info->screen_base, par->fbsize);
+                          info->screen_base, info->fix.smem_len);
 }
 
-static int __devinit tcx_init_one(struct of_device *op)
+static int __devinit tcx_probe(struct of_device *op,
+                              const struct of_device_id *match)
 {
        struct device_node *dp = op->node;
        struct fb_info *info;
@@ -384,14 +382,14 @@ static int __devinit tcx_init_one(struct of_device *op)
        par->lowdepth =
                (of_find_property(dp, "tcx-8-bit", NULL) != NULL);
 
-       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;
 
        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->tec = of_ioremap(&op->resource[7], 0,
                                  sizeof(struct tcx_tec), "tcx tec");
@@ -400,7 +398,7 @@ static int __devinit tcx_init_one(struct of_device *op)
        par->bt = of_ioremap(&op->resource[8], 0,
                                 sizeof(struct bt_regs), "tcx dac");
        info->screen_base = of_ioremap(&op->resource[0], 0,
-                                          par->fbsize, "tcx ram");
+                                          info->fix.smem_len, "tcx ram");
        if (!par->tec || !par->thc ||
            !par->bt || !info->screen_base)
                goto out_unmap_regs;
@@ -408,7 +406,7 @@ static int __devinit tcx_init_one(struct of_device *op)
        memcpy(&par->mmap_map, &__tcx_mmap_map, sizeof(par->mmap_map));
        if (!par->lowdepth) {
                par->cplane = of_ioremap(&op->resource[4], 0,
-                                            par->fbsize * sizeof(u32),
+                                            info->fix.smem_len * sizeof(u32),
                                             "tcx cplane");
                if (!par->cplane)
                        goto out_unmap_regs;
@@ -419,7 +417,7 @@ static int __devinit tcx_init_one(struct of_device *op)
                par->mmap_map[6].size = SBUS_MMAP_EMPTY;
        }
 
-       par->physbase = 0;
+       info->fix.smem_start = op->resource[0].start;
        par->which_io = op->resource[0].flags & IORESOURCE_BITS;
 
        for (i = 0; i < TCX_MMAP_ENTRIES; i++) {
@@ -470,10 +468,10 @@ static int __devinit tcx_init_one(struct of_device *op)
 
        dev_set_drvdata(&op->dev, info);
 
-       printk("%s: TCX at %lx:%lx, %s\n",
+       printk(KERN_INFO "%s: TCX at %lx:%lx, %s\n",
               dp->full_name,
               par->which_io,
-              op->resource[0].start,
+              info->fix.smem_start,
               par->lowdepth ? "8-bit only" : "24-bit depth");
 
        return 0;
@@ -488,13 +486,6 @@ out_err:
        return err;
 }
 
-static int __devinit tcx_probe(struct of_device *dev, const struct of_device_id *match)
-{
-       struct of_device *op = to_of_device(&dev->dev);
-
-       return tcx_init_one(op);
-}
-
 static int __devexit tcx_remove(struct of_device *op)
 {
        struct fb_info *info = dev_get_drvdata(&op->dev);
@@ -512,7 +503,7 @@ static int __devexit tcx_remove(struct of_device *op)
        return 0;
 }
 
-static struct of_device_id tcx_match[] = {
+static const struct of_device_id tcx_match[] = {
        {
                .name = "SUNW,tcx",
        },
@@ -527,7 +518,7 @@ static struct of_platform_driver tcx_driver = {
        .remove         = __devexit_p(tcx_remove),
 };
 
-int __init tcx_init(void)
+static int __init tcx_init(void)
 {
        if (fb_get_options("tcxfb", NULL))
                return -ENODEV;
@@ -535,7 +526,7 @@ int __init tcx_init(void)
        return of_register_driver(&tcx_driver, &of_bus_type);
 }
 
-void __exit tcx_exit(void)
+static void __exit tcx_exit(void)
 {
        of_unregister_driver(&tcx_driver);
 }