Patchwork [U-Boot,U-boot] mmc write|read howto

login
register
mail settings
Submitter Wu, Josh
Date April 27, 2013, 10:52 a.m.
Message ID <517BADE4.30609@atmel.com>
Download mbox | patch
Permalink /patch/240103/
State Not Applicable
Headers show

Comments

Wu, Josh - April 27, 2013, 10:52 a.m.
Hi, Jagan

Since I am working on the fatwrite part for the moment. And there is a 
bug find in U-Boot fat write.
You can check the thread here: 
http://article.gmane.org/gmane.comp.boot-loaders.u-boot/158939

following patch can fix it:


          startsect = mydata->data_begin +
@@ -571,7 +571,11 @@ set_cluster(fsdata *mydata, __u32 clustnum, __u8 
*buffer,

      debug("clustnum: %d, startsect: %d\n", clustnum, startsect);

-    if (disk_write(startsect, size / mydata->sect_size, buffer) < 0) {
+    nr_sectors = size / mydata->sect_size;
+    if (nr_sectors == 0)
+        nr_sectors = 1;
+
+    if (disk_write(startsect, nr_sectors, buffer) < 0) {
          debug("Error writing data\n");
          return -1;
      }

Patch

diff --git a/fs/fat/fat_write.c b/fs/fat/fat_write.c
index 5829adf..b7ba8ea 100644
--- a/fs/fat/fat_write.c
+++ b/fs/fat/fat_write.c
@@ -561,7 +561,7 @@  set_cluster(fsdata *mydata, __u32 clustnum, __u8 
*buffer,
           unsigned long size)
  {
      int idx = 0;
-    __u32 startsect;
+    __u32 startsect, nr_sectors;

      if (clustnum > 0)