From: [email-masked] on behalf of [email-masked]
To: [email-masked]; [email-masked];

[email-masked]
Subject: [ACPI] acpi_register_gsi-change-ia64-iosapic-code.patch added
to -mm tree

The patch titled

     acpi_register_gsi(): change ia64 iosapic code

has been added to the -mm tree.  Its filename is

     acpi_register_gsi-change-ia64-iosapic-code.patch

Patches currently in -mm which might be from [email-masked] are

acpi_register_gsi-change-acpi_register_gsi-interface.patch
acpi_register_gsi-change-acpi-pci-code.patch
acpi_register_gsi-change-hpet-driver.patch
acpi_register_gsi-change-phpacpi-driver.patch
acpi_register_gsi-change-acpi-based-8250-driver.patch
acpi_register_gsi-change-ia64-iosapic-code.patch

From: Kenji Kaneshige <[email-masked]>

Change iosapic_register_intr(), which called by acpi_register_gsi(), to return
negative value on error instead of panic.

Signed-off-by: Kenji Kaneshige <[email-masked]>
Cc: <[email-masked]>
Signed-off-by: Andrew Morton <[email-masked]>
Index: to-akpm/arch/ia64/kernel/iosapic.c
===================================================================
--- to-akpm.orig/arch/ia64/kernel/iosapic.c
+++ to-akpm/arch/ia64/kernel/iosapic.c
@@ -562,7 +562,7 @@ static inline int vector_is_shared (int 
 	return (iosapic_intr_info[vector].count > 1);
 }
 
-static void
+static int
 register_intr (unsigned int gsi, int vector, unsigned char delivery,
 	       unsigned long polarity, unsigned long trigger)
 {
@@ -577,7 +577,7 @@ register_intr (unsigned int gsi, int vec
 	index = find_iosapic(gsi);
 	if (index < 0) {
 		printk(KERN_WARNING "%s: No IOSAPIC for GSI %u\n", __FUNCTION__, gsi);
-		return;
+		return -ENODEV;
 	}
 
 	iosapic_address = iosapic_lists[index].addr;
@@ -588,7 +588,7 @@ register_intr (unsigned int gsi, int vec
 		rte = iosapic_alloc_rte();
 		if (!rte) {
 			printk(KERN_WARNING "%s: cannot allocate memory\n", __FUNCTION__);
-			return;
+			return -ENOMEM;
 		}
 
 		rte_index = gsi - gsi_base;
@@ -603,7 +603,7 @@ register_intr (unsigned int gsi, int vec
 		struct iosapic_intr_info *info = &iosapic_intr_info[vector];
 		if (info->trigger != trigger || info->polarity != polarity) {
 			printk (KERN_WARNING "%s: cannot override the interrupt\n", __FUNCTION__);
-			return;
+			return -EINVAL;
 		}
 	}
 
@@ -623,6 +623,7 @@ register_intr (unsigned int gsi, int vec
 			       __FUNCTION__, vector, idesc->handler->typename, irq_type->typename);
 		idesc->handler = irq_type;
 	}
+	return 0;
 }
 
 static unsigned int
@@ -710,7 +711,7 @@ int
 iosapic_register_intr (unsigned int gsi,
 		       unsigned long polarity, unsigned long trigger)
 {
-	int vector, mask = 1;
+	int vector, mask = 1, err;
 	unsigned int dest;
 	unsigned long flags;
 	struct iosapic_rte_info *rte;
@@ -735,8 +736,11 @@ again:
 
 	/* If vector is running out, we try to find a sharable vector */
 	vector = assign_irq_vector_nopanic(AUTO_ASSIGN);
-	if (vector < 0)
+	if (vector < 0) {
 		vector = iosapic_find_sharable_vector(trigger, polarity);
+  		if (vector < 0)
+			Return -ENOSPC;
+	}
 
 	spin_lock_irqsave(&irq_descp(vector)->lock, flags);
 	spin_lock(&iosapic_lock);
@@ -750,8 +754,13 @@ again:
 		}
 
 		dest = get_target_cpu(gsi, vector);
-		register_intr(gsi, vector, IOSAPIC_LOWEST_PRIORITY,
+		err = register_intr(gsi, vector, IOSAPIC_LOWEST_PRIORITY,
 			      polarity, trigger);
+		if (err < 0) {
+			spin_unlock(&iosapic_lock);
+			spin_unlock_irqrestore(&irq_descp(vector)->lock, flags);
+			return err;
+		}
 
 		/*
 		 * If the vector is shared and already unmasked for