[PATCH] mtd: spi-nor: Fix chip erase timeout issue
Marek Vasut
marex at denx.de
Thu Sep 12 11:23:50 CEST 2024
On 9/12/24 10:48 AM, Ye Li wrote:
[...]
>>> + timeout = max(CHIP_ERASE_2MB_READY_WAIT_JIFFIES,
>>> + CHIP_ERASE_2MB_READY_WAIT_JIFFIES *
>>> + (unsigned long)(mtd->size / SZ_2M));
>> Is the type cast needed ?
>
> Yes. otherwise get below warning
>
>
> In file included from include/linux/bitops.h:22,
> from include/log.h:15,
> from drivers/mtd/spi/spi-nor-core.c:13:
> drivers/mtd/spi/spi-nor-core.c: In function ‘spi_nor_erase’:
> include/linux/kernel.h:190:24: warning: comparison of distinct pointer
> types lacks a cast
> 190 | (void) (&_max1 == &_max2); \
> | ^~
> drivers/mtd/spi/spi-nor-core.c:1042:35: note: in expansion of macro ‘max’
> 1042 | timeout =
> max(CHIP_ERASE_2MB_READY_WAIT_JIFFIES,
> |
mtd->size is uint64 , so you need to use do_div() :
u64 sz = mtd->size;
do_div(sz, SZ_2M);
timeout = CHIP_ERASE_2MB_READY_WAIT_JIFFIES * max(1ULL, sz);
More information about the U-Boot
mailing list