Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 263816
b: refs/heads/master
c: f71f948
h: refs/heads/master
v: v3
  • Loading branch information
Al Viro authored and Linus Torvalds committed Sep 15, 2011
1 parent 0942c89 commit cb7ac86
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: fbfe9c847edf57ac8232aeafb290f272289893a3
refs/heads/master: f71f94845e0126884eca8ce57a92e30b189c8e71
25 changes: 12 additions & 13 deletions trunk/arch/um/drivers/line.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,8 @@ int line_setup_irq(int fd, int input, int output, struct line *line, void *data)
* is done under a spinlock. Checking whether the device is in use is
* line->tty->count > 1, also under the spinlock.
*
* tty->count serves to decide whether the device should be enabled or
* disabled on the host. If it's equal to 1, then we are doing the
* line->count serves to decide whether the device should be enabled or
* disabled on the host. If it's equal to 0, then we are doing the
* first open or last close. Otherwise, open and close just return.
*/

Expand All @@ -414,16 +414,16 @@ int line_open(struct line *lines, struct tty_struct *tty)
goto out_unlock;

err = 0;
if (tty->count > 1)
if (line->count++)
goto out_unlock;

spin_unlock(&line->count_lock);

BUG_ON(tty->driver_data);
tty->driver_data = line;
line->tty = tty;

spin_unlock(&line->count_lock);
err = enable_chan(line);
if (err)
if (err) /* line_close() will be called by our caller */
return err;

INIT_DELAYED_WORK(&line->task, line_timer_cb);
Expand All @@ -436,7 +436,7 @@ int line_open(struct line *lines, struct tty_struct *tty)
chan_window_size(&line->chan_list, &tty->winsize.ws_row,
&tty->winsize.ws_col);

return err;
return 0;

out_unlock:
spin_unlock(&line->count_lock);
Expand All @@ -460,17 +460,16 @@ void line_close(struct tty_struct *tty, struct file * filp)
flush_buffer(line);

spin_lock(&line->count_lock);
if (!line->valid)
goto out_unlock;
BUG_ON(!line->valid);

if (tty->count > 1)
if (--line->count)
goto out_unlock;

spin_unlock(&line->count_lock);

line->tty = NULL;
tty->driver_data = NULL;

spin_unlock(&line->count_lock);

if (line->sigio) {
unregister_winch(tty);
line->sigio = 0;
Expand Down Expand Up @@ -498,7 +497,7 @@ static int setup_one_line(struct line *lines, int n, char *init, int init_prio,

spin_lock(&line->count_lock);

if (line->tty != NULL) {
if (line->count) {
*error_out = "Device is already open";
goto out;
}
Expand Down
1 change: 1 addition & 0 deletions trunk/arch/um/include/shared/line.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ struct line_driver {
struct line {
struct tty_struct *tty;
spinlock_t count_lock;
unsigned long count;
int valid;

char *init_str;
Expand Down

0 comments on commit cb7ac86

Please sign in to comment.