]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/scsi/mesh.c
[PATCH] Necessary evil to get sata_vsc to initialize with Intel iq3124h hba
[linux-2.6-omap-h63xx.git] / drivers / scsi / mesh.c
index a4857db4f9b8033f2ff16785dc94244e997489a6..d6d2125f9044452d6f55a0721bf628cc16130dc9 100644 (file)
@@ -730,7 +730,7 @@ static void start_phase(struct mesh_state *ms)
                 * issue a SEQ_MSGOUT to get the mesh to drop ACK.
                 */
                if ((in_8(&mr->bus_status0) & BS0_ATN) == 0) {
-                       dlog(ms, "bus0 was %.2x explictly asserting ATN", mr->bus_status0);
+                       dlog(ms, "bus0 was %.2x explicitly asserting ATN", mr->bus_status0);
                        out_8(&mr->bus_status0, BS0_ATN); /* explicit ATN */
                        mesh_flush_io(mr);
                        udelay(1);
@@ -1869,7 +1869,8 @@ static int mesh_probe(struct macio_dev *mdev, const struct of_device_id *match)
 
        if (macio_resource_count(mdev) != 2 || macio_irq_count(mdev) != 2) {
                        printk(KERN_ERR "mesh: expected 2 addrs and 2 intrs"
-                      " (got %d,%d)\n", mesh->n_addrs, mesh->n_intrs);
+                      " (got %d,%d)\n", macio_resource_count(mdev),
+                      macio_irq_count(mdev));
                return -ENODEV;
        }
 
@@ -1959,22 +1960,35 @@ static int mesh_probe(struct macio_dev *mdev, const struct of_device_id *match)
        /* Set it up */
                mesh_init(ms);
 
-       /* XXX FIXME: error should be fatal */
-               if (request_irq(ms->meshintr, do_mesh_interrupt, 0, "MESH", ms))
+       /* Request interrupt */
+               if (request_irq(ms->meshintr, do_mesh_interrupt, 0, "MESH", ms)) {
                printk(KERN_ERR "MESH: can't get irq %d\n", ms->meshintr);
+               goto out_shutdown;
+       }
 
-       /* XXX FIXME: handle failure */
-       scsi_add_host(mesh_host, &mdev->ofdev.dev);
+       /* Add scsi host & scan */
+       if (scsi_add_host(mesh_host, &mdev->ofdev.dev))
+               goto out_release_irq;
        scsi_scan_host(mesh_host);
 
        return 0;
 
-out_unmap:
+ out_release_irq:
+       free_irq(ms->meshintr, ms);
+ out_shutdown:
+       /* shutdown & reset bus in case of error or macos can be confused
+        * at reboot if the bus was set to synchronous mode already
+        */
+       mesh_shutdown(mdev);
+       set_mesh_power(ms, 0);
+       pci_free_consistent(macio_get_pci_dev(mdev), ms->dma_cmd_size,
+                           ms->dma_cmd_space, ms->dma_cmd_bus);
+ out_unmap:
        iounmap(ms->dma);
        iounmap(ms->mesh);
-out_free:
+ out_free:
        scsi_host_put(mesh_host);
-out_release:
+ out_release:
        macio_release_resources(mdev);
 
        return -ENODEV;
@@ -2001,7 +2015,7 @@ static int mesh_remove(struct macio_dev *mdev)
 
        /* Free DMA commands memory */
        pci_free_consistent(macio_get_pci_dev(mdev), ms->dma_cmd_size,
-                         ms->dma_cmd_space, ms->dma_cmd_bus);
+                           ms->dma_cmd_space, ms->dma_cmd_bus);
 
        /* Release memory resources */
        macio_release_resources(mdev);