patch-2.4.0-test9 linux/drivers/acorn/scsi/eesox.c

Next file: linux/drivers/acorn/scsi/eesox.h
Previous file: linux/drivers/acorn/scsi/cumana_2.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acorn/scsi/eesox.c linux/drivers/acorn/scsi/eesox.c
@@ -1,24 +1,27 @@
 /*
- * linux/arch/arm/drivers/scsi/eesox.c
+ *  linux/drivers/acorn/scsi/eesox.c
  *
- * Copyright (C) 1997-2000 Russell King
+ *  Copyright (C) 1997-2000 Russell King
  *
- * This driver is based on experimentation.  Hence, it may have made
- * assumptions about the particular card that I have available, and
- * may not be reliable!
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
  *
- * Changelog:
- *  01-10-1997	RMK		Created, READONLY version
- *  15-02-1998	RMK		READ/WRITE version
+ *  This driver is based on experimentation.  Hence, it may have made
+ *  assumptions about the particular card that I have available, and
+ *  may not be reliable!
+ *
+ *  Changelog:
+ *   01-10-1997	RMK		Created, READONLY version
+ *   15-02-1998	RMK		READ/WRITE version
  *				added DMA support and hardware definitions
- *  14-03-1998	RMK		Updated DMA support
+ *   14-03-1998	RMK		Updated DMA support
  *				Added terminator control
- *  15-04-1998	RMK		Only do PIO if FAS216 will allow it.
- *  27-06-1998	RMK		Changed asm/delay.h to linux/delay.h
- *  02-04-2000	RMK	0.0.3	Fixed NO_IRQ/NO_DMA problem, updated for new
+ *   15-04-1998	RMK		Only do PIO if FAS216 will allow it.
+ *   27-06-1998	RMK		Changed asm/delay.h to linux/delay.h
+ *   02-04-2000	RMK	0.0.3	Fixed NO_IRQ/NO_DMA problem, updated for new
  *				error handling code.
  */
-
 #include <linux/module.h>
 #include <linux/blk.h>
 #include <linux/kernel.h>
@@ -29,6 +32,7 @@
 #include <linux/unistd.h>
 #include <linux/stat.h>
 #include <linux/delay.h>
+#include <linux/pci.h>
 
 #include <asm/io.h>
 #include <asm/irq.h>
@@ -157,15 +161,6 @@
 	fas216_intr(host);
 }
 
-static void
-eesoxscsi_invalidate(char *addr, long len, fasdmadir_t direction)
-{
-	if (direction == DMA_OUT)
-		dma_cache_wback((unsigned long)addr, (unsigned long)len);
-	else
-		dma_cache_inv((unsigned long)addr, (unsigned long)len);
-}
-
 /* Prototype: fasdmatype_t eesoxscsi_dma_setup(host, SCpnt, direction, min_type)
  * Purpose  : initialises DMA/PIO
  * Params   : host      - host
@@ -183,29 +178,27 @@
 
 	if (dmach != NO_DMA &&
 	    (min_type == fasdma_real_all || SCp->this_residual >= 512)) {
-		int buf;
+		int bufs = SCp->buffers_residual;
+		int pci_dir, dma_dir;
+
+		if (bufs)
+			memcpy(info->sg + 1, SCp->buffer + 1,
+				sizeof(struct scatterlist) * bufs);
+		info->sg[0].address = SCp->ptr;
+		info->sg[0].length = SCp->this_residual;
+
+		if (direction == DMA_OUT)
+			pci_dir = PCI_DMA_TODEVICE,
+			dma_dir = DMA_MODE_WRITE;
+		else
+			pci_dir = PCI_DMA_FROMDEVICE,
+			dma_dir = DMA_MODE_READ;
 
-		for(buf = 1; buf <= SCp->buffers_residual &&
-			     buf < NR_SG; buf++) {
-			info->dmasg[buf].address = __virt_to_bus(
-				(unsigned long)SCp->buffer[buf].address);
-			info->dmasg[buf].length = SCp->buffer[buf].length;
-
-			eesoxscsi_invalidate(SCp->buffer[buf].address,
-						SCp->buffer[buf].length,
-						direction);
-		}
-
-		info->dmasg[0].address = __virt_to_phys((unsigned long)SCp->ptr);
-		info->dmasg[0].length = SCp->this_residual;
-		eesoxscsi_invalidate(SCp->ptr,
-					SCp->this_residual, direction);
+		pci_map_sg(NULL, info->sg, bufs + 1, pci_dir);
 
 		disable_dma(dmach);
-		set_dma_sg(dmach, info->dmasg, buf);
-		set_dma_mode(dmach,
-			     direction == DMA_OUT ? DMA_MODE_WRITE :
-						    DMA_MODE_READ);
+		set_dma_sg(dmach, info->sg, bufs + 1);
+		set_dma_mode(dmach, dma_dir);
 		enable_dma(dmach);
 		return fasdma_real_all;
 	}

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)