[ARM] 5118/1: pxafb: add exit and remove handlers
authorJaya Kumar <jayakumar.arm@gmail.com>
Sun, 22 Jun 2008 03:27:28 +0000 (04:27 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Mon, 7 Jul 2008 12:23:38 +0000 (13:23 +0100)
This patch adds exit and remove handlers to pxafb so that it can be loaded
and unloaded as a module.

Signed-off-by: Jaya Kumar <jayakumar.lkml@gmail.com>
Acked-by: Krzysztof Helt <krzysztof.h1@wp.pl>
Acked-by: Eric Miao <eric.miao@marvell.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
drivers/video/pxafb.c

index 3ee314beacc1a7c6be88fc854ca4b0b69aff4c91..3682bbd7e50e5c2dcbd13aec75664dae594fd1e8 100644 (file)
@@ -1777,11 +1777,49 @@ failed:
        return ret;
 }
 
+static int __devexit pxafb_remove(struct platform_device *dev)
+{
+       struct pxafb_info *fbi = platform_get_drvdata(dev);
+       struct resource *r;
+       int irq;
+       struct fb_info *info;
+
+       if (!fbi)
+               return 0;
+
+       info = &fbi->fb;
+
+       unregister_framebuffer(info);
+
+       pxafb_disable_controller(fbi);
+
+       if (fbi->fb.cmap.len)
+               fb_dealloc_cmap(&fbi->fb.cmap);
+
+       irq = platform_get_irq(dev, 0);
+       free_irq(irq, fbi);
+
+       dma_free_writecombine(&dev->dev, fbi->map_size,
+                                       fbi->map_cpu, fbi->map_dma);
+
+       iounmap(fbi->mmio_base);
+
+       r = platform_get_resource(dev, IORESOURCE_MEM, 0);
+       release_mem_region(r->start, r->end - r->start + 1);
+
+       clk_put(fbi->clk);
+       kfree(fbi);
+
+       return 0;
+}
+
 static struct platform_driver pxafb_driver = {
        .probe          = pxafb_probe,
+       .remove         = pxafb_remove,
        .suspend        = pxafb_suspend,
        .resume         = pxafb_resume,
        .driver         = {
+               .owner  = THIS_MODULE,
                .name   = "pxa2xx-fb",
        },
 };
@@ -1794,7 +1832,13 @@ static int __devinit pxafb_init(void)
        return platform_driver_register(&pxafb_driver);
 }
 
+static void __exit pxafb_exit(void)
+{
+       platform_driver_unregister(&pxafb_driver);
+}
+
 module_init(pxafb_init);
+module_exit(pxafb_exit);
 
 MODULE_DESCRIPTION("loadable framebuffer driver for PXA");
 MODULE_LICENSE("GPL");