mtd/drivers/mtd/maps ixp4xx.c,1.5,1.6

gleixner at infradead.org gleixner at infradead.org
Thu Sep 16 20:25:09 EDT 2004


Update of /home/cvs/mtd/drivers/mtd/maps
In directory phoenix.infradead.org:/tmp/cvs-serv8167

Modified Files:
	ixp4xx.c 
Log Message:
Prevent unaligned access during probing. Initial patch provided by Signed-off-by: Scott Wood <scott.wood at timesys.com>

Index: ixp4xx.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/maps/ixp4xx.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ixp4xx.c	16 Sep 2004 23:27:13 -0000	1.5
+++ ixp4xx.c	17 Sep 2004 00:25:06 -0000	1.6
@@ -69,9 +69,22 @@
 		dest[len - 1] = BYTE0(src[i]);
 }
 
+/* 
+ * Unaligned writes are ignored, causing the 8-bit
+ * probe to fail and proceed to the 16-bit probe (which succeeds).
+ */
+static void ixp4xx_probe_write16(struct map_info *map, map_word d, unsigned long adr)
+{
+	if (!(adr & 1))
+	       *(__u16 *) (map->map_priv_1 + adr) = d.x[0];
+}
+
+/* 
+ * Fast write16 function without the probing check above
+ */
 static void ixp4xx_write16(struct map_info *map, map_word d, unsigned long adr)
 {
-	*(__u16 *) (map->map_priv_1 + adr) = d.x[0];
+       *(__u16 *) (map->map_priv_1 + adr) = d.x[0];
 }
 
 struct ixp4xx_flash_info {
@@ -171,7 +184,7 @@
 	info->map.bankwidth = 2;
 	info->map.name = dev->dev.bus_id;
 	info->map.read = ixp4xx_read16,
-	info->map.write = ixp4xx_write16,
+	info->map.write = ixp4xx_probe_write16,
 	info->map.copy_from = ixp4xx_copy_from,
 
 	info->res = request_mem_region(dev->resource->start, 
@@ -199,6 +212,9 @@
 		goto Error;
 	}
 	info->mtd->owner = THIS_MODULE;
+	
+	/* Use the fast version */
+	info->map.write = ixp4xx_write16,
 
 	err = parse_mtd_partitions(info->mtd, probes, &info->partitions, 0);
 	if (err > 0) {





More information about the linux-mtd-cvs mailing list