Re: [PATCH] Use u64 to calculate the timeout value to avoid overflow

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux