From 1ecb0a32d2c2f8dc2b7fe964f79a7de6a0e818a5 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Mon, 2 Apr 2012 13:54:22 +0200 Subject: [PATCH] --- yaml --- r: 304151 b: refs/heads/master c: 85bbc003b24335e253a392f6a9874103b77abb36 h: refs/heads/master i: 304149: 77881a0fb2a3d32c15424a8f42e1f7eea0ea0c3f 304147: 9b0c5f76b7c20cbe3e381d2095c8e43788c3ccac 304143: 90c8d0a9e48932012d2877740a2c0164d788b037 v: v3 --- [refs] | 2 +- trunk/drivers/tty/hvc/hvc_console.c | 36 ++++++++++++----------------- trunk/drivers/tty/hvc/hvc_console.h | 1 - trunk/drivers/tty/hvc/hvsi_lib.c | 2 +- 4 files changed, 17 insertions(+), 24 deletions(-) diff --git a/[refs] b/[refs] index acafb80b5b0f..08651414c315 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: f3d9f25097b62eaeb9e5b71358b863c7bf54c600 +refs/heads/master: 85bbc003b24335e253a392f6a9874103b77abb36 diff --git a/trunk/drivers/tty/hvc/hvc_console.c b/trunk/drivers/tty/hvc/hvc_console.c index 12a42730d3c8..92b7f5d5441f 100644 --- a/trunk/drivers/tty/hvc/hvc_console.c +++ b/trunk/drivers/tty/hvc/hvc_console.c @@ -323,11 +323,10 @@ static int hvc_open(struct tty_struct *tty, struct file * filp) } /* else count == 0 */ tty->driver_data = hp; - - hp->tty = tty_kref_get(tty); - spin_unlock_irqrestore(&hp->lock, flags); + tty_port_tty_set(&hp->port, tty); + if (hp->ops->notifier_add) rc = hp->ops->notifier_add(hp, hp->data); @@ -338,9 +337,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp) * tty fields and return the kref reference. */ if (rc) { - spin_lock_irqsave(&hp->lock, flags); - hp->tty = NULL; - spin_unlock_irqrestore(&hp->lock, flags); + tty_port_tty_set(&hp->port, NULL); tty_kref_put(tty); tty->driver_data = NULL; tty_port_put(&hp->port); @@ -373,9 +370,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp) spin_lock_irqsave(&hp->lock, flags); if (--hp->count == 0) { - /* We are done with the tty pointer now. */ - hp->tty = NULL; spin_unlock_irqrestore(&hp->lock, flags); + /* We are done with the tty pointer now. */ + tty_port_tty_set(&hp->port, NULL); if (hp->ops->notifier_del) hp->ops->notifier_del(hp, hp->data); @@ -427,9 +424,8 @@ static void hvc_hangup(struct tty_struct *tty) temp_open_count = hp->count; hp->count = 0; hp->n_outbuf = 0; - hp->tty = NULL; - spin_unlock_irqrestore(&hp->lock, flags); + tty_port_tty_set(&hp->port, NULL); if (hp->ops->notifier_hangup) hp->ops->notifier_hangup(hp, hp->data); @@ -526,13 +522,12 @@ static void hvc_set_winsz(struct work_struct *work) hp = container_of(work, struct hvc_struct, tty_resize); - spin_lock_irqsave(&hp->lock, hvc_flags); - if (!hp->tty) { - spin_unlock_irqrestore(&hp->lock, hvc_flags); + tty = tty_port_tty_get(&hp->port); + if (!tty) return; - } - ws = hp->ws; - tty = tty_kref_get(hp->tty); + + spin_lock_irqsave(&hp->lock, hvc_flags); + ws = hp->ws; spin_unlock_irqrestore(&hp->lock, hvc_flags); tty_do_resize(tty, &ws); @@ -601,7 +596,7 @@ int hvc_poll(struct hvc_struct *hp) } /* No tty attached, just skip */ - tty = tty_kref_get(hp->tty); + tty = tty_port_tty_get(&hp->port); if (tty == NULL) goto bail; @@ -681,8 +676,7 @@ int hvc_poll(struct hvc_struct *hp) tty_flip_buffer_push(tty); } - if (tty) - tty_kref_put(tty); + tty_kref_put(tty); return poll_mask; } @@ -880,9 +874,9 @@ int hvc_remove(struct hvc_struct *hp) unsigned long flags; struct tty_struct *tty; - spin_lock_irqsave(&hp->lock, flags); - tty = tty_kref_get(hp->tty); + tty = tty_port_tty_get(&hp->port); + spin_lock_irqsave(&hp->lock, flags); if (hp->index < MAX_NR_HVC_CONSOLES) vtermnos[hp->index] = -1; diff --git a/trunk/drivers/tty/hvc/hvc_console.h b/trunk/drivers/tty/hvc/hvc_console.h index 926d9e4b6db7..594a28fe0da0 100644 --- a/trunk/drivers/tty/hvc/hvc_console.h +++ b/trunk/drivers/tty/hvc/hvc_console.h @@ -49,7 +49,6 @@ struct hvc_struct { struct tty_port port; spinlock_t lock; int index; - struct tty_struct *tty; int count; int do_wakeup; char *outbuf; diff --git a/trunk/drivers/tty/hvc/hvsi_lib.c b/trunk/drivers/tty/hvc/hvsi_lib.c index 6f4dd83d8695..59c135dd5d20 100644 --- a/trunk/drivers/tty/hvc/hvsi_lib.c +++ b/trunk/drivers/tty/hvc/hvsi_lib.c @@ -377,7 +377,7 @@ int hvsilib_open(struct hvsi_priv *pv, struct hvc_struct *hp) pr_devel("HVSI@%x: open !\n", pv->termno); /* Keep track of the tty data structure */ - pv->tty = tty_kref_get(hp->tty); + pv->tty = tty_port_tty_get(&hp->port); hvsilib_establish(pv);