From dc41b8bf3df2b2c3bd833f871d88ff5ef40a19f3 Mon Sep 17 00:00:00 2001 From: Grazvydas Ignotas Date: Wed, 11 Aug 2010 15:56:03 -0700 Subject: [PATCH] mmc: omap3: fix block read function 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 Tested-by: Steve Sakoman Signed-off-by: Sandeep Paulraj --- drivers/mmc/omap3_mmc.c | 47 ++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/drivers/mmc/omap3_mmc.c b/drivers/mmc/omap3_mmc.c index 238f537a25..15d41e55bd 100644 --- a/drivers/mmc/omap3_mmc.c +++ b/drivers/mmc/omap3_mmc.c @@ -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) -- 2.25.1