patch-2.4.10 linux/include/asm-sparc64/floppy.h

Next file: linux/include/asm-sparc64/keyboard.h
Previous file: linux/include/asm-sparc64/fcntl.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.9/linux/include/asm-sparc64/floppy.h linux/include/asm-sparc64/floppy.h
@@ -1,4 +1,4 @@
-/* $Id: floppy.h,v 1.30 2001/05/11 07:05:38 davem Exp $
+/* $Id: floppy.h,v 1.31 2001/08/22 17:46:31 davem Exp $
  * asm-sparc64/floppy.h: Sparc specific parts of the Floppy driver.
  *
  * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
@@ -268,8 +268,15 @@
 static struct linux_ebus_dma *sun_pci_fd_ebus_dma;
 static struct pci_dev *sun_pci_ebus_dev;
 static int sun_pci_broken_drive = -1;
-static unsigned int sun_pci_dma_addr = -1U;
-static int sun_pci_dma_len, sun_pci_dma_direction;
+
+struct sun_pci_dma_op {
+	unsigned int 	addr;
+	int		len;
+	int		direction;
+	char		*buf;
+};
+static struct sun_pci_dma_op sun_pci_dma_current = { -1U, 0, 0, NULL};
+static struct sun_pci_dma_op sun_pci_dma_pending = { -1U, 0, 0, NULL};
 
 extern void floppy_interrupt(int irq, void *dev_id, struct pt_regs *regs);
 
@@ -339,6 +346,29 @@
 {
 	unsigned int dcsr;
 
+	if((NULL == sun_pci_dma_pending.buf) 	||
+	   (0	== sun_pci_dma_pending.len) 	||
+	   (0	== sun_pci_dma_pending.direction)) {
+		goto enable; /* TODO: BUG() */
+	}
+
+	sun_pci_dma_current.buf = sun_pci_dma_pending.buf;
+	sun_pci_dma_current.len = sun_pci_dma_pending.len;
+	sun_pci_dma_current.direction = sun_pci_dma_pending.direction;
+
+	sun_pci_dma_pending.buf  = NULL;
+	sun_pci_dma_pending.len  = 0;
+	sun_pci_dma_pending.direction = 0;
+	sun_pci_dma_pending.addr = -1U;
+
+	sun_pci_dma_current.addr = 
+		pci_map_single(	sun_pci_ebus_dev,
+				sun_pci_dma_current.buf,
+				sun_pci_dma_current.len,
+				sun_pci_dma_current.direction);
+	writel(sun_pci_dma_current.addr, &sun_pci_fd_ebus_dma->dacr);
+
+enable:
 	dcsr = readl(&sun_pci_fd_ebus_dma->dcsr);
 	dcsr |= EBUS_DCSR_EN_DMA;
 	writel(dcsr, &sun_pci_fd_ebus_dma->dcsr);
@@ -362,12 +392,12 @@
 			writel(dcsr, &sun_pci_fd_ebus_dma->dcsr);
 		}
 	}
-	if (sun_pci_dma_addr != -1U)
+	if (sun_pci_dma_current.addr != -1U)
 		pci_unmap_single(sun_pci_ebus_dev,
-				 sun_pci_dma_addr,
-				 sun_pci_dma_len,
-				 sun_pci_dma_direction);
-	sun_pci_dma_addr = -1U;
+				 sun_pci_dma_current.addr,
+				 sun_pci_dma_current.len,
+				 sun_pci_dma_current.direction);
+	sun_pci_dma_current.addr = -1U;
 }
 
 static void sun_pci_fd_set_dma_mode(int mode)
@@ -387,29 +417,23 @@
 	 */
 	if (mode == DMA_MODE_WRITE) {
 		dcsr &= ~(EBUS_DCSR_WRITE);
-		sun_pci_dma_direction = PCI_DMA_TODEVICE;
+		sun_pci_dma_pending.direction = PCI_DMA_TODEVICE;
 	} else {
 		dcsr |= EBUS_DCSR_WRITE;
-		sun_pci_dma_direction = PCI_DMA_FROMDEVICE;
+		sun_pci_dma_pending.direction = PCI_DMA_FROMDEVICE;
 	}
 	writel(dcsr, &sun_pci_fd_ebus_dma->dcsr);
 }
 
 static void sun_pci_fd_set_dma_count(int length)
 {
-	sun_pci_dma_len = length;
+	sun_pci_dma_pending.len = length;
 	writel(length, &sun_pci_fd_ebus_dma->dbcr);
 }
 
 static void sun_pci_fd_set_dma_addr(char *buffer)
 {
-	unsigned int addr;
-
-	addr = sun_pci_dma_addr = pci_map_single(sun_pci_ebus_dev,
-						 buffer,
-						 sun_pci_dma_len,
-						 sun_pci_dma_direction);
-	writel(addr, &sun_pci_fd_ebus_dma->dacr);
+	sun_pci_dma_pending.buf = buffer;
 }
 
 static unsigned int sun_pci_get_dma_residue(void)
@@ -719,7 +743,7 @@
 		sun_fdops.fd_inb = sun_pci_fd_inb;
 		sun_fdops.fd_outb = sun_pci_fd_outb;
 
-		use_virtual_dma = 0;
+		can_use_virtual_dma = use_virtual_dma = 0;
 		sun_fdops.fd_enable_dma = sun_pci_fd_enable_dma;
 		sun_fdops.fd_disable_dma = sun_pci_fd_disable_dma;
 		sun_fdops.fd_set_dma_mode = sun_pci_fd_set_dma_mode;
@@ -796,9 +820,9 @@
 			ns87303_modify(config, ASC, ASC_DRV2_SEL, 0);
 			ns87303_modify(config, FCR, 0, FCR_LDE);
 
-			cfg = sun_floppy_types[0];
+			config = sun_floppy_types[0];
 			sun_floppy_types[0] = sun_floppy_types[1];
-			sun_floppy_types[1] = cfg;
+			sun_floppy_types[1] = config;
 
 			if (sun_pci_broken_drive != -1) {
 				sun_pci_broken_drive = 1 - sun_pci_broken_drive;

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