Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Chris Ball <chris@printf.net>

authored by

Axel Lin and committed by
Chris Ball
03a16853 e6cc0123

+5 -5
+5 -5
drivers/mmc/host/omap.c
··· 177 177 unsigned long tick_ns; 178 178 179 179 if (slot != NULL && slot->host->fclk_enabled && slot->fclk_freq > 0) { 180 - tick_ns = (1000000000 + slot->fclk_freq - 1) / slot->fclk_freq; 180 + tick_ns = DIV_ROUND_UP(NSEC_PER_SEC, slot->fclk_freq); 181 181 ndelay(8 * tick_ns); 182 182 } 183 183 } ··· 435 435 struct mmc_data *data = host->stop_data; 436 436 unsigned long tick_ns; 437 437 438 - tick_ns = (1000000000 + slot->fclk_freq - 1)/slot->fclk_freq; 438 + tick_ns = DIV_ROUND_UP(NSEC_PER_SEC, slot->fclk_freq); 439 439 ndelay(8*tick_ns); 440 440 441 441 mmc_omap_start_command(host, data->stop); ··· 477 477 u16 stat = 0; 478 478 479 479 /* Sending abort takes 80 clocks. Have some extra and round up */ 480 - timeout = (120*1000000 + slot->fclk_freq - 1)/slot->fclk_freq; 480 + timeout = DIV_ROUND_UP(120 * USEC_PER_SEC, slot->fclk_freq); 481 481 restarts = 0; 482 482 while (restarts < maxloops) { 483 483 OMAP_MMC_WRITE(host, STAT, 0xFFFF); ··· 677 677 if (n > host->buffer_bytes_left) 678 678 n = host->buffer_bytes_left; 679 679 680 - nwords = n / 2; 681 - nwords += n & 1; /* handle odd number of bytes to transfer */ 680 + /* Round up to handle odd number of bytes to transfer */ 681 + nwords = DIV_ROUND_UP(n, 2); 682 682 683 683 host->buffer_bytes_left -= n; 684 684 host->total_bytes_left -= n;