TC58FVT160 question

Jonas Holmberg jonas.holmberg at axis.com
Fri Nov 9 07:59:45 EST 2001


The patch you gave me for mtdram was pretty useful. Do you want to commit it?

(I added "+ to" compared to your version so use the patch below if you commit)

/Jonas



 static int ram_write(struct mtd_info *mtd, loff_t to, size_t len,
              size_t *retlen, const u_char *buf)
 {
+  size_t c;
+  unsigned char *storage = (char *)mtd->priv + to;
+
   DEBUG(MTD_DEBUG_LEVEL2, "ram_write(pos:%ld, len:%ld)\n", (long)to, (long)len);   if (to + len > mtd->size) {
     DEBUG(MTD_DEBUG_LEVEL1, "ram_write() out of bounds (%ld > %ld)\n", (long)(to + len), (long)mtd->size);
     return -EINVAL;
   }
 
-  memcpy ((char *)mtd->priv + to, buf, len);
+  for (c = 0; c < len; c++) {
+    if ((storage[c] & buf[c]) != buf[c]) {
+      /* We're trying to set bits which weren't set before */
+      printk(KERN_WARNING "mtdram write at 0x%08x tried to set bits "
+             "(from %02x to %02x)\n", to + c, storage[c], buf[c]);
+      *retlen = c;
+      return -EIO;
+    }
+    storage[c] &= buf[c];
+  }
 
   *retlen=len;
   return 0;






More information about the linux-mtd mailing list