Linux 4.16.11
[linux/fpc-iii.git] / drivers / tty / hvc / hvc_irq.c
blob4b255dfef2cc6b1f07ca733c1b375f8ec3ad9034
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Copyright IBM Corp. 2001,2008
5 * This file contains the IRQ specific code for hvc_console
7 */
9 #include <linux/interrupt.h>
11 #include "hvc_console.h"
13 static irqreturn_t hvc_handle_interrupt(int irq, void *dev_instance)
15 /* if hvc_poll request a repoll, then kick the hvcd thread */
16 if (hvc_poll(dev_instance))
17 hvc_kick();
20 * We're safe to always return IRQ_HANDLED as the hvcd thread will
21 * iterate through each hvc_struct.
23 return IRQ_HANDLED;
27 * For IRQ based systems these callbacks can be used
29 int notifier_add_irq(struct hvc_struct *hp, int irq)
31 int rc;
33 if (!irq) {
34 hp->irq_requested = 0;
35 return 0;
37 rc = request_irq(irq, hvc_handle_interrupt, hp->flags,
38 "hvc_console", hp);
39 if (!rc)
40 hp->irq_requested = 1;
41 return rc;
44 void notifier_del_irq(struct hvc_struct *hp, int irq)
46 if (!hp->irq_requested)
47 return;
48 free_irq(irq, hp);
49 hp->irq_requested = 0;
52 void notifier_hangup_irq(struct hvc_struct *hp, int irq)
54 notifier_del_irq(hp, irq);