[PATCH] pxa3xx_nand: fix time calculation
Artem Bityutskiy
dedekind1 at gmail.com
Sun Oct 11 08:51:15 EDT 2009
On Wed, 2009-10-07 at 11:31 +0200, Enrico Scholz wrote:
> Use DIV_ROUND_UP to calculate number of clocks. Else, calculated clocks
> are nearly always to low and for times < 10ns, they will be negative on
> PXA320 (which has a nand clock of 104 MHz).
>
> Signed-off-by: Enrico Scholz <enrico.scholz at sigma-chemnitz.de>
> ---
> drivers/mtd/nand/pxa3xx_nand.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c
> index 6ea520a..32cb4d1 100644
> --- a/drivers/mtd/nand/pxa3xx_nand.c
> +++ b/drivers/mtd/nand/pxa3xx_nand.c
> @@ -316,7 +316,7 @@ static struct pxa3xx_nand_flash *builtin_flash_types[] = {
> #define tAR_NDTR1(r) (((r) >> 0) & 0xf)
>
> /* convert nano-seconds to nand flash controller clock cycles */
> -#define ns2cycle(ns, clk) (int)(((ns) * (clk / 1000000) / 1000) - 1)
> +#define ns2cycle(ns, clk) (int)(DIV_ROUND_UP((ns) * (clk / 1000000), 1000) - 1)
Why there is -1 at the end?
--
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
More information about the linux-mtd
mailing list