Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Christian Borntraeger | 611e097 | 2008-06-20 15:24:08 +0200 | [diff] [blame] | 2 | /* |
| 3 | * Copyright IBM Corp. 2001,2008 |
| 4 | * |
| 5 | * This file contains the IRQ specific code for hvc_console |
| 6 | * |
| 7 | */ |
| 8 | |
| 9 | #include <linux/interrupt.h> |
| 10 | |
| 11 | #include "hvc_console.h" |
| 12 | |
| 13 | static irqreturn_t hvc_handle_interrupt(int irq, void *dev_instance) |
| 14 | { |
| 15 | /* if hvc_poll request a repoll, then kick the hvcd thread */ |
| 16 | if (hvc_poll(dev_instance)) |
| 17 | hvc_kick(); |
Sam Mendoza-Jonas | bbc3dfe8 | 2016-07-11 13:38:57 +1000 | [diff] [blame] | 18 | |
| 19 | /* |
| 20 | * We're safe to always return IRQ_HANDLED as the hvcd thread will |
| 21 | * iterate through each hvc_struct. |
| 22 | */ |
Christian Borntraeger | 611e097 | 2008-06-20 15:24:08 +0200 | [diff] [blame] | 23 | return IRQ_HANDLED; |
| 24 | } |
| 25 | |
| 26 | /* |
| 27 | * For IRQ based systems these callbacks can be used |
| 28 | */ |
| 29 | int notifier_add_irq(struct hvc_struct *hp, int irq) |
| 30 | { |
| 31 | int rc; |
| 32 | |
| 33 | if (!irq) { |
| 34 | hp->irq_requested = 0; |
| 35 | return 0; |
| 36 | } |
Sam Mendoza-Jonas | bbc3dfe8 | 2016-07-11 13:38:57 +1000 | [diff] [blame] | 37 | rc = request_irq(irq, hvc_handle_interrupt, hp->flags, |
| 38 | "hvc_console", hp); |
Christian Borntraeger | 611e097 | 2008-06-20 15:24:08 +0200 | [diff] [blame] | 39 | if (!rc) |
| 40 | hp->irq_requested = 1; |
| 41 | return rc; |
| 42 | } |
| 43 | |
| 44 | void notifier_del_irq(struct hvc_struct *hp, int irq) |
| 45 | { |
Milton Miller | c21f7a5 | 2009-01-08 02:14:21 +0000 | [diff] [blame] | 46 | if (!hp->irq_requested) |
Christian Borntraeger | 611e097 | 2008-06-20 15:24:08 +0200 | [diff] [blame] | 47 | return; |
| 48 | free_irq(irq, hp); |
| 49 | hp->irq_requested = 0; |
| 50 | } |
Hendrik Brueckner | fc362e2 | 2008-10-13 23:12:48 +0000 | [diff] [blame] | 51 | |
| 52 | void notifier_hangup_irq(struct hvc_struct *hp, int irq) |
| 53 | { |
| 54 | notifier_del_irq(hp, irq); |
| 55 | } |