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 / mtd / maps / dc21285.c
index 938c41f..8b3784e 100644 (file)
@@ -4,8 +4,8 @@
  * (C) 2000  Nicolas Pitre <nico@cam.org>
  *
  * This code is GPL
- * 
- * $Id: dc21285.c,v 1.22 2004/11/01 13:39:21 rmk Exp $
+ *
+ * $Id: dc21285.c,v 1.24 2005/11/07 11:14:26 gleixner Exp $
  */
 #include <linux/config.h>
 #include <linux/module.h>
@@ -13,6 +13,7 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/map.h>
@@ -26,9 +27,9 @@
 static struct mtd_info *dc21285_mtd;
 
 #ifdef CONFIG_ARCH_NETWINDER
-/* 
+/*
  * This is really ugly, but it seams to be the only
- * realiable way to do it, as the cpld state machine 
+ * realiable way to do it, as the cpld state machine
  * is unpredictible. So we have a 25us penalty per
  * write access.
  */
@@ -109,8 +110,9 @@ static void dc21285_copy_to_32(struct map_info *map, unsigned long to, const voi
 {
        while (len > 0) {
                map_word d;
-               d.x[0] = *((uint32_t*)from)++;
+               d.x[0] = *((uint32_t*)from);
                dc21285_write32(map, d, to);
+               from += 4;
                to += 4;
                len -= 4;
        }
@@ -120,8 +122,9 @@ static void dc21285_copy_to_16(struct map_info *map, unsigned long to, const voi
 {
        while (len > 0) {
                map_word d;
-               d.x[0] = *((uint16_t*)from)++;
+               d.x[0] = *((uint16_t*)from);
                dc21285_write16(map, d, to);
+               from += 2;
                to += 2;
                len -= 2;
        }
@@ -130,8 +133,9 @@ static void dc21285_copy_to_16(struct map_info *map, unsigned long to, const voi
 static void dc21285_copy_to_8(struct map_info *map, unsigned long to, const void *from, ssize_t len)
 {
        map_word d;
-       d.x[0] = *((uint8_t*)from)++;
+       d.x[0] = *((uint8_t*)from);
        dc21285_write8(map, d, to);
+       from++;
        to++;
        len--;
 }
@@ -149,7 +153,7 @@ static struct map_info dc21285_map = {
 static struct mtd_partition *dc21285_parts;
 static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
 #endif
-  
+
 static int __init init_dc21285(void)
 {
 
@@ -159,20 +163,20 @@ static int __init init_dc21285(void)
 
        /* Determine bankwidth */
        switch (*CSR_SA110_CNTL & (3<<14)) {
-               case SA110_CNTL_ROMWIDTH_8: 
+               case SA110_CNTL_ROMWIDTH_8:
                        dc21285_map.bankwidth = 1;
                        dc21285_map.read = dc21285_read8;
                        dc21285_map.write = dc21285_write8;
                        dc21285_map.copy_to = dc21285_copy_to_8;
                        break;
-               case SA110_CNTL_ROMWIDTH_16: 
-                       dc21285_map.bankwidth = 2; 
+               case SA110_CNTL_ROMWIDTH_16:
+                       dc21285_map.bankwidth = 2;
                        dc21285_map.read = dc21285_read16;
                        dc21285_map.write = dc21285_write16;
                        dc21285_map.copy_to = dc21285_copy_to_16;
                        break;
-               case SA110_CNTL_ROMWIDTH_32: 
-                       dc21285_map.bankwidth = 4; 
+               case SA110_CNTL_ROMWIDTH_32:
+                       dc21285_map.bankwidth = 4;
                        dc21285_map.read = dc21285_read32;
                        dc21285_map.write = dc21285_write32;
                        dc21285_map.copy_to = dc21285_copy_to_32;
@@ -200,20 +204,20 @@ static int __init init_dc21285(void)
        if (!dc21285_mtd) {
                iounmap(dc21285_map.virt);
                return -ENXIO;
-       }       
-       
+       }
+
        dc21285_mtd->owner = THIS_MODULE;
 
 #ifdef CONFIG_MTD_PARTITIONS
        nrparts = parse_mtd_partitions(dc21285_mtd, probes, &dc21285_parts, 0);
        if (nrparts > 0)
                add_mtd_partitions(dc21285_mtd, dc21285_parts, nrparts);
-       else    
-#endif 
+       else
+#endif
                add_mtd_device(dc21285_mtd);
-                       
+
        if(machine_is_ebsa285()) {
-               /* 
+               /*
                 * Flash timing is determined with bits 19-16 of the
                 * CSR_SA110_CNTL.  The value is the number of wait cycles, or
                 * 0 for 16 cycles (the default).  Cycles are 20 ns.
@@ -226,7 +230,7 @@ static int __init init_dc21285(void)
                /* tristate time */
                *CSR_SA110_CNTL = ((*CSR_SA110_CNTL & ~0x0f000000) | (7 << 24));
        }
-       
+
        return 0;
 }