X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?p=pandora-kernel.git;a=blobdiff_plain;f=drivers%2Fchar%2Fvt.c;h=8e4413f6fbaf6145352ffb5e7c9af0530240cc79;hp=0fca83ededff3eef49ae281790d8e76a77f8ab0f;hb=6ebfc0e20b409f13e62bbb84ce70102b49945cfd;hpb=d4328b40af16bae62ff8f854060d33daad237093 diff --git a/drivers/char/vt.c b/drivers/char/vt.c index 0fca83ededff..8e4413f6fbaf 100644 --- a/drivers/char/vt.c +++ b/drivers/char/vt.c @@ -106,7 +106,8 @@ #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 @@ -737,7 +730,8 @@ int vc_allocate(unsigned int currcons) /* return 0 on success */ visual_init(vc, currcons, 1); if (!*vc->vc_uni_pagedir_loc) con_set_default_unimap(vc); - vc->vc_screenbuf = kmalloc(vc->vc_screenbuf_size, GFP_KERNEL); + if (!vc->vc_kmalloced) + vc->vc_screenbuf = kmalloc(vc->vc_screenbuf_size, GFP_KERNEL); if (!vc->vc_screenbuf) { kfree(vc); vc_cons[currcons].d = NULL; @@ -885,14 +879,24 @@ int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int lines) return err; } +int vc_lock_resize(struct vc_data *vc, unsigned int cols, unsigned int lines) +{ + int rc; -void vc_disallocate(unsigned int currcons) + acquire_console_sem(); + rc = vc_resize(vc, cols, lines); + release_console_sem(); + return rc; +} + +void vc_deallocate(unsigned int currcons) { WARN_CONSOLE_UNLOCKED(); if (vc_cons_allocated(currcons)) { struct vc_data *vc = vc_cons[currcons].d; vc->vc_sw->con_deinit(vc); + put_pid(vc->vt_pid); module_put(vc->vc_sw->owner); if (vc->vc_kmalloced) kfree(vc->vc_screenbuf); @@ -2664,7 +2668,7 @@ static int __init con_init(void) } console_initcall(con_init); -static struct tty_operations con_ops = { +static const struct tty_operations con_ops = { .open = con_open, .close = con_close, .write = con_write, @@ -3059,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; + } - return 0; + if (error) { + while (--i >= 0) + class_device_remove_file(con->class_dev, + &class_device_attrs[i]); + con->flag &= ~CON_DRIVER_FLAG_ATTR; + } + + 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; + } } /** @@ -3173,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); @@ -3790,6 +3810,7 @@ EXPORT_SYMBOL(default_blu); EXPORT_SYMBOL(update_region); EXPORT_SYMBOL(redraw_screen); EXPORT_SYMBOL(vc_resize); +EXPORT_SYMBOL(vc_lock_resize); EXPORT_SYMBOL(fg_console); EXPORT_SYMBOL(console_blank_hook); EXPORT_SYMBOL(console_blanked);