patch-1.3.76 linux/arch/i386/kernel/irq.c

Next file: linux/arch/i386/kernel/setup.c
Previous file: linux/arch/i386/kernel/head.S
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.75/linux/arch/i386/kernel/irq.c linux/arch/i386/kernel/irq.c
@@ -212,16 +212,15 @@
 #endif
 
 /*
- * IRQ0 is timer, IRQ2 is cascade interrupt to second interrupt controller
+ * IRQ2 is cascade interrupt to second interrupt controller
  */
-extern struct irqaction irq0;
 static struct irqaction irq2  = { no_action, 0, 0, "cascade", NULL, NULL};
 
 static struct irqaction *irq_action[16] = {
-	&irq0, NULL, &irq2, NULL,
 	NULL, NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL,
-	NULL, &irq13 , NULL, NULL
+	NULL, NULL, NULL, NULL,
+	NULL, NULL, NULL, NULL
 };
 
 int get_irq_list(char *buf)
@@ -385,59 +384,39 @@
 	}
 }
 
-int request_irq(unsigned int irq, 
-		void (*handler)(int, void *, struct pt_regs *),
-		unsigned long irqflags, 
-		const char * devname,
-		void *dev_id)
+int setup_x86_irq(int irq, struct irqaction * new)
 {
 	int shared = 0;
-	struct irqaction * action, **p;
+	struct irqaction *old, **p;
 	unsigned long flags;
 
-	if (irq > 15)
-		return -EINVAL;
-	if (!handler)
-		return -EINVAL;
 	p = irq_action + irq;
-	action = *p;
-	if (action) {
+	if ((old = *p) != NULL) {
 		/* Can't share interrupts unless both agree to */
-		if (!(action->flags & irqflags & SA_SHIRQ))
+		if (!(old->flags & new->flags & SA_SHIRQ))
 			return -EBUSY;
 
 		/* Can't share interrupts unless both are same type */
-		if ((action->flags ^ irqflags) & SA_INTERRUPT)
+		if ((old->flags ^ new->flags) & SA_INTERRUPT)
 			return -EBUSY;
 
 		/* add new interrupt at end of irq queue */
 		do {
-			p = &action->next;
-			action = *p;
-		} while (action);
+			p = &old->next;
+			old = *p;
+		} while (old);
 		shared = 1;
 	}
 
-	action = (struct irqaction *)kmalloc(sizeof(struct irqaction), GFP_KERNEL);
-	if (!action)
-		return -ENOMEM;
-
-	if (irqflags & SA_SAMPLE_RANDOM)
+	if (new->flags & SA_SAMPLE_RANDOM)
 		rand_initialize_irq(irq);
 
-	action->handler = handler;
-	action->flags = irqflags;
-	action->mask = 0;
-	action->name = devname;
-	action->next = NULL;
-	action->dev_id = dev_id;
-
 	save_flags(flags);
 	cli();
-	*p = action;
+	*p = new;
 
 	if (!shared) {
-		if (action->flags & SA_INTERRUPT)
+		if (new->flags & SA_INTERRUPT)
 			set_intr_gate(0x20+irq,fast_interrupt[irq]);
 		else
 			set_intr_gate(0x20+irq,interrupt[irq]);
@@ -446,6 +425,38 @@
 	restore_flags(flags);
 	return 0;
 }
+
+int request_irq(unsigned int irq, 
+		void (*handler)(int, void *, struct pt_regs *),
+		unsigned long irqflags, 
+		const char * devname,
+		void *dev_id)
+{
+	int retval;
+	struct irqaction * action;
+
+	if (irq > 15)
+		return -EINVAL;
+	if (!handler)
+		return -EINVAL;
+
+	action = (struct irqaction *)kmalloc(sizeof(struct irqaction), GFP_KERNEL);
+	if (!action)
+		return -ENOMEM;
+
+	action->handler = handler;
+	action->flags = irqflags;
+	action->mask = 0;
+	action->name = devname;
+	action->next = NULL;
+	action->dev_id = dev_id;
+
+	retval = setup_x86_irq(irq, action);
+
+	if (retval)
+		kfree(action);
+	return retval;
+}
 		
 void free_irq(unsigned int irq, void *dev_id)
 {
@@ -535,6 +546,6 @@
 #endif	
 	request_region(0x20,0x20,"pic1");
 	request_region(0xa0,0x20,"pic2");
-	enable_irq(2);
-	enable_irq(13);
+	setup_x86_irq(2, &irq2);
+	setup_x86_irq(13, &irq13);
 } 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this