diff options
author | Ingo Molnar <mingo@elte.hu> | 2006-03-23 06:00:31 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-23 10:38:11 -0500 |
commit | 70522e121a521aa09bd0f4e62e1aa68708b798e1 (patch) | |
tree | 1233412da73361b48ed01290a33ab7c90e36359a /drivers/char | |
parent | d4f9af9dac4ecb75818f909168f87b441cc95653 (diff) |
[PATCH] sem2mutex: tty
Semaphore to mutex conversion.
The conversion was generated via scripts, and the result was validated
automatically via a script as well.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Russell King <rmk@arm.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/n_tty.c | 10 | ||||
-rw-r--r-- | drivers/char/tty_io.c | 50 | ||||
-rw-r--r-- | drivers/char/vt.c | 14 |
3 files changed, 37 insertions, 37 deletions
diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c index ccad7ae94541..ede365d05387 100644 --- a/drivers/char/n_tty.c +++ b/drivers/char/n_tty.c | |||
@@ -132,7 +132,7 @@ static void put_tty_queue(unsigned char c, struct tty_struct *tty) | |||
132 | * We test the TTY_THROTTLED bit first so that it always | 132 | * We test the TTY_THROTTLED bit first so that it always |
133 | * indicates the current state. The decision about whether | 133 | * indicates the current state. The decision about whether |
134 | * it is worth allowing more input has been taken by the caller. | 134 | * it is worth allowing more input has been taken by the caller. |
135 | * Can sleep, may be called under the atomic_read semaphore but | 135 | * Can sleep, may be called under the atomic_read_lock mutex but |
136 | * this is not guaranteed. | 136 | * this is not guaranteed. |
137 | */ | 137 | */ |
138 | 138 | ||
@@ -1132,7 +1132,7 @@ static inline int input_available_p(struct tty_struct *tty, int amt) | |||
1132 | * buffer, and once to drain the space from the (physical) beginning of | 1132 | * buffer, and once to drain the space from the (physical) beginning of |
1133 | * the buffer to head pointer. | 1133 | * the buffer to head pointer. |
1134 | * | 1134 | * |
1135 | * Called under the tty->atomic_read sem and with TTY_DONT_FLIP set | 1135 | * Called under the tty->atomic_read_lock sem and with TTY_DONT_FLIP set |
1136 | * | 1136 | * |
1137 | */ | 1137 | */ |
1138 | 1138 | ||
@@ -1262,11 +1262,11 @@ do_it_again: | |||
1262 | * Internal serialization of reads. | 1262 | * Internal serialization of reads. |
1263 | */ | 1263 | */ |
1264 | if (file->f_flags & O_NONBLOCK) { | 1264 | if (file->f_flags & O_NONBLOCK) { |
1265 | if (down_trylock(&tty->atomic_read)) | 1265 | if (!mutex_trylock(&tty->atomic_read_lock)) |
1266 | return -EAGAIN; | 1266 | return -EAGAIN; |
1267 | } | 1267 | } |
1268 | else { | 1268 | else { |
1269 | if (down_interruptible(&tty->atomic_read)) | 1269 | if (mutex_lock_interruptible(&tty->atomic_read_lock)) |
1270 | return -ERESTARTSYS; | 1270 | return -ERESTARTSYS; |
1271 | } | 1271 | } |
1272 | 1272 | ||
@@ -1393,7 +1393,7 @@ do_it_again: | |||
1393 | timeout = time; | 1393 | timeout = time; |
1394 | } | 1394 | } |
1395 | clear_bit(TTY_DONT_FLIP, &tty->flags); | 1395 | clear_bit(TTY_DONT_FLIP, &tty->flags); |
1396 | up(&tty->atomic_read); | 1396 | mutex_unlock(&tty->atomic_read_lock); |
1397 | remove_wait_queue(&tty->read_wait, &wait); | 1397 | remove_wait_queue(&tty->read_wait, &wait); |
1398 | 1398 | ||
1399 | if (!waitqueue_active(&tty->read_wait)) | 1399 | if (!waitqueue_active(&tty->read_wait)) |
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index 53d3d066554e..76592ee1fb38 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c | |||
@@ -130,7 +130,7 @@ LIST_HEAD(tty_drivers); /* linked list of tty drivers */ | |||
130 | 130 | ||
131 | /* Semaphore to protect creating and releasing a tty. This is shared with | 131 | /* Semaphore to protect creating and releasing a tty. This is shared with |
132 | vt.c for deeply disgusting hack reasons */ | 132 | vt.c for deeply disgusting hack reasons */ |
133 | DECLARE_MUTEX(tty_sem); | 133 | DEFINE_MUTEX(tty_mutex); |
134 | 134 | ||
135 | #ifdef CONFIG_UNIX98_PTYS | 135 | #ifdef CONFIG_UNIX98_PTYS |
136 | extern struct tty_driver *ptm_driver; /* Unix98 pty masters; for /dev/ptmx */ | 136 | extern struct tty_driver *ptm_driver; /* Unix98 pty masters; for /dev/ptmx */ |
@@ -1188,11 +1188,11 @@ void disassociate_ctty(int on_exit) | |||
1188 | 1188 | ||
1189 | lock_kernel(); | 1189 | lock_kernel(); |
1190 | 1190 | ||
1191 | down(&tty_sem); | 1191 | mutex_lock(&tty_mutex); |
1192 | tty = current->signal->tty; | 1192 | tty = current->signal->tty; |
1193 | if (tty) { | 1193 | if (tty) { |
1194 | tty_pgrp = tty->pgrp; | 1194 | tty_pgrp = tty->pgrp; |
1195 | up(&tty_sem); | 1195 | mutex_unlock(&tty_mutex); |
1196 | if (on_exit && tty->driver->type != TTY_DRIVER_TYPE_PTY) | 1196 | if (on_exit && tty->driver->type != TTY_DRIVER_TYPE_PTY) |
1197 | tty_vhangup(tty); | 1197 | tty_vhangup(tty); |
1198 | } else { | 1198 | } else { |
@@ -1200,7 +1200,7 @@ void disassociate_ctty(int on_exit) | |||
1200 | kill_pg(current->signal->tty_old_pgrp, SIGHUP, on_exit); | 1200 | kill_pg(current->signal->tty_old_pgrp, SIGHUP, on_exit); |
1201 | kill_pg(current->signal->tty_old_pgrp, SIGCONT, on_exit); | 1201 | kill_pg(current->signal->tty_old_pgrp, SIGCONT, on_exit); |
1202 | } | 1202 | } |
1203 | up(&tty_sem); | 1203 | mutex_unlock(&tty_mutex); |
1204 | unlock_kernel(); | 1204 | unlock_kernel(); |
1205 | return; | 1205 | return; |
1206 | } | 1206 | } |
@@ -1211,7 +1211,7 @@ void disassociate_ctty(int on_exit) | |||
1211 | } | 1211 | } |
1212 | 1212 | ||
1213 | /* Must lock changes to tty_old_pgrp */ | 1213 | /* Must lock changes to tty_old_pgrp */ |
1214 | down(&tty_sem); | 1214 | mutex_lock(&tty_mutex); |
1215 | current->signal->tty_old_pgrp = 0; | 1215 | current->signal->tty_old_pgrp = 0; |
1216 | tty->session = 0; | 1216 | tty->session = 0; |
1217 | tty->pgrp = -1; | 1217 | tty->pgrp = -1; |
@@ -1222,7 +1222,7 @@ void disassociate_ctty(int on_exit) | |||
1222 | p->signal->tty = NULL; | 1222 | p->signal->tty = NULL; |
1223 | } while_each_task_pid(current->signal->session, PIDTYPE_SID, p); | 1223 | } while_each_task_pid(current->signal->session, PIDTYPE_SID, p); |
1224 | read_unlock(&tasklist_lock); | 1224 | read_unlock(&tasklist_lock); |
1225 | up(&tty_sem); | 1225 | mutex_unlock(&tty_mutex); |
1226 | unlock_kernel(); | 1226 | unlock_kernel(); |
1227 | } | 1227 | } |
1228 | 1228 | ||
@@ -1306,7 +1306,7 @@ static inline ssize_t do_tty_write( | |||
1306 | ssize_t ret = 0, written = 0; | 1306 | ssize_t ret = 0, written = 0; |
1307 | unsigned int chunk; | 1307 | unsigned int chunk; |
1308 | 1308 | ||
1309 | if (down_interruptible(&tty->atomic_write)) { | 1309 | if (mutex_lock_interruptible(&tty->atomic_write_lock)) { |
1310 | return -ERESTARTSYS; | 1310 | return -ERESTARTSYS; |
1311 | } | 1311 | } |
1312 | 1312 | ||
@@ -1329,7 +1329,7 @@ static inline ssize_t do_tty_write( | |||
1329 | if (count < chunk) | 1329 | if (count < chunk) |
1330 | chunk = count; | 1330 | chunk = count; |
1331 | 1331 | ||
1332 | /* write_buf/write_cnt is protected by the atomic_write semaphore */ | 1332 | /* write_buf/write_cnt is protected by the atomic_write_lock mutex */ |
1333 | if (tty->write_cnt < chunk) { | 1333 | if (tty->write_cnt < chunk) { |
1334 | unsigned char *buf; | 1334 | unsigned char *buf; |
1335 | 1335 | ||
@@ -1338,7 +1338,7 @@ static inline ssize_t do_tty_write( | |||
1338 | 1338 | ||
1339 | buf = kmalloc(chunk, GFP_KERNEL); | 1339 | buf = kmalloc(chunk, GFP_KERNEL); |
1340 | if (!buf) { | 1340 | if (!buf) { |
1341 | up(&tty->atomic_write); | 1341 | mutex_unlock(&tty->atomic_write_lock); |
1342 | return -ENOMEM; | 1342 | return -ENOMEM; |
1343 | } | 1343 | } |
1344 | kfree(tty->write_buf); | 1344 | kfree(tty->write_buf); |
@@ -1374,7 +1374,7 @@ static inline ssize_t do_tty_write( | |||
1374 | inode->i_mtime = current_fs_time(inode->i_sb); | 1374 | inode->i_mtime = current_fs_time(inode->i_sb); |
1375 | ret = written; | 1375 | ret = written; |
1376 | } | 1376 | } |
1377 | up(&tty->atomic_write); | 1377 | mutex_unlock(&tty->atomic_write_lock); |
1378 | return ret; | 1378 | return ret; |
1379 | } | 1379 | } |
1380 | 1380 | ||
@@ -1442,8 +1442,8 @@ static inline void tty_line_name(struct tty_driver *driver, int index, char *p) | |||
1442 | 1442 | ||
1443 | /* | 1443 | /* |
1444 | * WSH 06/09/97: Rewritten to remove races and properly clean up after a | 1444 | * WSH 06/09/97: Rewritten to remove races and properly clean up after a |
1445 | * failed open. The new code protects the open with a semaphore, so it's | 1445 | * failed open. The new code protects the open with a mutex, so it's |
1446 | * really quite straightforward. The semaphore locking can probably be | 1446 | * really quite straightforward. The mutex locking can probably be |
1447 | * relaxed for the (most common) case of reopening a tty. | 1447 | * relaxed for the (most common) case of reopening a tty. |
1448 | */ | 1448 | */ |
1449 | static int init_dev(struct tty_driver *driver, int idx, | 1449 | static int init_dev(struct tty_driver *driver, int idx, |
@@ -1640,7 +1640,7 @@ fast_track: | |||
1640 | success: | 1640 | success: |
1641 | *ret_tty = tty; | 1641 | *ret_tty = tty; |
1642 | 1642 | ||
1643 | /* All paths come through here to release the semaphore */ | 1643 | /* All paths come through here to release the mutex */ |
1644 | end_init: | 1644 | end_init: |
1645 | return retval; | 1645 | return retval; |
1646 | 1646 | ||
@@ -1837,7 +1837,7 @@ static void release_dev(struct file * filp) | |||
1837 | /* Guard against races with tty->count changes elsewhere and | 1837 | /* Guard against races with tty->count changes elsewhere and |
1838 | opens on /dev/tty */ | 1838 | opens on /dev/tty */ |
1839 | 1839 | ||
1840 | down(&tty_sem); | 1840 | mutex_lock(&tty_mutex); |
1841 | tty_closing = tty->count <= 1; | 1841 | tty_closing = tty->count <= 1; |
1842 | o_tty_closing = o_tty && | 1842 | o_tty_closing = o_tty && |
1843 | (o_tty->count <= (pty_master ? 1 : 0)); | 1843 | (o_tty->count <= (pty_master ? 1 : 0)); |
@@ -1868,7 +1868,7 @@ static void release_dev(struct file * filp) | |||
1868 | 1868 | ||
1869 | printk(KERN_WARNING "release_dev: %s: read/write wait queue " | 1869 | printk(KERN_WARNING "release_dev: %s: read/write wait queue " |
1870 | "active!\n", tty_name(tty, buf)); | 1870 | "active!\n", tty_name(tty, buf)); |
1871 | up(&tty_sem); | 1871 | mutex_unlock(&tty_mutex); |
1872 | schedule(); | 1872 | schedule(); |
1873 | } | 1873 | } |
1874 | 1874 | ||
@@ -1934,7 +1934,7 @@ static void release_dev(struct file * filp) | |||
1934 | read_unlock(&tasklist_lock); | 1934 | read_unlock(&tasklist_lock); |
1935 | } | 1935 | } |
1936 | 1936 | ||
1937 | up(&tty_sem); | 1937 | mutex_unlock(&tty_mutex); |
1938 | 1938 | ||
1939 | /* check whether both sides are closing ... */ | 1939 | /* check whether both sides are closing ... */ |
1940 | if (!tty_closing || (o_tty && !o_tty_closing)) | 1940 | if (!tty_closing || (o_tty && !o_tty_closing)) |
@@ -2040,11 +2040,11 @@ retry_open: | |||
2040 | index = -1; | 2040 | index = -1; |
2041 | retval = 0; | 2041 | retval = 0; |
2042 | 2042 | ||
2043 | down(&tty_sem); | 2043 | mutex_lock(&tty_mutex); |
2044 | 2044 | ||
2045 | if (device == MKDEV(TTYAUX_MAJOR,0)) { | 2045 | if (device == MKDEV(TTYAUX_MAJOR,0)) { |
2046 | if (!current->signal->tty) { | 2046 | if (!current->signal->tty) { |
2047 | up(&tty_sem); | 2047 | mutex_unlock(&tty_mutex); |
2048 | return -ENXIO; | 2048 | return -ENXIO; |
2049 | } | 2049 | } |
2050 | driver = current->signal->tty->driver; | 2050 | driver = current->signal->tty->driver; |
@@ -2070,18 +2070,18 @@ retry_open: | |||
2070 | noctty = 1; | 2070 | noctty = 1; |
2071 | goto got_driver; | 2071 | goto got_driver; |
2072 | } | 2072 | } |
2073 | up(&tty_sem); | 2073 | mutex_unlock(&tty_mutex); |
2074 | return -ENODEV; | 2074 | return -ENODEV; |
2075 | } | 2075 | } |
2076 | 2076 | ||
2077 | driver = get_tty_driver(device, &index); | 2077 | driver = get_tty_driver(device, &index); |
2078 | if (!driver) { | 2078 | if (!driver) { |
2079 | up(&tty_sem); | 2079 | mutex_unlock(&tty_mutex); |
2080 | return -ENODEV; | 2080 | return -ENODEV; |
2081 | } | 2081 | } |
2082 | got_driver: | 2082 | got_driver: |
2083 | retval = init_dev(driver, index, &tty); | 2083 | retval = init_dev(driver, index, &tty); |
2084 | up(&tty_sem); | 2084 | mutex_unlock(&tty_mutex); |
2085 | if (retval) | 2085 | if (retval) |
2086 | return retval; | 2086 | return retval; |
2087 | 2087 | ||
@@ -2167,9 +2167,9 @@ static int ptmx_open(struct inode * inode, struct file * filp) | |||
2167 | } | 2167 | } |
2168 | up(&allocated_ptys_lock); | 2168 | up(&allocated_ptys_lock); |
2169 | 2169 | ||
2170 | down(&tty_sem); | 2170 | mutex_lock(&tty_mutex); |
2171 | retval = init_dev(ptm_driver, index, &tty); | 2171 | retval = init_dev(ptm_driver, index, &tty); |
2172 | up(&tty_sem); | 2172 | mutex_unlock(&tty_mutex); |
2173 | 2173 | ||
2174 | if (retval) | 2174 | if (retval) |
2175 | goto out; | 2175 | goto out; |
@@ -2915,8 +2915,8 @@ static void initialize_tty_struct(struct tty_struct *tty) | |||
2915 | init_waitqueue_head(&tty->write_wait); | 2915 | init_waitqueue_head(&tty->write_wait); |
2916 | init_waitqueue_head(&tty->read_wait); | 2916 | init_waitqueue_head(&tty->read_wait); |
2917 | INIT_WORK(&tty->hangup_work, do_tty_hangup, tty); | 2917 | INIT_WORK(&tty->hangup_work, do_tty_hangup, tty); |
2918 | sema_init(&tty->atomic_read, 1); | 2918 | mutex_init(&tty->atomic_read_lock); |
2919 | sema_init(&tty->atomic_write, 1); | 2919 | mutex_init(&tty->atomic_write_lock); |
2920 | spin_lock_init(&tty->read_lock); | 2920 | spin_lock_init(&tty->read_lock); |
2921 | INIT_LIST_HEAD(&tty->tty_files); | 2921 | INIT_LIST_HEAD(&tty->tty_files); |
2922 | INIT_WORK(&tty->SAK_work, NULL, NULL); | 2922 | INIT_WORK(&tty->SAK_work, NULL, NULL); |
diff --git a/drivers/char/vt.c b/drivers/char/vt.c index 86b31b87eb85..ca4844c527da 100644 --- a/drivers/char/vt.c +++ b/drivers/char/vt.c | |||
@@ -2489,7 +2489,7 @@ static int con_open(struct tty_struct *tty, struct file *filp) | |||
2489 | } | 2489 | } |
2490 | 2490 | ||
2491 | /* | 2491 | /* |
2492 | * We take tty_sem in here to prevent another thread from coming in via init_dev | 2492 | * We take tty_mutex in here to prevent another thread from coming in via init_dev |
2493 | * and taking a ref against the tty while we're in the process of forgetting | 2493 | * and taking a ref against the tty while we're in the process of forgetting |
2494 | * about it and cleaning things up. | 2494 | * about it and cleaning things up. |
2495 | * | 2495 | * |
@@ -2497,7 +2497,7 @@ static int con_open(struct tty_struct *tty, struct file *filp) | |||
2497 | */ | 2497 | */ |
2498 | static void con_close(struct tty_struct *tty, struct file *filp) | 2498 | static void con_close(struct tty_struct *tty, struct file *filp) |
2499 | { | 2499 | { |
2500 | down(&tty_sem); | 2500 | mutex_lock(&tty_mutex); |
2501 | acquire_console_sem(); | 2501 | acquire_console_sem(); |
2502 | if (tty && tty->count == 1) { | 2502 | if (tty && tty->count == 1) { |
2503 | struct vc_data *vc = tty->driver_data; | 2503 | struct vc_data *vc = tty->driver_data; |
@@ -2507,15 +2507,15 @@ static void con_close(struct tty_struct *tty, struct file *filp) | |||
2507 | tty->driver_data = NULL; | 2507 | tty->driver_data = NULL; |
2508 | release_console_sem(); | 2508 | release_console_sem(); |
2509 | vcs_remove_devfs(tty); | 2509 | vcs_remove_devfs(tty); |
2510 | up(&tty_sem); | 2510 | mutex_unlock(&tty_mutex); |
2511 | /* | 2511 | /* |
2512 | * tty_sem is released, but we still hold BKL, so there is | 2512 | * tty_mutex is released, but we still hold BKL, so there is |
2513 | * still exclusion against init_dev() | 2513 | * still exclusion against init_dev() |
2514 | */ | 2514 | */ |
2515 | return; | 2515 | return; |
2516 | } | 2516 | } |
2517 | release_console_sem(); | 2517 | release_console_sem(); |
2518 | up(&tty_sem); | 2518 | mutex_unlock(&tty_mutex); |
2519 | } | 2519 | } |
2520 | 2520 | ||
2521 | static void vc_init(struct vc_data *vc, unsigned int rows, | 2521 | static void vc_init(struct vc_data *vc, unsigned int rows, |
@@ -2869,9 +2869,9 @@ void unblank_screen(void) | |||
2869 | } | 2869 | } |
2870 | 2870 | ||
2871 | /* | 2871 | /* |
2872 | * We defer the timer blanking to work queue so it can take the console semaphore | 2872 | * We defer the timer blanking to work queue so it can take the console mutex |
2873 | * (console operations can still happen at irq time, but only from printk which | 2873 | * (console operations can still happen at irq time, but only from printk which |
2874 | * has the console semaphore. Not perfect yet, but better than no locking | 2874 | * has the console mutex. Not perfect yet, but better than no locking |
2875 | */ | 2875 | */ |
2876 | static void blank_screen_t(unsigned long dummy) | 2876 | static void blank_screen_t(unsigned long dummy) |
2877 | { | 2877 | { |