[SPARC64]: Fix several bugs in MSI handling.

1) sun4{u,v}_build_msi() have improper return value handling.

   We should always return negative error codes, instead of
   using the magic value "0" which could in fact be a valid
   MSI number.

2) sun4{u,v}_build_msi() should return -ENOMEM instead of
   calling prom_prom() halt with kzalloc() of the interrupt
   data fails.

3) We 'remembered' the MSI number using a singleton in the
   struct device archdata area, this doesn't work for MSI-X
   which can cause multiple MSIs assosciated with one device.

   Delete that archdata member, and instead store the MSI
   number in the IRQ chip data area.

Signed-off-by: David S. Miller <davem@davemloft.net>
diff --git a/arch/sparc64/kernel/pci_sun4v.c b/arch/sparc64/kernel/pci_sun4v.c
index 466f4aa..da724b1 100644
--- a/arch/sparc64/kernel/pci_sun4v.c
+++ b/arch/sparc64/kernel/pci_sun4v.c
@@ -940,13 +940,13 @@
 	if (msi_num < 0)
 		return msi_num;
 
-	devino = sun4v_build_msi(pbm->devhandle, virt_irq_p,
-				 pbm->msiq_first_devino,
-				 (pbm->msiq_first_devino +
-				  pbm->msiq_num));
-	err = -ENOMEM;
-	if (!devino)
+	err = sun4v_build_msi(pbm->devhandle, virt_irq_p,
+			      pbm->msiq_first_devino,
+			      (pbm->msiq_first_devino +
+			       pbm->msiq_num));
+	if (err < 0)
 		goto out_err;
+	devino = err;
 
 	msiqid = ((devino - pbm->msiq_first_devino) +
 		  pbm->msiq_first);
@@ -971,7 +971,7 @@
 	if (pci_sun4v_msi_setvalid(pbm->devhandle, msi_num, HV_MSIVALID_VALID))
 		goto out_err;
 
-	pdev->dev.archdata.msi_num = msi_num;
+	sparc64_set_msi(*virt_irq_p, msi_num);
 
 	if (entry->msi_attrib.is_64) {
 		msg.address_hi = pbm->msi64_start >> 32;
@@ -993,8 +993,6 @@
 
 out_err:
 	free_msi(pbm, msi_num);
-	sun4v_destroy_msi(*virt_irq_p);
-	*virt_irq_p = 0;
 	return err;
 
 }
@@ -1006,7 +1004,7 @@
 	unsigned long msiqid, err;
 	unsigned int msi_num;
 
-	msi_num = pdev->dev.archdata.msi_num;
+	msi_num = sparc64_get_msi(virt_irq);
 	err = pci_sun4v_msi_getmsiq(pbm->devhandle, msi_num, &msiqid);
 	if (err) {
 		printk(KERN_ERR "%s: getmsiq gives error %lu\n",