blob: 2623e177e8d61d501fe1c39dd57d3768bfcad481 [file] [log] [blame]
Christian Borntraeger611e0972008-06-20 15:24:08 +02001/*
2 * Copyright IBM Corp. 2001,2008
3 *
4 * This file contains the IRQ specific code for hvc_console
5 *
6 */
7
8#include <linux/interrupt.h>
9
10#include "hvc_console.h"
11
12static irqreturn_t hvc_handle_interrupt(int irq, void *dev_instance)
13{
14 /* if hvc_poll request a repoll, then kick the hvcd thread */
15 if (hvc_poll(dev_instance))
16 hvc_kick();
17 return IRQ_HANDLED;
18}
19
20/*
21 * For IRQ based systems these callbacks can be used
22 */
23int notifier_add_irq(struct hvc_struct *hp, int irq)
24{
25 int rc;
26
27 if (!irq) {
28 hp->irq_requested = 0;
29 return 0;
30 }
31 rc = request_irq(irq, hvc_handle_interrupt, IRQF_DISABLED,
32 "hvc_console", hp);
33 if (!rc)
34 hp->irq_requested = 1;
35 return rc;
36}
37
38void notifier_del_irq(struct hvc_struct *hp, int irq)
39{
Milton Millerc21f7a52009-01-08 02:14:21 +000040 if (!hp->irq_requested)
Christian Borntraeger611e0972008-06-20 15:24:08 +020041 return;
42 free_irq(irq, hp);
43 hp->irq_requested = 0;
44}
Hendrik Bruecknerfc362e22008-10-13 23:12:48 +000045
46void notifier_hangup_irq(struct hvc_struct *hp, int irq)
47{
48 notifier_del_irq(hp, irq);
49}