diff options
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/vt.c | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/drivers/char/vt.c b/drivers/char/vt.c index ec0c070bf15f..a398b6b6aa65 100644 --- a/drivers/char/vt.c +++ b/drivers/char/vt.c | |||
@@ -106,7 +106,8 @@ | |||
106 | #define MAX_NR_CON_DRIVER 16 | 106 | #define MAX_NR_CON_DRIVER 16 |
107 | 107 | ||
108 | #define CON_DRIVER_FLAG_MODULE 1 | 108 | #define CON_DRIVER_FLAG_MODULE 1 |
109 | #define CON_DRIVER_FLAG_INIT 2 | 109 | #define CON_DRIVER_FLAG_INIT 2 |
110 | #define CON_DRIVER_FLAG_ATTR 4 | ||
110 | 111 | ||
111 | struct con_driver { | 112 | struct con_driver { |
112 | const struct consw *con; | 113 | const struct consw *con; |
@@ -3070,22 +3071,37 @@ static struct class_device_attribute class_device_attrs[] = { | |||
3070 | static int vtconsole_init_class_device(struct con_driver *con) | 3071 | static int vtconsole_init_class_device(struct con_driver *con) |
3071 | { | 3072 | { |
3072 | int i; | 3073 | int i; |
3074 | int error = 0; | ||
3073 | 3075 | ||
3076 | con->flag |= CON_DRIVER_FLAG_ATTR; | ||
3074 | class_set_devdata(con->class_dev, con); | 3077 | class_set_devdata(con->class_dev, con); |
3075 | for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) | 3078 | for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) { |
3076 | class_device_create_file(con->class_dev, | 3079 | error = class_device_create_file(con->class_dev, |
3077 | &class_device_attrs[i]); | 3080 | &class_device_attrs[i]); |
3081 | if (error) | ||
3082 | break; | ||
3083 | } | ||
3078 | 3084 | ||
3079 | return 0; | 3085 | if (error) { |
3086 | while (--i >= 0) | ||
3087 | class_device_remove_file(con->class_dev, | ||
3088 | &class_device_attrs[i]); | ||
3089 | con->flag &= ~CON_DRIVER_FLAG_ATTR; | ||
3090 | } | ||
3091 | |||
3092 | return error; | ||
3080 | } | 3093 | } |
3081 | 3094 | ||
3082 | static void vtconsole_deinit_class_device(struct con_driver *con) | 3095 | static void vtconsole_deinit_class_device(struct con_driver *con) |
3083 | { | 3096 | { |
3084 | int i; | 3097 | int i; |
3085 | 3098 | ||
3086 | for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) | 3099 | if (con->flag & CON_DRIVER_FLAG_ATTR) { |
3087 | class_device_remove_file(con->class_dev, | 3100 | for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) |
3088 | &class_device_attrs[i]); | 3101 | class_device_remove_file(con->class_dev, |
3102 | &class_device_attrs[i]); | ||
3103 | con->flag &= ~CON_DRIVER_FLAG_ATTR; | ||
3104 | } | ||
3089 | } | 3105 | } |
3090 | 3106 | ||
3091 | /** | 3107 | /** |
@@ -3184,6 +3200,7 @@ int register_con_driver(const struct consw *csw, int first, int last) | |||
3184 | } else { | 3200 | } else { |
3185 | vtconsole_init_class_device(con_driver); | 3201 | vtconsole_init_class_device(con_driver); |
3186 | } | 3202 | } |
3203 | |||
3187 | err: | 3204 | err: |
3188 | release_console_sem(); | 3205 | release_console_sem(); |
3189 | module_put(owner); | 3206 | module_put(owner); |