Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / drivers / scsi / jazz_esp.c
index f158ec0..fc031c7 100644 (file)
@@ -6,6 +6,7 @@
  * jazz_esp is based on David S. Miller's ESP driver and cyber_esp
  */
 
+#include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/delay.h>
 #include <linux/types.h>
@@ -16,7 +17,7 @@
 #include <linux/stat.h>
 
 #include "scsi.h"
-#include "hosts.h"
+#include <scsi/scsi_host.h>
 #include "NCR53C9x.h"
 
 #include <asm/irq.h>
@@ -27,7 +28,7 @@
 #include <asm/pgtable.h>
 
 static int  dma_bytes_sent(struct NCR_ESP *esp, int fifo_count);
-static int  dma_can_transfer(struct NCR_ESP *esp, Scsi_Cmnd *sp);
+static int  dma_can_transfer(struct NCR_ESP *esp, struct scsi_cmnd *sp);
 static void dma_dump_state(struct NCR_ESP *esp);
 static void dma_init_read(struct NCR_ESP *esp, __u32 vaddress, int length);
 static void dma_init_write(struct NCR_ESP *esp, __u32 vaddress, int length);
@@ -36,11 +37,11 @@ static void dma_ints_on(struct NCR_ESP *esp);
 static int  dma_irq_p(struct NCR_ESP *esp);
 static int  dma_ports_p(struct NCR_ESP *esp);
 static void dma_setup(struct NCR_ESP *esp, __u32 addr, int count, int write);
-static void dma_mmu_get_scsi_one (struct NCR_ESP *esp, Scsi_Cmnd *sp);
-static void dma_mmu_get_scsi_sgl (struct NCR_ESP *esp, Scsi_Cmnd *sp);
-static void dma_mmu_release_scsi_one (struct NCR_ESP *esp, Scsi_Cmnd *sp);
-static void dma_mmu_release_scsi_sgl (struct NCR_ESP *esp, Scsi_Cmnd *sp);
-static void dma_advance_sg (Scsi_Cmnd *sp);
+static void dma_mmu_get_scsi_one (struct NCR_ESP *esp, struct scsi_cmnd *sp);
+static void dma_mmu_get_scsi_sgl (struct NCR_ESP *esp, struct scsi_cmnd *sp);
+static void dma_mmu_release_scsi_one (struct NCR_ESP *esp, struct scsi_cmnd *sp);
+static void dma_mmu_release_scsi_sgl (struct NCR_ESP *esp, struct scsi_cmnd *sp);
+static void dma_advance_sg (struct scsi_cmnd *sp);
 static void dma_led_off(struct NCR_ESP *);
 static void dma_led_on(struct NCR_ESP *);
 
@@ -51,8 +52,20 @@ static volatile unsigned char cmd_buffer[16];
                                 * via PIO.
                                 */
 
+static int jazz_esp_release(struct Scsi_Host *shost)
+{
+       if (shost->irq)
+               free_irq(shost->irq, NULL);
+       if (shost->dma_channel != 0xff)
+               free_dma(shost->dma_channel);
+       if (shost->io_port && shost->n_io_port)
+               release_region(shost->io_port, shost->n_io_port);
+       scsi_unregister(shost);
+       return 0;
+}
+
 /***************************************************************** Detection */
