Merge master.kernel.org:/pub/scm/linux/kernel/git/lethal/sh-2.6
[pandora-kernel.git] / drivers / char / vt.c
index ec0c070..8e4413f 100644 (file)
 #define MAX_NR_CON_DRIVER 16
 
 #define CON_DRIVER_FLAG_MODULE 1
-#define CON_DRIVER_FLAG_INIT 2
+#define CON_DRIVER_FLAG_INIT   2
+#define CON_DRIVER_FLAG_ATTR   4
 
 struct con_driver {
        const struct consw *con;
@@ -138,14 +139,6 @@ const struct consw *conswitchp;
 extern void vcs_make_sysfs(struct tty_struct *tty);
 extern void vcs_remove_sysfs(struct tty_struct *tty);
 
-extern void console_map_init(void);
-#ifdef CONFIG_PROM_CONSOLE
-extern void prom_con_init(void);
-#endif
-#ifdef CONFIG_MDA_CONSOLE
-extern int mda_console_init(void);
-#endif
-
 struct vc vc_cons [MAX_NR_CONSOLES];
 
 #ifndef VT_SINGLE_DRIVER
@@ -3070,22 +3063,37 @@ static struct class_device_attribute class_device_attrs[] = {
 static int vtconsole_init_class_device(struct con_driver *con)
 {
        int i;
+       int error = 0;
 
+       con->flag |= CON_DRIVER_FLAG_ATTR;
        class_set_devdata(con->class_dev, con);
-       for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++)
-               class_device_create_file(con->class_dev,
+       for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) {
+               error = class_device_create_file(con->class_dev,
+                                        &class_device_attrs[i]);
+               if (error)
+                       break;
+       }
+
+       if (error) {
+               while (--i >= 0)
+                       class_device_remove_file(con->class_dev,
                                         &class_device_attrs[i]);
+               con->flag &= ~CON_DRIVER_FLAG_ATTR;
+       }
 
-       return 0;
+       return error;
 }
 
 static void vtconsole_deinit_class_device(struct con_driver *con)
 {
        int i;
 
-       for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++)
-               class_device_remove_file(con->class_dev,
-                                        &class_device_attrs[i]);
+       if (con->flag & CON_DRIVER_FLAG_ATTR) {
+               for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++)
+                       class_device_remove_file(con->class_dev,
+                                                &class_device_attrs[i]);
+               con->flag &= ~CON_DRIVER_FLAG_ATTR;
+       }
 }
 
 /**
@@ -3184,6 +3192,7 @@ int register_con_driver(const struct consw *csw, int first, int last)
        } else {
                vtconsole_init_class_device(con_driver);
        }
+
 err:
        release_console_sem();
        module_put(owner);