[PATCH 3/8] hvc: Convert to using interrupts instead of opal events

Alistair Popple alistair at popple.id.au
Thu Apr 2 14:22:27 AEDT 2015


Convert the opal hvc driver to use the new irqchip to register for
opal events. As older firmware version may not have device tree
bindings for the interrupt parent we just use a hardcoded hwirq based
on the event number.

Signed-off-by: Alistair Popple <alistair at popple.id.au>
---
 drivers/tty/hvc/hvc_opal.c | 29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/drivers/tty/hvc/hvc_opal.c b/drivers/tty/hvc/hvc_opal.c
index 071551b..240283e 100644
--- a/drivers/tty/hvc/hvc_opal.c
+++ b/drivers/tty/hvc/hvc_opal.c
@@ -29,6 +29,7 @@
 #include <linux/of.h>
 #include <linux/of_platform.h>
 #include <linux/export.h>
+#include <linux/interrupt.h>
 
 #include <asm/hvconsole.h>
 #include <asm/prom.h>
@@ -162,27 +163,21 @@ static const struct hv_ops hvc_opal_hvsi_ops = {
 	.tiocmset = hvc_opal_hvsi_tiocmset,
 };
 
-static int hvc_opal_console_event(struct notifier_block *nb,
-				  unsigned long events, void *change)
+static irqreturn_t hvc_opal_console_event(int irq, void *data)
 {
-	if (events & OPAL_EVENT_CONSOLE_INPUT)
-		hvc_kick();
+	hvc_kick();
 	return 0;
 }
 
-static struct notifier_block hvc_opal_console_nb = {
-	.notifier_call	= hvc_opal_console_event,
-};
-
 static int hvc_opal_probe(struct platform_device *dev)
 {
 	const struct hv_ops *ops;
 	struct hvc_struct *hp;
 	struct hvc_opal_priv *pv;
 	hv_protocol_t proto;
-	unsigned int termno, boot = 0;
+	unsigned int termno, irq, boot = 0;
 	const __be32 *reg;
-
+	int rc;
 
 	if (of_device_is_compatible(dev->dev.of_node, "ibm,opal-console-raw")) {
 		proto = HV_PROTOCOL_RAW;
@@ -235,7 +230,19 @@ static int hvc_opal_probe(struct platform_device *dev)
 
 	/* ...  but we use OPAL event to kick the console */
 	if (!hvc_opal_event_registered) {
-		opal_notifier_register(&hvc_opal_console_nb);
+		irq = opal_event_request(ilog2(OPAL_EVENT_CONSOLE_INPUT));
+		if (!irq) {
+			pr_err("hvc_opal: Unable to map interrupt for device %s\n",
+				dev->dev.of_node->full_name);
+			return irq;
+		}
+		rc = request_irq(irq, hvc_opal_console_event,
+				IRQ_TYPE_LEVEL_HIGH, "opal-hvc", NULL);
+		if (rc) {
+			pr_err("hvc_opal: Unable to request interrput for device %s\n",
+				dev->dev.of_node->full_name);
+			return rc;
+		}
 		hvc_opal_event_registered = true;
 	}
 
-- 
1.8.3.2



More information about the Linuxppc-dev mailing list