Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 304152
b: refs/heads/master
c: 0146b69
h: refs/heads/master
v: v3
  • Loading branch information
Jiri Slaby authored and Greg Kroah-Hartman committed Apr 9, 2012
1 parent 1ecb0a3 commit 712b8bd
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 21 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: 85bbc003b24335e253a392f6a9874103b77abb36
refs/heads/master: 0146b6939074ebe14ece3604fd00e7be128a3812
40 changes: 21 additions & 19 deletions trunk/drivers/tty/hvc/hvc_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,18 +313,18 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
if (!(hp = hvc_get_by_index(tty->index)))
return -ENODEV;

spin_lock_irqsave(&hp->lock, flags);
spin_lock_irqsave(&hp->port.lock, flags);
/* Check and then increment for fast path open. */
if (hp->count++ > 0) {
if (hp->port.count++ > 0) {
spin_unlock_irqrestore(&hp->port.lock, flags);
/* FIXME why taking a reference here? */
tty_kref_get(tty);
spin_unlock_irqrestore(&hp->lock, flags);
hvc_kick();
return 0;
} /* else count == 0 */
spin_unlock_irqrestore(&hp->port.lock, flags);

tty->driver_data = hp;
spin_unlock_irqrestore(&hp->lock, flags);

tty_port_tty_set(&hp->port, tty);

if (hp->ops->notifier_add)
Expand Down Expand Up @@ -367,10 +367,10 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)

hp = tty->driver_data;

spin_lock_irqsave(&hp->lock, flags);
spin_lock_irqsave(&hp->port.lock, flags);

if (--hp->count == 0) {
spin_unlock_irqrestore(&hp->lock, flags);
if (--hp->port.count == 0) {
spin_unlock_irqrestore(&hp->port.lock, flags);
/* We are done with the tty pointer now. */
tty_port_tty_set(&hp->port, NULL);

Expand All @@ -387,10 +387,10 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
*/
tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
} else {
if (hp->count < 0)
if (hp->port.count < 0)
printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
hp->vtermno, hp->count);
spin_unlock_irqrestore(&hp->lock, flags);
hp->vtermno, hp->port.count);
spin_unlock_irqrestore(&hp->port.lock, flags);
}

tty_kref_put(tty);
Expand All @@ -409,24 +409,25 @@ static void hvc_hangup(struct tty_struct *tty)
/* cancel pending tty resize work */
cancel_work_sync(&hp->tty_resize);

spin_lock_irqsave(&hp->lock, flags);
spin_lock_irqsave(&hp->port.lock, flags);

/*
* The N_TTY line discipline has problems such that in a close vs
* open->hangup case this can be called after the final close so prevent
* that from happening for now.
*/
if (hp->count <= 0) {
spin_unlock_irqrestore(&hp->lock, flags);
if (hp->port.count <= 0) {
spin_unlock_irqrestore(&hp->port.lock, flags);
return;
}

temp_open_count = hp->count;
hp->count = 0;
hp->n_outbuf = 0;
spin_unlock_irqrestore(&hp->lock, flags);
temp_open_count = hp->port.count;
hp->port.count = 0;
spin_unlock_irqrestore(&hp->port.lock, flags);
tty_port_tty_set(&hp->port, NULL);

hp->n_outbuf = 0;

if (hp->ops->notifier_hangup)
hp->ops->notifier_hangup(hp, hp->data);

Expand Down Expand Up @@ -474,7 +475,8 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
if (!hp)
return -EPIPE;

if (hp->count <= 0)
/* FIXME what's this (unprotected) check for? */
if (hp->port.count <= 0)
return -EIO;

spin_lock_irqsave(&hp->lock, flags);
Expand Down
1 change: 0 additions & 1 deletion trunk/drivers/tty/hvc/hvc_console.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ struct hvc_struct {
struct tty_port port;
spinlock_t lock;
int index;
int count;
int do_wakeup;
char *outbuf;
int outbuf_size;
Expand Down

0 comments on commit 712b8bd

Please sign in to comment.