regulator: Fix check of unsigned return value and transmit errors in wm831x_gp_ldo_ge...
[safe/jmp/linux-2.6] / drivers / scsi / a2091.c
index fddfa2e..4b38c47 100644 (file)
@@ -1,7 +1,6 @@
 #include <linux/types.h>
 #include <linux/mm.h>
 #include <linux/blkdev.h>
-#include <linux/sched.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
 
@@ -24,7 +23,9 @@
 #define DMA(ptr) ((a2091_scsiregs *)((ptr)->base))
 #define HDATA(ptr) ((struct WD33C93_hostdata *)((ptr)->hostdata))
 
-static irqreturn_t a2091_intr (int irq, void *_instance, struct pt_regs *fp)
+static int a2091_release(struct Scsi_Host *instance);
+
+static irqreturn_t a2091_intr (int irq, void *_instance)
 {
     unsigned long flags;
     unsigned int status;
@@ -40,15 +41,14 @@ static irqreturn_t a2091_intr (int irq, void *_instance, struct pt_regs *fp)
     return IRQ_HANDLED;
 }
 
-static int dma_setup (Scsi_Cmnd *cmd, int dir_in)
+static int dma_setup(struct scsi_cmnd *cmd, int dir_in)
 {
     unsigned short cntr = CNTR_PDMD | CNTR_INTEN;
     unsigned long addr = virt_to_bus(cmd->SCp.ptr);
     struct Scsi_Host *instance = cmd->device->host;
 
     /* don't allow DMA if the physical address is bad */
-    if (addr & A2091_XFER_MASK ||
-       (!dir_in && mm_end_of_chunk (addr, cmd->SCp.this_residual)))
+    if (addr & A2091_XFER_MASK)
     {
        HDATA(instance)->dma_bounce_len = (cmd->SCp.this_residual + 511)
            & ~0x1ff;
@@ -74,18 +74,9 @@ static int dma_setup (Scsi_Cmnd *cmd, int dir_in)
        }
 
        if (!dir_in) {
-           /* copy to bounce buffer for a write */
-           if (cmd->use_sg)
-#if 0
-               panic ("scsi%ddma: incomplete s/g support",
-                      instance->host_no);
-#else
+               /* copy to bounce buffer for a write */
                memcpy (HDATA(instance)->dma_bounce_buffer,
                        cmd->SCp.ptr, cmd->SCp.this_residual);
-#endif
-           else
-               memcpy (HDATA(instance)->dma_bounce_buffer,
-                       cmd->request_buffer, cmd->request_bufflen);
        }
     }
 
@@ -115,7 +106,7 @@ static int dma_setup (Scsi_Cmnd *cmd, int dir_in)
     return 0;
 }
 
-static void dma_stop (struct Scsi_Host *instance, Scsi_Cmnd *SCpnt, 
+static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt,
                      int status)
 {
     /* disable SCSI interrupts */
@@ -145,34 +136,17 @@ static void dma_stop (struct Scsi_Host *instance, Scsi_Cmnd *SCpnt,
 
     /* copy from a bounce buffer, if necessary */
     if (status && HDATA(instance)->dma_bounce_buffer) {
-       if (SCpnt && SCpnt->use_sg) {
-#if 0
-           panic ("scsi%d: incomplete s/g support",
-                  instance->host_no);
-#else
-           if( HDATA(instance)->dma_dir )
+       if( HDATA(instance)->dma_dir )
                memcpy (SCpnt->SCp.ptr, 
                        HDATA(instance)->dma_bounce_buffer,
                        SCpnt->SCp.this_residual);
-           kfree (HDATA(instance)->dma_bounce_buffer);
-           HDATA(instance)->dma_bounce_buffer = NULL;
-           HDATA(instance)->dma_bounce_len = 0;
-           
-#endif
-       } else {
-           if (HDATA(instance)->dma_dir && SCpnt)
-               memcpy (SCpnt->request_buffer,
-                       HDATA(instance)->dma_bounce_buffer,
-                       SCpnt->request_bufflen);
-
-           kfree (HDATA(instance)->dma_bounce_buffer);
-           HDATA(instance)->dma_bounce_buffer = NULL;
-           HDATA(instance)->dma_bounce_len = 0;
-       }
+       kfree (HDATA(instance)->dma_bounce_buffer);
+       HDATA(instance)->dma_bounce_buffer = NULL;
+       HDATA(instance)->dma_bounce_len = 0;
     }
 }
 
-int __init a2091_detect(struct scsi_host_template *tpnt)
+static int __init a2091_detect(struct scsi_host_template *tpnt)
 {
     static unsigned char called = 0;
     struct Scsi_Host *instance;
@@ -197,27 +171,36 @@ int __init a2091_detect(struct scsi_host_template *tpnt)
            continue;
 
        instance = scsi_register (tpnt, sizeof (struct WD33C93_hostdata));
-       if (instance == NULL) {
-           release_mem_region(address, 256);
-           continue;
-       }
+       if (instance == NULL)
+           goto release;
        instance->base = ZTWO_VADDR(address);
        instance->irq = IRQ_AMIGA_PORTS;
        instance->unique_id = z->slotaddr;
        DMA(instance)->DAWR = DAWR_A2091;
        regs.SASR = &(DMA(instance)->SASR);
        regs.SCMD = &(DMA(instance)->SCMD);
+       HDATA(instance)->no_sync = 0xff;
+       HDATA(instance)->fast = 0;
+       HDATA(instance)->dma_mode = CTRL_DMA;
        wd33c93_init(instance, regs, dma_setup, dma_stop, WD33C93_FS_8_10);
-       request_irq(IRQ_AMIGA_PORTS, a2091_intr, IRQF_SHARED, "A2091 SCSI",
-                   instance);
+       if (request_irq(IRQ_AMIGA_PORTS, a2091_intr, IRQF_SHARED, "A2091 SCSI",
+                       instance))
+           goto unregister;
        DMA(instance)->CNTR = CNTR_PDMD | CNTR_INTEN;
        num_a2091++;
+       continue;
+
+unregister:
+       scsi_unregister(instance);
+       wd33c93_release();
+release:
+       release_mem_region(address, 256);
     }
 
     return num_a2091;
 }
 
-static int a2091_bus_reset(Scsi_Cmnd *cmd)
+static int a2091_bus_reset(struct scsi_cmnd *cmd)
 {
        /* FIXME perform bus-specific reset */
 
@@ -252,7 +235,7 @@ static struct scsi_host_template driver_template = {
 
 #include "scsi_module.c"
 
-int a2091_release(struct Scsi_Host *instance)
+static int a2091_release(struct Scsi_Host *instance)
 {
 #ifdef MODULE
        DMA(instance)->CNTR = 0;