Commit fc362e2e authored by Hendrik Brueckner's avatar Hendrik Brueckner Committed by Benjamin Herrenschmidt

hvc_console: Add a hangup notifier for backends

I have added a hangup notifier that can be used by hvc console
backends to handle a tty hangup. The default irq hangup notifier
calls the notifier_del_irq() for compatibility.
Acked-by: default avatarChristian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: default avatarHendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent a02efb90
...@@ -418,8 +418,8 @@ static void hvc_hangup(struct tty_struct *tty) ...@@ -418,8 +418,8 @@ static void hvc_hangup(struct tty_struct *tty)
spin_unlock_irqrestore(&hp->lock, flags); spin_unlock_irqrestore(&hp->lock, flags);
if (hp->ops->notifier_del) if (hp->ops->notifier_hangup)
hp->ops->notifier_del(hp, hp->data); hp->ops->notifier_hangup(hp, hp->data);
while(temp_open_count) { while(temp_open_count) {
--temp_open_count; --temp_open_count;
......
...@@ -65,9 +65,10 @@ struct hv_ops { ...@@ -65,9 +65,10 @@ struct hv_ops {
int (*get_chars)(uint32_t vtermno, char *buf, int count); int (*get_chars)(uint32_t vtermno, char *buf, int count);
int (*put_chars)(uint32_t vtermno, const char *buf, int count); int (*put_chars)(uint32_t vtermno, const char *buf, int count);
/* Callbacks for notification. Called in open and close */ /* Callbacks for notification. Called in open, close and hangup */
int (*notifier_add)(struct hvc_struct *hp, int irq); int (*notifier_add)(struct hvc_struct *hp, int irq);
void (*notifier_del)(struct hvc_struct *hp, int irq); void (*notifier_del)(struct hvc_struct *hp, int irq);
void (*notifier_hangup)(struct hvc_struct *hp, int irq);
}; };
/* Register a vterm and a slot index for use as a console (console_init) */ /* Register a vterm and a slot index for use as a console (console_init) */
...@@ -86,6 +87,7 @@ void hvc_kick(void); ...@@ -86,6 +87,7 @@ void hvc_kick(void);
/* default notifier for irq based notification */ /* default notifier for irq based notification */
extern int notifier_add_irq(struct hvc_struct *hp, int data); extern int notifier_add_irq(struct hvc_struct *hp, int data);
extern void notifier_del_irq(struct hvc_struct *hp, int data); extern void notifier_del_irq(struct hvc_struct *hp, int data);
extern void notifier_hangup_irq(struct hvc_struct *hp, int data);
#if defined(CONFIG_XMON) && defined(CONFIG_SMP) #if defined(CONFIG_XMON) && defined(CONFIG_SMP)
......
...@@ -42,3 +42,8 @@ void notifier_del_irq(struct hvc_struct *hp, int irq) ...@@ -42,3 +42,8 @@ void notifier_del_irq(struct hvc_struct *hp, int irq)
free_irq(irq, hp); free_irq(irq, hp);
hp->irq_requested = 0; hp->irq_requested = 0;
} }
void notifier_hangup_irq(struct hvc_struct *hp, int irq)
{
notifier_del_irq(hp, irq);
}
...@@ -202,6 +202,7 @@ static struct hv_ops hvc_get_put_ops = { ...@@ -202,6 +202,7 @@ static struct hv_ops hvc_get_put_ops = {
.put_chars = put_chars, .put_chars = put_chars,
.notifier_add = notifier_add_irq, .notifier_add = notifier_add_irq,
.notifier_del = notifier_del_irq, .notifier_del = notifier_del_irq,
.notifier_hangup = notifier_hangup_irq,
}; };
static int __devinit hvc_vio_probe(struct vio_dev *vdev, static int __devinit hvc_vio_probe(struct vio_dev *vdev,
......
...@@ -82,6 +82,7 @@ static struct hv_ops hvc_get_put_ops = { ...@@ -82,6 +82,7 @@ static struct hv_ops hvc_get_put_ops = {
.put_chars = hvc_put_chars, .put_chars = hvc_put_chars,
.notifier_add = notifier_add_irq, .notifier_add = notifier_add_irq,
.notifier_del = notifier_del_irq, .notifier_del = notifier_del_irq,
.notifier_hangup = notifier_hangup_irq,
}; };
static int __devinit hvc_vio_probe(struct vio_dev *vdev, static int __devinit hvc_vio_probe(struct vio_dev *vdev,
......
...@@ -102,6 +102,7 @@ static struct hv_ops hvc_ops = { ...@@ -102,6 +102,7 @@ static struct hv_ops hvc_ops = {
.put_chars = write_console, .put_chars = write_console,
.notifier_add = notifier_add_irq, .notifier_add = notifier_add_irq,
.notifier_del = notifier_del_irq, .notifier_del = notifier_del_irq,
.notifier_hangup = notifier_hangup_irq,
}; };
static int __init xen_init(void) static int __init xen_init(void)
......
...@@ -198,6 +198,7 @@ static int __devinit virtcons_probe(struct virtio_device *dev) ...@@ -198,6 +198,7 @@ static int __devinit virtcons_probe(struct virtio_device *dev)
virtio_cons.put_chars = put_chars; virtio_cons.put_chars = put_chars;
virtio_cons.notifier_add = notifier_add_vio; virtio_cons.notifier_add = notifier_add_vio;
virtio_cons.notifier_del = notifier_del_vio; virtio_cons.notifier_del = notifier_del_vio;
virtio_cons.notifier_hangup = notifier_del_vio;
/* The first argument of hvc_alloc() is the virtual console number, so /* The first argument of hvc_alloc() is the virtual console number, so
* we use zero. The second argument is the parameter for the * we use zero. The second argument is the parameter for the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment