Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * Copyright IBM Corp. 2001,2008
0004  *
0005  * This file contains the IRQ specific code for hvc_console
0006  *
0007  */
0008 
0009 #include <linux/interrupt.h>
0010 
0011 #include "hvc_console.h"
0012 
0013 static irqreturn_t hvc_handle_interrupt(int irq, void *dev_instance)
0014 {
0015     /* if hvc_poll request a repoll, then kick the hvcd thread */
0016     if (hvc_poll(dev_instance))
0017         hvc_kick();
0018 
0019     /*
0020      * We're safe to always return IRQ_HANDLED as the hvcd thread will
0021      * iterate through each hvc_struct.
0022      */
0023     return IRQ_HANDLED;
0024 }
0025 
0026 /*
0027  * For IRQ based systems these callbacks can be used
0028  */
0029 int notifier_add_irq(struct hvc_struct *hp, int irq)
0030 {
0031     int rc;
0032 
0033     if (!irq) {
0034         hp->irq_requested = 0;
0035         return 0;
0036     }
0037     rc = request_irq(irq, hvc_handle_interrupt, hp->flags,
0038             "hvc_console", hp);
0039     if (!rc)
0040         hp->irq_requested = 1;
0041     return rc;
0042 }
0043 
0044 void notifier_del_irq(struct hvc_struct *hp, int irq)
0045 {
0046     if (!hp->irq_requested)
0047         return;
0048     free_irq(irq, hp);
0049     hp->irq_requested = 0;
0050 }
0051 
0052 void notifier_hangup_irq(struct hvc_struct *hp, int irq)
0053 {
0054     notifier_del_irq(hp, irq);
0055 }