]> git.hungrycats.org Git - linux/commitdiff
[PATCH] Apollo fb sysfsification
authorAndrew Morton <akpm@osdl.org>
Fri, 12 Mar 2004 00:20:52 +0000 (16:20 -0800)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Fri, 12 Mar 2004 00:20:52 +0000 (16:20 -0800)
From: Geert Uytterhoeven <geert@linux-m68k.org>

Apollo fb: Add sysfs support (from James Simmons)

drivers/video/dnfb.c

index 914bc8e388ecea5954895a6f153f7be8ab6c1336..7e75f7426a087e9fb9f558a899d83c4ada8ab5ad 100644 (file)
 
 #define SWAP(A) ((A>>8) | ((A&0xff) <<8))
 
-static struct fb_info fb_info;
-
 /* frame buffer operations */
 
 static int dnfb_blank(int blank, struct fb_info *info);
@@ -119,7 +117,7 @@ static struct fb_ops dn_fb_ops = {
        .fb_cursor      = soft_cursor,
 };
 
-struct fb_var_screeninfo dnfb_var __initdata = {
+struct fb_var_screeninfo dnfb_var __devinitdata = {
        .xres           1280,
        .yres           1024,
        .xres_virtual   2048,
@@ -130,7 +128,7 @@ struct fb_var_screeninfo dnfb_var __initdata = {
        .vmode          FB_VMODE_NONINTERLACED,
 };
 
-static struct fb_fix_screeninfo dnfb_fix __initdata = {
+static struct fb_fix_screeninfo dnfb_fix __devinitdata = {
        .id             "Apollo Mono",
        .smem_start     (FRAME_BUFFER_START + IO_BASE),
        .smem_len       FRAME_BUFFER_LEN,
@@ -148,7 +146,7 @@ static int dnfb_blank(int blank, struct fb_info *info)
        return 0;
 }
 
-static 
+static
 void dnfb_copyarea(struct fb_info *info, const struct fb_copyarea *area)
 {
 
@@ -224,21 +222,38 @@ void dnfb_copyarea(struct fb_info *info, const struct fb_copyarea *area)
        out_8(AP_CONTROL_0, NORMAL_MODE);
 }
 
+/*
+ * Initialization
+ */
 
-unsigned long __init dnfb_init(unsigned long mem_start)
+static int __devinit dnfb_probe(struct device *device)
 {
-       int err;
-
-       fb_info.fbops = &dn_fb_ops;
-       fb_info.fix = dnfb_fix;
-       fb_info.var = dnfb_var;
-       fb_info.screen_base = (u_char *) fb_info.fix.smem_start;
-
-       fb_alloc_cmap(&fb_info.cmap, 2, 0);
+       struct platform_device *dev = to_platform_device(device);
+       struct fb_info *info;
+       int err = 0;
+
+       info = framebuffer_alloc(0, &dev->dev);
+       if (!info)
+               return -ENOMEM;
+
+       info->fbops = &dn_fb_ops;
+       info->fix = dnfb_fix;
+       info->var = dnfb_var;
+       info->screen_base = (u_char *) info->fix.smem_start;
+
+       err = fb_alloc_cmap(&info->cmap, 2, 0);
+       if (err < 0) {
+               framebuffer_release(info);
+               return err;
+       }
 
-       err = register_framebuffer(&fb_info);
-       if (err < 0)
-               panic("unable to register apollo frame buffer\n");
+       err = register_framebuffer(info);
+       if (err < 0) {
+               fb_dealloc_cmap(&info->cmap);
+               framebuffer_release(info);
+               return err;
+       }
+       dev_set_drvdata(&dev->dev, info);
 
        /* now we have registered we can safely setup the hardware */
        out_8(AP_CONTROL_3A, RESET_CREG);
@@ -249,7 +264,31 @@ unsigned long __init dnfb_init(unsigned long mem_start)
        out_be16(AP_ROP_1, SWAP(0x3));
 
        printk("apollo frame buffer alive and kicking !\n");
-       return mem_start;
+       return err;
+}
+
+static struct device_driver dnfb_driver = {
+       .name   = "dnfb",
+       .bus    = &platform_bus_type,
+       .probe  = dnfb_probe,
+};
+
+static struct platform_device dnfb_device = {
+       .name   = "dnfb",
+};
+
+int __init dnfb_init(void)
+{
+       int ret;
+
+       ret = driver_register(&dnfb_driver);
+
+       if (!ret) {
+               ret = platform_device_register(&dnfb_device);
+               if (ret)
+                       driver_unregister(&dnfb_driver);
+       }
+       return ret;
 }
 
 MODULE_LICENSE("GPL");