Commit 03a16853 authored by Axel Lin's avatar Axel Lin Committed by Chris Ball

mmc: omap: Use DIV_ROUND_UP instead of open coded

Also uses NSEC_PER_SEC and USEC_PER_SEC instead of hard-coded value.
This makes the intention more clear.
Signed-off-by: default avatarAxel Lin <axel.lin@ingics.com>
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
Signed-off-by: default avatarChris Ball <chris@printf.net>
parent e6cc0123
...@@ -177,7 +177,7 @@ static void mmc_omap_fclk_offdelay(struct mmc_omap_slot *slot) ...@@ -177,7 +177,7 @@ static void mmc_omap_fclk_offdelay(struct mmc_omap_slot *slot)
unsigned long tick_ns; unsigned long tick_ns;
if (slot != NULL && slot->host->fclk_enabled && slot->fclk_freq > 0) { if (slot != NULL && slot->host->fclk_enabled && slot->fclk_freq > 0) {
tick_ns = (1000000000 + slot->fclk_freq - 1) / slot->fclk_freq; tick_ns = DIV_ROUND_UP(NSEC_PER_SEC, slot->fclk_freq);
ndelay(8 * tick_ns); ndelay(8 * tick_ns);
} }
} }
...@@ -435,7 +435,7 @@ static void mmc_omap_send_stop_work(struct work_struct *work) ...@@ -435,7 +435,7 @@ static void mmc_omap_send_stop_work(struct work_struct *work)
struct mmc_data *data = host->stop_data; struct mmc_data *data = host->stop_data;
unsigned long tick_ns; unsigned long tick_ns;
tick_ns = (1000000000 + slot->fclk_freq - 1)/slot->fclk_freq; tick_ns = DIV_ROUND_UP(NSEC_PER_SEC, slot->fclk_freq);
ndelay(8*tick_ns); ndelay(8*tick_ns);
mmc_omap_start_command(host, data->stop); mmc_omap_start_command(host, data->stop);
...@@ -477,7 +477,7 @@ mmc_omap_send_abort(struct mmc_omap_host *host, int maxloops) ...@@ -477,7 +477,7 @@ mmc_omap_send_abort(struct mmc_omap_host *host, int maxloops)
u16 stat = 0; u16 stat = 0;
/* Sending abort takes 80 clocks. Have some extra and round up */ /* Sending abort takes 80 clocks. Have some extra and round up */
timeout = (120*1000000 + slot->fclk_freq - 1)/slot->fclk_freq; timeout = DIV_ROUND_UP(120 * USEC_PER_SEC, slot->fclk_freq);
restarts = 0; restarts = 0;
while (restarts < maxloops) { while (restarts < maxloops) {
OMAP_MMC_WRITE(host, STAT, 0xFFFF); OMAP_MMC_WRITE(host, STAT, 0xFFFF);
...@@ -677,8 +677,8 @@ mmc_omap_xfer_data(struct mmc_omap_host *host, int write) ...@@ -677,8 +677,8 @@ mmc_omap_xfer_data(struct mmc_omap_host *host, int write)
if (n > host->buffer_bytes_left) if (n > host->buffer_bytes_left)
n = host->buffer_bytes_left; n = host->buffer_bytes_left;
nwords = n / 2; /* Round up to handle odd number of bytes to transfer */
nwords += n & 1; /* handle odd number of bytes to transfer */ nwords = DIV_ROUND_UP(n, 2);
host->buffer_bytes_left -= n; host->buffer_bytes_left -= n;
host->total_bytes_left -= n; host->total_bytes_left -= n;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment