[parisc-linux-cvs] irq tidyup

Matthew Wilcox willy@ldl.fc.hp.com
Fri, 13 Jul 2001 23:27:12 -0600


Index: arch/parisc/kernel/irq.c
===================================================================
RCS file: /home/cvs/parisc/linux/arch/parisc/kernel/irq.c,v
retrieving revision 1.41
diff -u -p -r1.41 irq.c
--- irq.c	2001/07/07 00:23:44	1.41
+++ irq.c	2001/07/14 05:21:45
@@ -516,6 +516,9 @@ int request_irq(unsigned int irq,
 	printk(KERN_INFO "request_irq(%d, %p, 0x%lx, %s, %p)\n",irq, handler, irqflags, devname, dev_id);
 #endif
 
+	/* request_irq()/free_irq() may not be called from interrupt context. */
+	if (in_interrupt()) BUG();
+
 	if(!handler) {
 		printk(KERN_ERR "request_irq(%d,...): Augh! No handler for irq!\n",
 			irq);
@@ -533,22 +536,13 @@ int request_irq(unsigned int irq,
 		return -EINVAL;
 	}
 
-	/*
-	** We don't allow request_irq()/free_irq() called from an
-	** interrupt context. We aren't aware of a need for it at
-	** the moment. If that changes, replace all usage of irq_lock
-	** with *irqsave locking variants.
-	** - ggg
-	*/
-	if (in_interrupt()) BUG();
-
 	spin_lock(&irq_lock);
 	action = &(irq_region[IRQ_REGION(irq)]->action[IRQ_OFFSET(irq)]);
 
 	/* First one is preallocated. */
-	if(action->handler) {
+	if (action->handler) {
 		/* But it's in use...find the tail and allocate a new one */
-		while(action->next)
+		while (action->next)
 			action = action->next;
 
 		action->next = kmalloc(sizeof(*action), GFP_ATOMIC);
@@ -556,7 +550,7 @@ int request_irq(unsigned int irq,
 		action = action->next;
 	}
 
-	if(!action) {
+	if (!action) {
 		printk(KERN_ERR "request_irq():Augh! No action!\n") ;
 		return -ENOMEM;
 	}
@@ -583,11 +577,12 @@ void free_irq(unsigned int irq, void *de
 	spin_lock(&irq_lock);
 	action = &irq_region[IRQ_REGION(irq)]->action[IRQ_OFFSET(irq)];
 
-	if(action->dev_id == dev_id) {
-		if(action->next == NULL)
+	if (action->dev_id == dev_id) {
+		if(action->next == NULL) {
 			action->handler = NULL;
-		else
+		} else {
 			memcpy(action, action->next, sizeof *action);
+		}
 
 		spin_unlock(&irq_lock);
 		return;