diff mbox series

[1/1] spi: cadence-quadspi: Fix a compilation warning for 64-bit platform

Message ID 20210112100637.747-2-thunder.leizhen@huawei.com
State New
Headers show
Series spi: cadence-quadspi: Fix a compilation warning for 64-bit platform | expand

Commit Message

Leizhen (ThunderTown) Jan. 12, 2021, 10:06 a.m. UTC
The __typecheck() requires that the two arguments of max() must be of the
same type. For the current max(), the type of the first parameter "len" is
size_t. But the type of size_t is not fixed, it's "unsigned int" on 32-bit
platforms and "unsigned long" on 64-bit platforms. So both the suffix "U"
and "UL" are not appropriate for the second constant parameter. Therefore,
forcible type conversion is used.

Fixes: 8728a81b8f10 ("spi: Fix distinct pointer types warning for ARCH=mips")
Fixes: 0920a32cf6f2 ("spi: cadence-quadspi: Wait at least 500 ms for direct reads")
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>

---
 drivers/spi/spi-cadence-quadspi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--
1.8.3

Comments

Pratyush Yadav Jan. 12, 2021, 10:16 a.m. UTC | #1
Hi Zhen,

On 12/01/21 06:06PM, Zhen Lei wrote:
> The __typecheck() requires that the two arguments of max() must be of the

> same type. For the current max(), the type of the first parameter "len" is

> size_t. But the type of size_t is not fixed, it's "unsigned int" on 32-bit

> platforms and "unsigned long" on 64-bit platforms. So both the suffix "U"

> and "UL" are not appropriate for the second constant parameter. Therefore,

> forcible type conversion is used.

> 

> Fixes: 8728a81b8f10 ("spi: Fix distinct pointer types warning for ARCH=mips")

> Fixes: 0920a32cf6f2 ("spi: cadence-quadspi: Wait at least 500 ms for direct reads")

> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>

> ---

>  drivers/spi/spi-cadence-quadspi.c | 2 +-

>  1 file changed, 1 insertion(+), 1 deletion(-)

> 

> diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c

> index 576610ba11184c6..eb40b8d46b56b0c 100644

> --- a/drivers/spi/spi-cadence-quadspi.c

> +++ b/drivers/spi/spi-cadence-quadspi.c

> @@ -1150,7 +1150,7 @@ static int cqspi_direct_read_execute(struct cqspi_flash_pdata *f_pdata,

> 

>  	dma_async_issue_pending(cqspi->rx_chan);

>  	if (!wait_for_completion_timeout(&cqspi->rx_dma_complete,

> -					 msecs_to_jiffies(max(len, 500U)))) {

> +				 msecs_to_jiffies(max_t(size_t, len, 500)))) {


I sent a patch with this exact fix already [0]. It has made it in Mark's 
for-next branch.

[0] https://lore.kernel.org/linux-spi/20210108181457.30291-1-p.yadav@ti.com/

>  		dmaengine_terminate_sync(cqspi->rx_chan);

>  		dev_err(dev, "DMA wait_for_completion_timeout\n");

>  		ret = -ETIMEDOUT;

> --

> 1.8.3

> 

> 


-- 
Regards,
Pratyush Yadav
Texas Instruments India
Leizhen (ThunderTown) Jan. 12, 2021, 11:23 a.m. UTC | #2
On 2021/1/12 18:16, Pratyush Yadav wrote:
> Hi Zhen,

> 

> On 12/01/21 06:06PM, Zhen Lei wrote:

>> The __typecheck() requires that the two arguments of max() must be of the

>> same type. For the current max(), the type of the first parameter "len" is

>> size_t. But the type of size_t is not fixed, it's "unsigned int" on 32-bit

>> platforms and "unsigned long" on 64-bit platforms. So both the suffix "U"

>> and "UL" are not appropriate for the second constant parameter. Therefore,

>> forcible type conversion is used.

>>

>> Fixes: 8728a81b8f10 ("spi: Fix distinct pointer types warning for ARCH=mips")

>> Fixes: 0920a32cf6f2 ("spi: cadence-quadspi: Wait at least 500 ms for direct reads")

>> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>

>> ---

>>  drivers/spi/spi-cadence-quadspi.c | 2 +-

>>  1 file changed, 1 insertion(+), 1 deletion(-)

>>

>> diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c

>> index 576610ba11184c6..eb40b8d46b56b0c 100644

>> --- a/drivers/spi/spi-cadence-quadspi.c

>> +++ b/drivers/spi/spi-cadence-quadspi.c

>> @@ -1150,7 +1150,7 @@ static int cqspi_direct_read_execute(struct cqspi_flash_pdata *f_pdata,

>>

>>  	dma_async_issue_pending(cqspi->rx_chan);

>>  	if (!wait_for_completion_timeout(&cqspi->rx_dma_complete,

>> -					 msecs_to_jiffies(max(len, 500U)))) {

>> +				 msecs_to_jiffies(max_t(size_t, len, 500)))) {

> 

> I sent a patch with this exact fix already [0]. It has made it in Mark's 

> for-next branch.


OK,I don't known it.

> 

> [0] https://lore.kernel.org/linux-spi/20210108181457.30291-1-p.yadav@ti.com/

> 

>>  		dmaengine_terminate_sync(cqspi->rx_chan);

>>  		dev_err(dev, "DMA wait_for_completion_timeout\n");

>>  		ret = -ETIMEDOUT;

>> --

>> 1.8.3

>>

>>

>
diff mbox series

Patch

diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c
index 576610ba11184c6..eb40b8d46b56b0c 100644
--- a/drivers/spi/spi-cadence-quadspi.c
+++ b/drivers/spi/spi-cadence-quadspi.c
@@ -1150,7 +1150,7 @@  static int cqspi_direct_read_execute(struct cqspi_flash_pdata *f_pdata,

 	dma_async_issue_pending(cqspi->rx_chan);
 	if (!wait_for_completion_timeout(&cqspi->rx_dma_complete,
-					 msecs_to_jiffies(max(len, 500U)))) {
+				 msecs_to_jiffies(max_t(size_t, len, 500)))) {
 		dmaengine_terminate_sync(cqspi->rx_chan);
 		dev_err(dev, "DMA wait_for_completion_timeout\n");
 		ret = -ETIMEDOUT;