From 0094f0353a09a649114e0fff1000a6968aed1cb2 Mon Sep 17 00:00:00 2001 From: Ludovic Desroches Date: Wed, 28 Mar 2012 12:28:33 +0200 Subject: [PATCH] --- yaml --- r: 298796 b: refs/heads/master c: 66292ad92c6d3f2f1c137a1c826b331ca8595dfd h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/drivers/mmc/host/atmel-mci.c | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/[refs] b/[refs] index 1488ad198595..76a581d53963 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 9f4e8151dbbc4ca4d5dd7792666a50c137102204 +refs/heads/master: 66292ad92c6d3f2f1c137a1c826b331ca8595dfd diff --git a/trunk/drivers/mmc/host/atmel-mci.c b/trunk/drivers/mmc/host/atmel-mci.c index 9819dc09ce08..34080f590f69 100644 --- a/trunk/drivers/mmc/host/atmel-mci.c +++ b/trunk/drivers/mmc/host/atmel-mci.c @@ -482,7 +482,14 @@ static void atmci_init_debugfs(struct atmel_mci_slot *slot) static inline unsigned int atmci_ns_to_clocks(struct atmel_mci *host, unsigned int ns) { - return (ns * (host->bus_hz / 1000000) + 999) / 1000; + /* + * It is easier here to use us instead of ns for the timeout, + * it prevents from overflows during calculation. + */ + unsigned int us = DIV_ROUND_UP(ns, 1000); + + /* Maximum clock frequency is host->bus_hz/2 */ + return us * (DIV_ROUND_UP(host->bus_hz, 2000000)); } static void atmci_set_timeout(struct atmel_mci *host,