Commit ae6d3218 authored by Antonino A. Daplas's avatar Antonino A. Daplas Committed by Linus Torvalds

[PATCH] vga16fb: Update platform code

Update platform code to dynamically allocate the platform device
Signed-off-by: default avatarAntonino Daplas <adaplas@pol.net>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 20cecf6a
...@@ -1334,9 +1334,8 @@ static int vga16fb_setup(char *options) ...@@ -1334,9 +1334,8 @@ static int vga16fb_setup(char *options)
} }
#endif #endif
static int __init vga16fb_probe(struct device *device) static int __init vga16fb_probe(struct platform_device *dev)
{ {
struct platform_device *dev = to_platform_device(device);
struct fb_info *info; struct fb_info *info;
struct vga16fb_par *par; struct vga16fb_par *par;
int i; int i;
...@@ -1403,7 +1402,7 @@ static int __init vga16fb_probe(struct device *device) ...@@ -1403,7 +1402,7 @@ static int __init vga16fb_probe(struct device *device)
printk(KERN_INFO "fb%d: %s frame buffer device\n", printk(KERN_INFO "fb%d: %s frame buffer device\n",
info->node, info->fix.id); info->node, info->fix.id);
dev_set_drvdata(device, info); platform_set_drvdata(dev, info);
return 0; return 0;
...@@ -1417,9 +1416,9 @@ static int __init vga16fb_probe(struct device *device) ...@@ -1417,9 +1416,9 @@ static int __init vga16fb_probe(struct device *device)
return ret; return ret;
} }
static int vga16fb_remove(struct device *device) static int vga16fb_remove(struct platform_device *dev)
{ {
struct fb_info *info = dev_get_drvdata(device); struct fb_info *info = platform_get_drvdata(dev);
if (info) { if (info) {
unregister_framebuffer(info); unregister_framebuffer(info);
...@@ -1432,17 +1431,16 @@ static int vga16fb_remove(struct device *device) ...@@ -1432,17 +1431,16 @@ static int vga16fb_remove(struct device *device)
return 0; return 0;
} }
static struct device_driver vga16fb_driver = { static struct platform_driver vga16fb_driver = {
.name = "vga16fb",
.bus = &platform_bus_type,
.probe = vga16fb_probe, .probe = vga16fb_probe,
.remove = vga16fb_remove, .remove = vga16fb_remove,
}; .driver = {
static struct platform_device vga16fb_device = {
.name = "vga16fb", .name = "vga16fb",
},
}; };
static struct platform_device *vga16fb_device;
static int __init vga16fb_init(void) static int __init vga16fb_init(void)
{ {
int ret; int ret;
...@@ -1454,12 +1452,20 @@ static int __init vga16fb_init(void) ...@@ -1454,12 +1452,20 @@ static int __init vga16fb_init(void)
vga16fb_setup(option); vga16fb_setup(option);
#endif #endif
ret = driver_register(&vga16fb_driver); ret = platform_driver_register(&vga16fb_driver);
if (!ret) { if (!ret) {
ret = platform_device_register(&vga16fb_device); vga16fb_device = platform_device_alloc("vga16fb", 0);
if (ret)
driver_unregister(&vga16fb_driver); if (vga16fb_device)
ret = platform_device_add(vga16fb_device);
else
ret = -ENOMEM;
if (ret) {
platform_device_put(vga16fb_device);
platform_driver_unregister(&vga16fb_driver);
}
} }
return ret; return ret;
...@@ -1467,8 +1473,8 @@ static int __init vga16fb_init(void) ...@@ -1467,8 +1473,8 @@ static int __init vga16fb_init(void)
static void __exit vga16fb_exit(void) static void __exit vga16fb_exit(void)
{ {
platform_device_unregister(&vga16fb_device); platform_device_unregister(vga16fb_device);
driver_unregister(&vga16fb_driver); platform_driver_unregister(&vga16fb_driver);
} }
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment