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>
} /* else count == 0 */
tty->driver_data = hp;
} /* else count == 0 */
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)
rc = hp->ops->notifier_add(hp, hp->data);
if (hp->ops->notifier_add)
rc = hp->ops->notifier_add(hp, hp->data);
* tty fields and return the kref reference.
*/
if (rc) {
* 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);
tty_kref_put(tty);
tty->driver_data = NULL;
tty_port_put(&hp->port);
spin_lock_irqsave(&hp->lock, flags);
if (--hp->count == 0) {
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);
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);
if (hp->ops->notifier_del)
hp->ops->notifier_del(hp, hp->data);
temp_open_count = hp->count;
hp->count = 0;
hp->n_outbuf = 0;
temp_open_count = hp->count;
hp->count = 0;
hp->n_outbuf = 0;
spin_unlock_irqrestore(&hp->lock, flags);
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);
if (hp->ops->notifier_hangup)
hp->ops->notifier_hangup(hp, hp->data);
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);
- if (!hp->tty) {
- spin_unlock_irqrestore(&hp->lock, hvc_flags);
+ tty = tty_port_tty_get(&hp->port);
+ if (!tty)
- }
- 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);
spin_unlock_irqrestore(&hp->lock, hvc_flags);
tty_do_resize(tty, &ws);
}
/* 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)
goto bail;
if (tty == NULL)
goto bail;
tty_flip_buffer_push(tty);
}
tty_flip_buffer_push(tty);
}
- if (tty)
- tty_kref_put(tty);
unsigned long flags;
struct tty_struct *tty;
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;
if (hp->index < MAX_NR_HVC_CONSOLES)
vtermnos[hp->index] = -1;
struct tty_port port;
spinlock_t lock;
int index;
struct tty_port port;
spinlock_t lock;
int index;
- struct tty_struct *tty;
int count;
int do_wakeup;
char *outbuf;
int count;
int do_wakeup;
char *outbuf;
pr_devel("HVSI@%x: open !\n", pv->termno);
/* Keep track of the tty data structure */
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);