Christian Borntraeger | 611e097 | 2008-06-20 15:24:08 +0200 | [diff] [blame] | 1 | /* |
| 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 | |
| 12 | static 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(); |
Sam Mendoza-Jonas | bbc3dfe8 | 2016-07-11 13:38:57 +1000 | [diff] [blame] | 17 | |
| 18 | /* |
| 19 | * We're safe to always return IRQ_HANDLED as the hvcd thread will |
| 20 | * iterate through each hvc_struct. |
| 21 | */ |
Christian Borntraeger | 611e097 | 2008-06-20 15:24:08 +0200 | [diff] [blame] | 22 | return IRQ_HANDLED; |
| 23 | } |
| 24 | |
| 25 | /* |
| 26 | * For IRQ based systems these callbacks can be used |
| 27 | */ |
| 28 | int notifier_add_irq(struct hvc_struct *hp, int irq) |
| 29 | { |
| 30 | int rc; |
| 31 | |
| 32 | if (!irq) { |
| 33 | hp->irq_requested = 0; |
| 34 | return 0; |
| 35 | } |
Sam Mendoza-Jonas | bbc3dfe8 | 2016-07-11 13:38:57 +1000 | [diff] [blame] | 36 | rc = request_irq(irq, hvc_handle_interrupt, hp->flags, |
| 37 | "hvc_console", hp); |
Christian Borntraeger | 611e097 | 2008-06-20 15:24:08 +0200 | [diff] [blame] | 38 | if (!rc) |
| 39 | hp->irq_requested = 1; |
| 40 | return rc; |
| 41 | } |
| 42 | |
| 43 | void notifier_del_irq(struct hvc_struct *hp, int irq) |
| 44 | { |
Milton Miller | c21f7a5 | 2009-01-08 02:14:21 +0000 | [diff] [blame] | 45 | if (!hp->irq_requested) |
Christian Borntraeger | 611e097 | 2008-06-20 15:24:08 +0200 | [diff] [blame] | 46 | return; |
| 47 | free_irq(irq, hp); |
| 48 | hp->irq_requested = 0; |
| 49 | } |
Hendrik Brueckner | fc362e2 | 2008-10-13 23:12:48 +0000 | [diff] [blame] | 50 | |
| 51 | void notifier_hangup_irq(struct hvc_struct *hp, int irq) |
| 52 | { |
| 53 | notifier_del_irq(hp, irq); |
| 54 | } |