linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anton Vorontsov <cbouatmailru@gmail.com>
To: Haijun Zhang <Haijun.Zhang@freescale.com>
Cc: linux-mmc@vger.kernel.org,
	Jerry Huang <Chang-Ming.Huang@freescale.com>,
	Chris Ball <cjb@laptop.org>
Subject: Re: [PATCH] Use u64 to calculate the timeout value to avoid overflow
Date: Mon, 26 Nov 2012 01:09:53 -0800	[thread overview]
Message-ID: <20121126090953.GA11065@lizard> (raw)
In-Reply-To: <1353918959-12146-2-git-send-email-Haijun.Zhang@freescale.com>

On Mon, Nov 26, 2012 at 04:35:59PM +0800, Haijun Zhang wrote:
> As data timeout_ns use u64 to avoid overflow.
> So we use macro div_u64 to perform a division.
[...]
> --- a/drivers/mmc/host/atmel-mci.c
> +++ b/drivers/mmc/host/atmel-mci.c
> @@ -593,17 +593,16 @@ static void atmci_timeout_timer(unsigned long data)
>  	tasklet_schedule(&host->tasklet);
>  }
>  
> -static inline unsigned int atmci_ns_to_clocks(struct atmel_mci *host,
> -					unsigned int ns)
> +static inline unsigned int atmci_ns_to_clocks(struct atmel_mci *host, u64 ns)
>  {
>  	/*
>  	 * 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);
> +	u64 us = DIV_ROUND_UP_ULL(ns, 1000);
>  
>  	/* Maximum clock frequency is host->bus_hz/2 */
> -	return us * (DIV_ROUND_UP(host->bus_hz, 2000000));
> +	return (u32)(us * (DIV_ROUND_UP_ULL(host->bus_hz, 2000000)));

Why do you need u32 cast here?..

Thanks,
Anton.

  reply	other threads:[~2012-11-26  9:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-26  8:35 [PATCH] Powerpc eSDHC: Convert the cmd_timeou_ms to u64 to avoid overflow Haijun Zhang
2012-11-26  8:35 ` [PATCH] Use u64 to calculate the timeout value " Haijun Zhang
2012-11-26  9:09   ` Anton Vorontsov [this message]
2012-11-26  9:12 ` [PATCH] Powerpc eSDHC: Convert the cmd_timeou_ms to u64 " Anton Vorontsov
2012-11-26  9:35   ` Zhang Haijun-B42677

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121126090953.GA11065@lizard \
    --to=cbouatmailru@gmail.com \
    --cc=Chang-Ming.Huang@freescale.com \
    --cc=Haijun.Zhang@freescale.com \
    --cc=cjb@laptop.org \
    --cc=linux-mmc@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).