[PATCH v2 1/2] mmc: tmio: Check 'addr' width before checking for 64bit limitation

Jaehoon Chung jh80.chung at gmail.com
Mon Mar 13 14:05:33 CET 2023


On 3/1/23 06:18, Marek Vasut wrote:
> The 64bit limitation check is compiled and optimized out on 32bit
> platforms, but generates a type width warning:
> 
> drivers/mmc/tmio-common.c: In function ‘tmio_sd_addr_is_dmaable’:
> drivers/mmc/tmio-common.c:376:26: warning: right shift count >= width of type [-Wshift-count-overflow]
>   376 |                 if (addr >> 32)
>       |                          ^~
> 
> Fix the warning by checking the addr type width to see whether the
> shift even makes sense in the first place. The width check is also
> optimized out at compile time.
> 
> Signed-off-by: Marek Vasut <marek.vasut+renesas at mailbox.org>

Reviewed-by: Jaehoon Chung <jh80.chung at samsung.com>

Best Regards,
Jaehoon Chung

> ---
> Cc: Jaehoon Chung <jh80.chung at samsung.com>
> Cc: Peng Fan <peng.fan at nxp.com>
> ---
> V2: New patch
> ---
>  drivers/mmc/tmio-common.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/tmio-common.c b/drivers/mmc/tmio-common.c
> index e9c7d3a2e00..0b24a5a7bdb 100644
> --- a/drivers/mmc/tmio-common.c
> +++ b/drivers/mmc/tmio-common.c
> @@ -373,7 +373,7 @@ static bool tmio_sd_addr_is_dmaable(struct mmc_data *data)
>  	if (!(data->flags & MMC_DATA_READ) && !IS_ALIGNED(addr, 128))
>  		return false;
>  	/* Gen3 DMA has 32bit limit */
> -	if (addr >> 32)
> +	if (sizeof(addr) > 4 && addr >> 32)
>  		return false;
>  #endif
>  


More information about the U-Boot mailing list