aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/char/vc_screen.c18
-rw-r--r--drivers/char/vt.c5
2 files changed, 13 insertions, 10 deletions
diff --git a/drivers/char/vc_screen.c b/drivers/char/vc_screen.c
index 61fbc9e52eeb..83aeedda200c 100644
--- a/drivers/char/vc_screen.c
+++ b/drivers/char/vc_screen.c
@@ -28,11 +28,13 @@
28#include <linux/interrupt.h> 28#include <linux/interrupt.h>
29#include <linux/mm.h> 29#include <linux/mm.h>
30#include <linux/init.h> 30#include <linux/init.h>
31#include <linux/mutex.h>
31#include <linux/vt_kern.h> 32#include <linux/vt_kern.h>
32#include <linux/selection.h> 33#include <linux/selection.h>
33#include <linux/kbd_kern.h> 34#include <linux/kbd_kern.h>
34#include <linux/console.h> 35#include <linux/console.h>
35#include <linux/device.h> 36#include <linux/device.h>
37
36#include <asm/uaccess.h> 38#include <asm/uaccess.h>
37#include <asm/byteorder.h> 39#include <asm/byteorder.h>
38#include <asm/unaligned.h> 40#include <asm/unaligned.h>
@@ -69,11 +71,11 @@ static loff_t vcs_lseek(struct file *file, loff_t offset, int orig)
69{ 71{
70 int size; 72 int size;
71 73
72 down(&con_buf_sem); 74 mutex_lock(&con_buf_mtx);
73 size = vcs_size(file->f_path.dentry->d_inode); 75 size = vcs_size(file->f_path.dentry->d_inode);
74 switch (orig) { 76 switch (orig) {
75 default: 77 default:
76 up(&con_buf_sem); 78 mutex_unlock(&con_buf_mtx);
77 return -EINVAL; 79 return -EINVAL;
78 case 2: 80 case 2:
79 offset += size; 81 offset += size;
@@ -84,11 +86,11 @@ static loff_t vcs_lseek(struct file *file, loff_t offset, int orig)
84 break; 86 break;
85 } 87 }
86 if (offset < 0 || offset > size) { 88 if (offset < 0 || offset > size) {
87 up(&con_buf_sem); 89 mutex_unlock(&con_buf_mtx);
88 return -EINVAL; 90 return -EINVAL;
89 } 91 }
90 file->f_pos = offset; 92 file->f_pos = offset;
91 up(&con_buf_sem); 93 mutex_unlock(&con_buf_mtx);
92 return file->f_pos; 94 return file->f_pos;
93} 95}
94 96
@@ -105,7 +107,7 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
105 unsigned short *org = NULL; 107 unsigned short *org = NULL;
106 ssize_t ret; 108 ssize_t ret;
107 109
108 down(&con_buf_sem); 110 mutex_lock(&con_buf_mtx);
109 111
110 pos = *ppos; 112 pos = *ppos;
111 113
@@ -262,7 +264,7 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
262 ret = read; 264 ret = read;
263unlock_out: 265unlock_out:
264 release_console_sem(); 266 release_console_sem();
265 up(&con_buf_sem); 267 mutex_unlock(&con_buf_mtx);
266 return ret; 268 return ret;
267} 269}
268 270
@@ -279,7 +281,7 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
279 u16 *org0 = NULL, *org = NULL; 281 u16 *org0 = NULL, *org = NULL;
280 size_t ret; 282 size_t ret;
281 283
282 down(&con_buf_sem); 284 mutex_lock(&con_buf_mtx);
283 285
284 pos = *ppos; 286 pos = *ppos;
285 287
@@ -449,7 +451,7 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
449unlock_out: 451unlock_out:
450 release_console_sem(); 452 release_console_sem();
451 453
452 up(&con_buf_sem); 454 mutex_unlock(&con_buf_mtx);
453 455
454 return ret; 456 return ret;
455} 457}
diff --git a/drivers/char/vt.c b/drivers/char/vt.c
index 0edbbc3fa9d8..bbd9fc412877 100644
--- a/drivers/char/vt.c
+++ b/drivers/char/vt.c
@@ -86,6 +86,7 @@
86#include <linux/mm.h> 86#include <linux/mm.h>
87#include <linux/console.h> 87#include <linux/console.h>
88#include <linux/init.h> 88#include <linux/init.h>
89#include <linux/mutex.h>
89#include <linux/vt_kern.h> 90#include <linux/vt_kern.h>
90#include <linux/selection.h> 91#include <linux/selection.h>
91#include <linux/tiocl.h> 92#include <linux/tiocl.h>
@@ -1952,7 +1953,7 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c)
1952 * kernel memory allocation is available. 1953 * kernel memory allocation is available.
1953 */ 1954 */
1954char con_buf[CON_BUF_SIZE]; 1955char con_buf[CON_BUF_SIZE];
1955DECLARE_MUTEX(con_buf_sem); 1956DEFINE_MUTEX(con_buf_mtx);
1956 1957
1957/* is_double_width() is based on the wcwidth() implementation by 1958/* is_double_width() is based on the wcwidth() implementation by
1958 * Markus Kuhn -- 2003-05-20 (Unicode 4.0) 1959 * Markus Kuhn -- 2003-05-20 (Unicode 4.0)
@@ -2049,7 +2050,7 @@ static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int co
2049 2050
2050 /* At this point 'buf' is guaranteed to be a kernel buffer 2051 /* At this point 'buf' is guaranteed to be a kernel buffer
2051 * and therefore no access to userspace (and therefore sleeping) 2052 * and therefore no access to userspace (and therefore sleeping)
2052 * will be needed. The con_buf_sem serializes all tty based 2053 * will be needed. The con_buf_mtx serializes all tty based
2053 * console rendering and vcs write/read operations. We hold 2054 * console rendering and vcs write/read operations. We hold
2054 * the console spinlock during the entire write. 2055 * the console spinlock during the entire write.
2055 */ 2056 */