PageRenderTime 12ms CodeModel.GetById 5ms app.highlight 6ms RepoModel.GetById 0ms app.codeStats 0ms

/drivers/tty/tty_mutex.c

https://bitbucket.org/wisechild/galaxy-nexus
C | 44 lines | 24 code | 7 blank | 13 comment | 2 complexity | 1c51f83d4558840d0f5a60103ce14539 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, AGPL-1.0
 1#include <linux/tty.h>
 2#include <linux/module.h>
 3#include <linux/kallsyms.h>
 4#include <linux/semaphore.h>
 5#include <linux/sched.h>
 6
 7/*
 8 * The 'big tty mutex'
 9 *
10 * This mutex is taken and released by tty_lock() and tty_unlock(),
11 * replacing the older big kernel lock.
12 * It can no longer be taken recursively, and does not get
13 * released implicitly while sleeping.
14 *
15 * Don't use in new code.
16 */
17static DEFINE_MUTEX(big_tty_mutex);
18struct task_struct *__big_tty_mutex_owner;
19EXPORT_SYMBOL_GPL(__big_tty_mutex_owner);
20
21/*
22 * Getting the big tty mutex.
23 */
24void __lockfunc tty_lock(void)
25{
26	struct task_struct *task = current;
27
28	WARN_ON(__big_tty_mutex_owner == task);
29
30	mutex_lock(&big_tty_mutex);
31	__big_tty_mutex_owner = task;
32}
33EXPORT_SYMBOL(tty_lock);
34
35void __lockfunc tty_unlock(void)
36{
37	struct task_struct *task = current;
38
39	WARN_ON(__big_tty_mutex_owner != task);
40	__big_tty_mutex_owner = NULL;
41
42	mutex_unlock(&big_tty_mutex);
43}
44EXPORT_SYMBOL(tty_unlock);