We should allocate platform device dynamically, otherwise it can't be removed. Also, back in time it was acceptable to mix devices and platform_devices, today this might cause all sort of bugs. Fix that too. This patch was build-tested only. Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com> --- On Sun, Jun 01, 2008 at 01:41:30PM +0200, devzero@web.de wrote:It should be just trivially fixed. Here is the patch, I can only build test it though. drivers/video/hgafb.c | 39 ++++++++++++++++++++------------------- 1 files changed, 20 insertions(+), 19 deletions(-) diff --git a/drivers/video/hgafb.c b/drivers/video/hgafb.c index fb9e672..224ffb8 100644 --- a/drivers/video/hgafb.c +++ b/drivers/video/hgafb.c @@ -547,7 +547,7 @@ static struct fb_ops hgafb_ops = { * Initialization */ -static int __init hgafb_probe(struct device *device) +static int __init hgafb_probe(struct platform_device *pdev) { struct fb_info *info; @@ -589,13 +589,13 @@ static int __init hgafb_probe(struct device *device) printk(KERN_INFO "fb%d: %s frame buffer device\n", info->node, info->fix.id); - dev_set_drvdata(device, info); + platform_set_drvdata(pdev, info); return 0; } -static int hgafb_remove(struct device *device) +static int __devexit hgafb_remove(struct platform_device *pdev) { - struct fb_info *info = dev_get_drvdata(device); + struct fb_info *info = platform_get_drvdata(pdev); hga_txt_mode(); hga_clear_screen(); @@ -616,16 +616,15 @@ static int hgafb_remove(struct device *device) return 0; } -static struct device_driver hgafb_driver = { - .name = "hgafb", - .bus = &platform_bus_type, +static struct platform_driver hgafb_driver = { + .driver = { + .name = "hgafb", + }, .probe = hgafb_probe, - .remove = hgafb_remove, + .remove = __devexit_p(hgafb_remove), }; -static struct platform_device hgafb_device = { - .name = "hgafb", -}; +static struct platform_device *hgafb_device; static int __init hgafb_init(void) { @@ -634,21 +633,23 @@ static int __init hgafb_init(void) if (fb_get_options("hgafb", NULL)) return -ENODEV; - ret = driver_register(&hgafb_driver); + ret = platform_driver_register(&hgafb_driver); + if (ret) + return ret; - if (!ret) { - ret = platform_device_register(&hgafb_device); - if (ret) - driver_unregister(&hgafb_driver); + hgafb_device = platform_device_register_simple("hgafb", -1, NULL, 0); + if (!hgafb_device) { + platform_driver_unregister(&hgafb_driver); + return -ENOMEM; } - return ret; + return 0; } static void __exit hgafb_exit(void) { - platform_device_unregister(&hgafb_device); - driver_unregister(&hgafb_driver); + platform_device_unregister(hgafb_device); + platform_driver_unregister(&hgafb_driver); } /* ------------------------------------------------------------------------- -- 1.5.5.1 --
| Tarkan Erimer | Re: Dual-Licensing Linux Kernel with GPL V2 and GPL V3 |
| Greg Kroah-Hartman | [PATCH 001/196] Chinese: Add the known_regression URI to the HOWTO |
| Arjan van de Ven | Re: Linux 2.6.27-rc8 |
git: | |
| Arjan van de Ven | Re: [GIT]: Networking |
| Gerrit Renker | [PATCH 27/37] dccp: Integration of dynamic feature activation - part 2 (server side) |
| Jarek Poplawski | [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
| Jeff Garzik | Re: [bug?] tg3: Failed to load firmware "tigon/tg3_tso.bin" |
