TTY: HVC, use tty from tty_port
The driver already used refcounting. So we just switch it to tty_port helpers. And switch to tty_port->lock for tty. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: linuxppc-dev@lists.ozlabs.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
f3d9f25097
commit
85bbc003b2
3 changed files with 16 additions and 23 deletions
|
@ -323,11 +323,10 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
|
||||||
} /* else count == 0 */
|
} /* else count == 0 */
|
||||||
|
|
||||||
tty->driver_data = hp;
|
tty->driver_data = hp;
|
||||||
|
|
||||||
hp->tty = tty_kref_get(tty);
|
|
||||||
|
|
||||||
spin_unlock_irqrestore(&hp->lock, flags);
|
spin_unlock_irqrestore(&hp->lock, flags);
|
||||||
|
|
||||||
|
tty_port_tty_set(&hp->port, tty);
|
||||||
|
|
||||||
if (hp->ops->notifier_add)
|
if (hp->ops->notifier_add)
|
||||||
rc = hp->ops->notifier_add(hp, hp->data);
|
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.
|
* tty fields and return the kref reference.
|
||||||
*/
|
*/
|
||||||
if (rc) {
|
if (rc) {
|
||||||
spin_lock_irqsave(&hp->lock, flags);
|
tty_port_tty_set(&hp->port, NULL);
|
||||||
hp->tty = NULL;
|
|
||||||
spin_unlock_irqrestore(&hp->lock, flags);
|
|
||||||
tty_kref_put(tty);
|
tty_kref_put(tty);
|
||||||
tty->driver_data = NULL;
|
tty->driver_data = NULL;
|
||||||
tty_port_put(&hp->port);
|
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);
|
spin_lock_irqsave(&hp->lock, flags);
|
||||||
|
|
||||||
if (--hp->count == 0) {
|
if (--hp->count == 0) {
|
||||||
/* We are done with the tty pointer now. */
|
|
||||||
hp->tty = NULL;
|
|
||||||
spin_unlock_irqrestore(&hp->lock, flags);
|
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)
|
if (hp->ops->notifier_del)
|
||||||
hp->ops->notifier_del(hp, hp->data);
|
hp->ops->notifier_del(hp, hp->data);
|
||||||
|
@ -427,9 +424,8 @@ static void hvc_hangup(struct tty_struct *tty)
|
||||||
temp_open_count = hp->count;
|
temp_open_count = hp->count;
|
||||||
hp->count = 0;
|
hp->count = 0;
|
||||||
hp->n_outbuf = 0;
|
hp->n_outbuf = 0;
|
||||||
hp->tty = NULL;
|
|
||||||
|
|
||||||
spin_unlock_irqrestore(&hp->lock, flags);
|
spin_unlock_irqrestore(&hp->lock, flags);
|
||||||
|
tty_port_tty_set(&hp->port, NULL);
|
||||||
|
|
||||||
if (hp->ops->notifier_hangup)
|
if (hp->ops->notifier_hangup)
|
||||||
hp->ops->notifier_hangup(hp, hp->data);
|
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);
|
hp = container_of(work, struct hvc_struct, tty_resize);
|
||||||
|
|
||||||
spin_lock_irqsave(&hp->lock, hvc_flags);
|
tty = tty_port_tty_get(&hp->port);
|
||||||
if (!hp->tty) {
|
if (!tty)
|
||||||
spin_unlock_irqrestore(&hp->lock, hvc_flags);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
spin_lock_irqsave(&hp->lock, hvc_flags);
|
||||||
ws = hp->ws;
|
ws = hp->ws;
|
||||||
tty = tty_kref_get(hp->tty);
|
|
||||||
spin_unlock_irqrestore(&hp->lock, hvc_flags);
|
spin_unlock_irqrestore(&hp->lock, hvc_flags);
|
||||||
|
|
||||||
tty_do_resize(tty, &ws);
|
tty_do_resize(tty, &ws);
|
||||||
|
@ -601,7 +596,7 @@ int hvc_poll(struct hvc_struct *hp)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No tty attached, just skip */
|
/* No tty attached, just skip */
|
||||||
tty = tty_kref_get(hp->tty);
|
tty = tty_port_tty_get(&hp->port);
|
||||||
if (tty == NULL)
|
if (tty == NULL)
|
||||||
goto bail;
|
goto bail;
|
||||||
|
|
||||||
|
@ -681,7 +676,6 @@ int hvc_poll(struct hvc_struct *hp)
|
||||||
|
|
||||||
tty_flip_buffer_push(tty);
|
tty_flip_buffer_push(tty);
|
||||||
}
|
}
|
||||||
if (tty)
|
|
||||||
tty_kref_put(tty);
|
tty_kref_put(tty);
|
||||||
|
|
||||||
return poll_mask;
|
return poll_mask;
|
||||||
|
@ -880,9 +874,9 @@ int hvc_remove(struct hvc_struct *hp)
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
struct tty_struct *tty;
|
struct tty_struct *tty;
|
||||||
|
|
||||||
spin_lock_irqsave(&hp->lock, flags);
|
tty = tty_port_tty_get(&hp->port);
|
||||||
tty = tty_kref_get(hp->tty);
|
|
||||||
|
|
||||||
|
spin_lock_irqsave(&hp->lock, flags);
|
||||||
if (hp->index < MAX_NR_HVC_CONSOLES)
|
if (hp->index < MAX_NR_HVC_CONSOLES)
|
||||||
vtermnos[hp->index] = -1;
|
vtermnos[hp->index] = -1;
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,6 @@ struct hvc_struct {
|
||||||
struct tty_port port;
|
struct tty_port port;
|
||||||
spinlock_t lock;
|
spinlock_t lock;
|
||||||
int index;
|
int index;
|
||||||
struct tty_struct *tty;
|
|
||||||
int count;
|
int count;
|
||||||
int do_wakeup;
|
int do_wakeup;
|
||||||
char *outbuf;
|
char *outbuf;
|
||||||
|
|
|
@ -377,7 +377,7 @@ int hvsilib_open(struct hvsi_priv *pv, struct hvc_struct *hp)
|
||||||
pr_devel("HVSI@%x: open !\n", pv->termno);
|
pr_devel("HVSI@%x: open !\n", pv->termno);
|
||||||
|
|
||||||
/* Keep track of the tty data structure */
|
/* 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);
|
hvsilib_establish(pv);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue