patch-2.3.41 linux/arch/sparc/kernel/ioport.c

Next file: linux/arch/sparc/kernel/pcic.c
Previous file: linux/arch/sparc/kernel/ebus.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.40/linux/arch/sparc/kernel/ioport.c linux/arch/sparc/kernel/ioport.c
@@ -1,4 +1,4 @@
-/* $Id: ioport.c,v 1.28 1999/12/27 06:08:28 anton Exp $
+/* $Id: ioport.c,v 1.29 2000/01/22 07:35:25 zaitcev Exp $
  * ioport.c:  Simple io mapping allocator.
  *
  * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
@@ -203,6 +203,7 @@
 		tlen = strlen(name);
 		tack = kmalloc(sizeof (struct resource) + tlen + 1, GFP_KERNEL);
 		if (tack == NULL) return NULL;
+		memset(tack, 0, sizeof(struct resource));
 		res = (struct resource *) tack;
 		tack += sizeof (struct resource);
 	}
@@ -285,8 +286,10 @@
  * Allocate a chunk of memory suitable for DMA.
  * Typically devices use them for control blocks.
  * CPU may access them without any explicit flushing.
+ *
+ * XXX Some clever people know that sdev is not used and supply NULL. Watch.
  */
-void *sbus_alloc_consistant(struct sbus_dev *sdev, long len, u32 *dma_addrp)
+void *sbus_alloc_consistent(struct sbus_dev *sdev, long len, u32 *dma_addrp)
 {
 	unsigned long len_total = (len + PAGE_SIZE-1) & PAGE_MASK;
 	unsigned long va;
@@ -310,26 +313,27 @@
 		/*
 		 * printk here may be flooding... Consider removal XXX.
 		 */
-		printk("sbus_alloc_consistant: no %ld pages\n", len_total>>PAGE_SHIFT);
+		printk("sbus_alloc_consistent: no %ld pages\n", len_total>>PAGE_SHIFT);
 		return NULL;
 	}
 
 	if ((res = kmalloc(sizeof(struct resource), GFP_KERNEL)) == NULL) {
 		free_pages(va, order);
-		printk("sbus_alloc_consistant: no core\n");
+		printk("sbus_alloc_consistent: no core\n");
 		return NULL;
 	}
+	memset((char*)res, 0, sizeof(struct resource));
 
 	if (allocate_resource(&sparc_dvma, res, len_total,
 	    sparc_dvma.start, sparc_dvma.end, PAGE_SIZE, NULL, NULL) != 0) {
-		printk("sbus_alloc_consistant: cannot occupy 0x%lx", len);
+		printk("sbus_alloc_consistent: cannot occupy 0x%lx", len_total);
 		free_pages(va, order);
 		kfree(res);
 		return NULL;
 	}
 
 	*dma_addrp = res->start;
-	mmu_map_dma_area(va, res->start, len);
+	mmu_map_dma_area(va, res->start, len_total);
 
 	/*
 	 * "Official" or "natural" address of pages we got is va.
@@ -342,7 +346,7 @@
 	return (void *)res->start;
 }
 
-void sbus_free_consistant(struct sbus_dev *sdev, long n, void *p, u32 ba)
+void sbus_free_consistent(struct sbus_dev *sdev, long n, void *p, u32 ba)
 {
 	struct resource *res;
 	unsigned long pgp;
@@ -350,18 +354,18 @@
 
 	if ((res = sparc_find_resource_bystart(&sparc_dvma,
 	    (unsigned long)p)) == NULL) {
-		printk("sbus_free_consistant: cannot free %p\n", p);
+		printk("sbus_free_consistent: cannot free %p\n", p);
 		return;
 	}
 
 	if (((unsigned long)p & (PAGE_MASK-1)) != 0) {
-		printk("sbus_free_consistant: unaligned va %p\n", p);
+		printk("sbus_free_consistent: unaligned va %p\n", p);
 		return;
 	}
 
 	n = (n + PAGE_SIZE-1) & PAGE_MASK;
 	if ((res->end-res->start)+1 != n) {
-		printk("sbus_free_consistant: region 0x%lx asked 0x%lx\n",
+		printk("sbus_free_consistent: region 0x%lx asked 0x%lx\n",
 		    (long)((res->end-res->start)+1), n);
 		return;
 	}
@@ -386,7 +390,7 @@
  */
 u32 sbus_map_single(struct sbus_dev *sdev, void *va, long len)
 {
-#if 0 /* This is the version that abuses consistant space */
+#if 0 /* This is the version that abuses consistent space */
 	unsigned long len_total = (len + PAGE_SIZE-1) & PAGE_MASK;
 	struct resource *res;
 
@@ -403,6 +407,7 @@
 		printk("sbus_map_single: no core\n");
 		return 0;
 	}
+	memset((char*)res, 0, sizeof(struct resource));
 	res->name = va;
 
 	if (allocate_resource(&sparc_dvma, res, len_total,
@@ -433,7 +438,7 @@
 
 void sbus_unmap_single(struct sbus_dev *sdev, u32 ba, long n)
 {
-#if 0 /* This is the version that abuses consistant space */
+#if 0 /* This is the version that abuses consistent space */
 	struct resource *res;
 	unsigned long va;
 

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