[PATCH] vfb: Update platform code
authorAntonino A. Daplas <adaplas@gmail.com>
Mon, 26 Jun 2006 07:26:34 +0000 (00:26 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Mon, 26 Jun 2006 16:58:29 +0000 (09:58 -0700)
Update platform code to dynamically allocate the platform device

Signed-off-by: Antonino Daplas <adaplas@pol.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/video/vfb.c

index 77eed1fd994366d4140ae74d319eee2a94fe396d..d073ffb6e1f9f0d600c585f46ffa802fca4b0286 100644 (file)
@@ -398,12 +398,6 @@ static int __init vfb_setup(char *options)
      *  Initialisation
      */
 
-static void vfb_platform_release(struct device *device)
-{
-       // This is called when the reference count goes to zero.
-       dev_err(device, "This driver is broken, please bug the authors so they will fix it.\n");
-}
-
 static int __init vfb_probe(struct platform_device *dev)
 {
        struct fb_info *info;
@@ -482,13 +476,7 @@ static struct platform_driver vfb_driver = {
        },
 };
 
-static struct platform_device vfb_device = {
-       .name   = "vfb",
-       .id     = 0,
-       .dev    = {
-               .release = vfb_platform_release,
-       }
-};
+static struct platform_device *vfb_device;
 
 static int __init vfb_init(void)
 {
@@ -508,10 +496,19 @@ static int __init vfb_init(void)
        ret = platform_driver_register(&vfb_driver);
 
        if (!ret) {
-               ret = platform_device_register(&vfb_device);
-               if (ret)
+               vfb_device = platform_device_alloc("vfb", 0);
+
+               if (vfb_device)
+                       ret = platform_device_add(vfb_device);
+               else
+                       ret = -ENOMEM;
+
+               if (ret) {
+                       platform_device_put(vfb_device);
                        platform_driver_unregister(&vfb_driver);
+               }
        }
+
        return ret;
 }
 
@@ -520,7 +517,7 @@ module_init(vfb_init);
 #ifdef MODULE
 static void __exit vfb_exit(void)
 {
-       platform_device_unregister(&vfb_device);
+       platform_device_unregister(vfb_device);
        platform_driver_unregister(&vfb_driver);
 }