[PATCH] Detaching fbcon: clean up exit code
authorAntonino A. Daplas <adaplas@gmail.com>
Mon, 26 Jun 2006 07:27:05 +0000 (00:27 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Mon, 26 Jun 2006 16:58:32 +0000 (09:58 -0700)
To detach fbcon, it must also clean up all resources it allocated.  This was
never done before because fbcon cannot be unloaded.

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/console/fbcon.c

index 746225bf8c4428965ec38d16e286524ac53620b7..0b742497055e72dac35e99ab1b3f178faf52741d 100644 (file)
@@ -3112,6 +3112,49 @@ static void __exit fbcon_deinit_class_device(void)
 
 static void __exit fbcon_exit(void)
 {
+       struct fb_info *info;
+       int i, j, mapped;
+
+       for (i = 0; i < FB_MAX; i++) {
+               info = registered_fb[i];
+
+               if (info && info->fbcon_par)
+                       fbcon_del_cursor_timer(info);
+       }
+
+#ifdef CONFIG_ATARI
+       free_irq(IRQ_AUTO_4, fbcon_vbl_handler);
+#endif
+#ifdef CONFIG_MAC
+       if (MACH_IS_MAC && vbl_detected)
+               free_irq(IRQ_MAC_VBL, fbcon_vbl_handler);
+#endif
+
+       kfree((void *)softback_buf);
+
+       for (i = 0; i < FB_MAX; i++) {
+               mapped = 0;
+               info = registered_fb[i];
+
+               if (info == NULL)
+                       continue;
+
+               for (j = 0; j < MAX_NR_CONSOLES; j++) {
+                       if (con2fb_map[j] == i) {
+                               con2fb_map[j] = -1;
+                               mapped = 1;
+                       }
+               }
+
+               if (mapped) {
+                       if (info->fbops->fb_release)
+                               info->fbops->fb_release(info, 0);
+                       module_put(info->fbops->owner);
+                       kfree(info->fbcon_par);
+                       info->fbcon_par = NULL;
+               }
+       }
+
        fbcon_deinit_class_device();
        class_device_destroy(fb_class, MKDEV(FB_MAJOR, FB_MAX));
 }