diff options
author | Stefano Babic <sbabic@denx.de> | 2015-07-10 09:21:44 +0200 |
---|---|---|
committer | Stefano Babic <sbabic@denx.de> | 2015-07-10 09:21:44 +0200 |
commit | 1254ff97abb7606ccd0d7bdcd9f22581c50fe535 (patch) | |
tree | 61b31e61173154abd38aaa6584e84ea77314b861 /drivers/mmc | |
parent | 54e0f96f764f662be186baae7d6c2c97423bc29d (diff) | |
parent | f3edfd30541d6f245d7dfa6fa7354cc916cc53e1 (diff) |
Merge branch 'master' of git://git.denx.de/u-boot
Diffstat (limited to 'drivers/mmc')
-rw-r--r-- | drivers/mmc/bcm2835_sdhci.c | 4 | ||||
-rw-r--r-- | drivers/mmc/mmc_write.c | 12 |
2 files changed, 13 insertions, 3 deletions
diff --git a/drivers/mmc/bcm2835_sdhci.c b/drivers/mmc/bcm2835_sdhci.c index 078ef0523a9..227d2dfa2ef 100644 --- a/drivers/mmc/bcm2835_sdhci.c +++ b/drivers/mmc/bcm2835_sdhci.c @@ -69,11 +69,11 @@ static inline void bcm2835_sdhci_raw_writel(struct sdhci_host *host, u32 val, * (Which is just as well - otherwise we'd have to nobble the DMA engine * too) */ - while (get_timer(bcm_host->last_write) < bcm_host->twoticks_delay) + while (timer_get_us() - bcm_host->last_write < bcm_host->twoticks_delay) ; writel(val, host->ioaddr + reg); - bcm_host->last_write = get_timer(0); + bcm_host->last_write = timer_get_us(); } static inline u32 bcm2835_sdhci_raw_readl(struct sdhci_host *host, int reg) diff --git a/drivers/mmc/mmc_write.c b/drivers/mmc/mmc_write.c index 3db9669c82e..7aea7e943b9 100644 --- a/drivers/mmc/mmc_write.c +++ b/drivers/mmc/mmc_write.c @@ -10,6 +10,8 @@ #include <config.h> #include <common.h> #include <part.h> +#include <div64.h> +#include <linux/math64.h> #include "mmc_private.h" static ulong mmc_erase_t(struct mmc *mmc, ulong start, lbaint_t blkcnt) @@ -66,6 +68,7 @@ err_out: unsigned long mmc_berase(int dev_num, lbaint_t start, lbaint_t blkcnt) { int err = 0; + u32 start_rem, blkcnt_rem; struct mmc *mmc = find_mmc_device(dev_num); lbaint_t blk = 0, blk_r = 0; int timeout = 1000; @@ -73,7 +76,14 @@ unsigned long mmc_berase(int dev_num, lbaint_t start, lbaint_t blkcnt) if (!mmc) return -1; - if ((start % mmc->erase_grp_size) || (blkcnt % mmc->erase_grp_size)) + /* + * We want to see if the requested start or total block count are + * unaligned. We discard the whole numbers and only care about the + * remainder. + */ + err = div_u64_rem(start, mmc->erase_grp_size, &start_rem); + err = div_u64_rem(blkcnt, mmc->erase_grp_size, &blkcnt_rem); + if (start_rem || blkcnt_rem) printf("\n\nCaution! Your devices Erase group is 0x%x\n" "The erase range would be change to " "0x" LBAF "~0x" LBAF "\n\n", |