-int jazz_esp_detect(Scsi_Host_Template *tpnt)
+static int jazz_esp_detect(struct scsi_host_template *tpnt)
 {
     struct NCR_ESP *esp;
     struct ConfigDev *esp_dev;
@@ -61,7 +74,7 @@ int jazz_esp_detect(Scsi_Host_Template *tpnt)
      * first assumption it is there:-)
      */
     if (1) {
-       esp_dev = 0;
+       esp_dev = NULL;
        esp = esp_allocate(tpnt, (void *) esp_dev);
        
        /* Do command transfer with programmed I/O */
@@ -80,13 +93,13 @@ int jazz_esp_detect(Scsi_Host_Template *tpnt)
        esp->dma_setup = &dma_setup;
 
        /* Optional functions */
-       esp->dma_barrier = 0;
-       esp->dma_drain = 0;
-       esp->dma_invalidate = 0;
-       esp->dma_irq_entry = 0;
-       esp->dma_irq_exit = 0;
-       esp->dma_poll = 0;
-       esp->dma_reset = 0;
+       esp->dma_barrier = NULL;
+       esp->dma_drain = NULL;
+       esp->dma_invalidate = NULL;
+       esp->dma_irq_entry = NULL;
+       esp->dma_irq_exit = NULL;
+       esp->dma_poll = NULL;
+       esp->dma_reset = NULL;
        esp->dma_led_off = &dma_led_off;
        esp->dma_led_on = &dma_led_on;
        
@@ -106,7 +119,7 @@ int jazz_esp_detect(Scsi_Host_Template *tpnt)
         * of DMA channel, so we can use the jazz DMA functions
         * 
         */
-       esp->dregs = JAZZ_SCSI_DMA;
+       esp->dregs = (void *) JAZZ_SCSI_DMA;
        
        /* ESP register base */
        esp->eregs = (struct ESP_regs *)(JAZZ_SCSI_BASE);
@@ -115,7 +128,7 @@ int jazz_esp_detect(Scsi_Host_Template *tpnt)
        esp->esp_command = (volatile unsigned char *)cmd_buffer;
        
        /* get virtual dma address for command buffer */
-       esp->esp_command_dvma = vdma_alloc(PHYSADDR(cmd_buffer), sizeof (cmd_buffer));
+       esp->esp_command_dvma = vdma_alloc(CPHYSADDR(cmd_buffer), sizeof (cmd_buffer));
        
        esp->irq = JAZZ_SCSI_IRQ;
        request_irq(JAZZ_SCSI_IRQ, esp_intr, SA_INTERRUPT, "JAZZ SCSI",
@@ -139,25 +152,13 @@ int jazz_esp_detect(Scsi_Host_Template *tpnt)
     return 0;
 }
 
-static int jazz_esp_release(struct Scsi_Host *shost)
-{
-       if (shost->irq)
-               free_irq(shost->irq, NULL);
-       if (shost->dma_channel != 0xff)
-               free_dma(shost->dma_channel);
-       if (shost->io_port && shost->n_io_port)
-               release_region(shost->io_port, shost->n_io_port);
-       scsi_unregister(shost);
-       return 0;
-}
-
 /************************************************************* DMA Functions */
 static int dma_bytes_sent(struct NCR_ESP *esp, int fifo_count)
 {
     return fifo_count;
 }
 
-static int dma_can_transfer(struct NCR_ESP *esp, Scsi_Cmnd *sp)
+static int dma_can_transfer(struct NCR_ESP *esp, struct scsi_cmnd *sp)
 {
     /*
      * maximum DMA size is 1MB
@@ -230,43 +231,43 @@ static void dma_setup(struct NCR_ESP *esp, __u32 addr, int count, int write)
     }
 }
 
-static void dma_mmu_get_scsi_one (struct NCR_ESP *esp, Scsi_Cmnd *sp)
+static void dma_mmu_get_scsi_one (struct NCR_ESP *esp, struct scsi_cmnd *sp)
 {
-    sp->SCp.have_data_in = vdma_alloc(PHYSADDR(sp->SCp.buffer), sp->SCp.this_residual);
+    sp->SCp.have_data_in = vdma_alloc(CPHYSADDR(sp->SCp.buffer), sp->SCp.this_residual);
     sp->SCp.ptr = (char *)((unsigned long)sp->SCp.have_data_in);
 }
 
-static void dma_mmu_get_scsi_sgl (struct NCR_ESP *esp, Scsi_Cmnd *sp)
+static void dma_mmu_get_scsi_sgl (struct NCR_ESP *esp, struct scsi_cmnd *sp)
 {
     int sz = sp->SCp.buffers_residual;
-    struct mmu_sglist *sg = (struct mmu_sglist *) sp->SCp.buffer;
+    struct scatterlist *sg = (struct scatterlist *) sp->SCp.buffer;
     
     while (sz >= 0) {
-       sg[sz].dvma_addr = vdma_alloc(PHYSADDR(sg[sz].addr), sg[sz].len);
+       sg[sz].dma_address = vdma_alloc(CPHYSADDR(page_address(sg[sz].page) + sg[sz].offset), sg[sz].length);
        sz--;
     }
-    sp->SCp.ptr=(char *)((unsigned long)sp->SCp.buffer->dvma_address);
+    sp->SCp.ptr=(char *)(sp->SCp.buffer->dma_address);
 }    
 
-static void dma_mmu_release_scsi_one (struct NCR_ESP *esp, Scsi_Cmnd *sp)
+static void dma_mmu_release_scsi_one (struct NCR_ESP *esp, struct scsi_cmnd *sp)
 {
     vdma_free(sp->SCp.have_data_in);
 }
 
-static void dma_mmu_release_scsi_sgl (struct NCR_ESP *esp, Scsi_Cmnd *sp)
+static void dma_mmu_release_scsi_sgl (struct NCR_ESP *esp, struct scsi_cmnd *sp)
 {
     int sz = sp->use_sg - 1;
-    struct mmu_sglist *sg = (struct mmu_sglist *)sp->buffer;
+    struct scatterlist *sg = (struct scatterlist *)sp->buffer;
                        
     while(sz >= 0) {
-       vdma_free(sg[sz].dvma_addr);
+       vdma_free(sg[sz].dma_address);
        sz--;
     }
 }
 
-static void dma_advance_sg (Scsi_Cmnd *sp)
+static void dma_advance_sg (struct scsi_cmnd *sp)
 {
-    sp->SCp.ptr = (char *)((unsigned long)sp->SCp.buffer->dvma_address);
+    sp->SCp.ptr = (char *)(sp->SCp.buffer->dma_address);
 }
 
 #define JAZZ_HDC_LED   0xe000d100 /* FIXME, find correct address */
@@ -285,9 +286,9 @@ static void dma_led_on(struct NCR_ESP *esp)
 #endif    
 }
 
-static Scsi_Host_Template driver_template = {
-       .proc_name              = "esp",
-       .proc_info              = &esp_proc_info,
+static struct scsi_host_template driver_template = {
+       .proc_name              = "jazz_esp",
+       .proc_info              = esp_proc_info,
        .name                   = "ESP 100/100a/200",
        .detect                 = jazz_esp_detect,
        .slave_alloc            = esp_slave_alloc,
@@ -303,4 +304,4 @@ static Scsi_Host_Template driver_template = {
        .cmd_per_lun            = 1,
        .use_clustering         = DISABLE_CLUSTERING,
 };
-
+#include "scsi_module.c"