]> git.sur5r.net Git - u-boot/commitdiff
mmc: omap3: fix block read function
authorGrazvydas Ignotas <notasas at>
Wed, 11 Aug 2010 22:56:03 +0000 (15:56 -0700)
committerSandeep Paulraj <s-paulraj@ti.com>
Thu, 12 Aug 2010 17:50:25 +0000 (13:50 -0400)
The OMAP3 block read function is not following API and always returning
1 instead of read block count, fix it. Also to simplify code, merge it
with with a helper function, which was only called from the block read
function.

After this patch ext2 filesystem can be used properly.

Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
Tested-by: Steve Sakoman <steve@sakoman.com>
Signed-off-by: Sandeep Paulraj <s-paulraj@ti.com>
drivers/mmc/omap3_mmc.c

index 238f537a2526bf410277955b0949a6ff1abf98ab..15d41e55bd1606b05ddc925f3c90eb3f68d47a90 100644 (file)
@@ -434,42 +434,45 @@ static unsigned char mmc_read_cardsize(mmc_card_data *mmc_dev_data,
        return 1;
 }
 
-static unsigned char omap_mmc_read_sect(unsigned int start_sec,
-               unsigned int num_bytes, mmc_card_data *mmc_c,
-               unsigned long *output_buf)
+static unsigned long mmc_bread(int dev_num, unsigned long blknr,
+               lbaint_t blkcnt, void *dst)
 {
        unsigned char err;
        unsigned int argument;
        unsigned int resp[4];
-       unsigned int num_sec_val =
-               (num_bytes + (MMCSD_SECTOR_SIZE - 1)) / MMCSD_SECTOR_SIZE;
+       unsigned int *output_buf = dst;
        unsigned int sec_inc_val;
+       lbaint_t i;
 
-       if (num_sec_val == 0)
-               return 1;
+       if (blkcnt == 0)
+               return 0;
 
-       if (mmc_c->mode == SECTOR_MODE) {
-               argument = start_sec;
+       if (cur_card_data.mode == SECTOR_MODE) {
+               argument = blknr;
                sec_inc_val = 1;
        } else {
-               argument = start_sec * MMCSD_SECTOR_SIZE;
+               argument = blknr * MMCSD_SECTOR_SIZE;
                sec_inc_val = MMCSD_SECTOR_SIZE;
        }
 
-       while (num_sec_val) {
+       for (i = 0; i < blkcnt; i++) {
                err = mmc_send_cmd(MMC_CMD17, argument, resp);
-               if (err != 1)
-                       return err;
+               if (err != 1) {
+                       printf("mmc: CMD17 failed, status = %08x\n", err);
+                       break;
+               }
 
-               err = mmc_read_data((unsigned int *) output_buf);
-               if (err != 1)
-                       return err;
+               err = mmc_read_data(output_buf);
+               if (err != 1) {
+                       printf("mmc: read failed, status = %08x\n", err);
+                       break;
+               }
 
                output_buf += (MMCSD_SECTOR_SIZE / 4);
                argument += sec_inc_val;
-               num_sec_val--;
        }
-       return 1;
+
+       return i;
 }
 
 static unsigned char configure_mmc(mmc_card_data *mmc_card_cur)
@@ -542,14 +545,6 @@ static unsigned char configure_mmc(mmc_card_data *mmc_card_cur)
        return 1;
 }
 
-static unsigned long mmc_bread(int dev_num, unsigned long blknr,
-               lbaint_t blkcnt, void *dst)
-{
-       omap_mmc_read_sect(blknr, (blkcnt * MMCSD_SECTOR_SIZE), &cur_card_data,
-                               (unsigned long *) dst);
-       return 1;
-}
-
 int mmc_legacy_init(int dev)
 {
        if (mmc_set_dev(dev) != 0)