All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2] spi: cf_qspi: fix clamp macro type check compilation warnings
@ 2015-06-21 21:40 Angelo Dureghello
  2015-06-22  6:44 ` Jagan Teki
  0 siblings, 1 reply; 6+ messages in thread
From: Angelo Dureghello @ 2015-06-21 21:40 UTC (permalink / raw)
  To: u-boot

Fix compilation warnings for redefined 'clamp' macro and non-uniform
clamp macro types.

Signed-off-by: Angelo Dureghello <angelo@sysam.it>
---
 drivers/spi/cf_qspi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/spi/cf_qspi.c b/drivers/spi/cf_qspi.c
index 834c5bd..e57e63e 100644
--- a/drivers/spi/cf_qspi.c
+++ b/drivers/spi/cf_qspi.c
@@ -19,7 +19,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#define clamp(x, low, high) (min(max(low, x), high))
 #define to_cf_qspi_slave(s) container_of(s, struct cf_qspi_slave, slave)
 
 struct cf_qspi_slave {
@@ -120,7 +119,7 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
 		dev->qmr = 2u;
 	else /* Get the closest baud rate */
 		dev->qmr = clamp(((gd->bus_clk >> 2) + max_hz - 1)/max_hz,
-					2u, 255u);
+					2lu, 255lu);
 
 	/* Map mode to QMR[CPOL] and QMR[CPHA] */
 	if (mode & SPI_CPOL)
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH v2] spi: cf_qspi: fix clamp macro type check compilation warnings
  2015-06-21 21:40 [U-Boot] [PATCH v2] spi: cf_qspi: fix clamp macro type check compilation warnings Angelo Dureghello
@ 2015-06-22  6:44 ` Jagan Teki
  2015-06-22  7:19   ` Angelo Dureghello
  0 siblings, 1 reply; 6+ messages in thread
From: Jagan Teki @ 2015-06-22  6:44 UTC (permalink / raw)
  To: u-boot

On 22 June 2015 at 03:10, Angelo Dureghello <angelo@sysam.it> wrote:
> Fix compilation warnings for redefined 'clamp' macro and non-uniform
> clamp macro types.
>
> Signed-off-by: Angelo Dureghello <angelo@sysam.it>
> ---
>  drivers/spi/cf_qspi.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/spi/cf_qspi.c b/drivers/spi/cf_qspi.c
> index 834c5bd..e57e63e 100644
> --- a/drivers/spi/cf_qspi.c
> +++ b/drivers/spi/cf_qspi.c
> @@ -19,7 +19,6 @@
>
>  DECLARE_GLOBAL_DATA_PTR;
>
> -#define clamp(x, low, high) (min(max(low, x), high))
>  #define to_cf_qspi_slave(s) container_of(s, struct cf_qspi_slave, slave)
>
>  struct cf_qspi_slave {
> @@ -120,7 +119,7 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
>                 dev->qmr = 2u;
>         else /* Get the closest baud rate */
>                 dev->qmr = clamp(((gd->bus_clk >> 2) + max_hz - 1)/max_hz,
> -                                       2u, 255u);
> +                                       2lu, 255lu);

Any Tested-by ?

>
>         /* Map mode to QMR[CPOL] and QMR[CPHA] */
>         if (mode & SPI_CPOL)
> --
> 2.1.4
>

thanks!
-- 
Jagan | openedev.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH v2] spi: cf_qspi: fix clamp macro type check compilation warnings
  2015-06-22  6:44 ` Jagan Teki
@ 2015-06-22  7:19   ` Angelo Dureghello
  2015-06-29 20:00     ` Jagan Teki
  0 siblings, 1 reply; 6+ messages in thread
From: Angelo Dureghello @ 2015-06-22  7:19 UTC (permalink / raw)
  To: u-boot



On 22/06/2015 08:44, Jagan Teki wrote:
> On 22 June 2015 at 03:10, Angelo Dureghello <angelo@sysam.it> wrote:
>> Fix compilation warnings for redefined 'clamp' macro and non-uniform
>> clamp macro types.
>>
>> Signed-off-by: Angelo Dureghello <angelo@sysam.it>
>> ---
>>   drivers/spi/cf_qspi.c | 3 +--
>>   1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/drivers/spi/cf_qspi.c b/drivers/spi/cf_qspi.c
>> index 834c5bd..e57e63e 100644
>> --- a/drivers/spi/cf_qspi.c
>> +++ b/drivers/spi/cf_qspi.c
>> @@ -19,7 +19,6 @@
>>
>>   DECLARE_GLOBAL_DATA_PTR;
>>
>> -#define clamp(x, low, high) (min(max(low, x), high))
>>   #define to_cf_qspi_slave(s) container_of(s, struct cf_qspi_slave, slave)
>>
>>   struct cf_qspi_slave {
>> @@ -120,7 +119,7 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
>>                  dev->qmr = 2u;
>>          else /* Get the closest baud rate */
>>                  dev->qmr = clamp(((gd->bus_clk >> 2) + max_hz - 1)/max_hz,
>> -                                       2u, 255u);
>> +                                       2lu, 255lu);
>
> Any Tested-by ?
>

Hi Jagan,

i am supposing there are no issues here, since 2 and 255 are inside the 
8-bit range, and they was unsigned int instead of unsigned long so the 
change gives no effect to the clamp.

I am still waiting the hardware here for proper mcf / qspi-testing. Will
test it then.


Best regards,
Angelo Durgehello

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH v2] spi: cf_qspi: fix clamp macro type check compilation warnings
  2015-06-22  7:19   ` Angelo Dureghello
@ 2015-06-29 20:00     ` Jagan Teki
  2015-06-30 11:07       ` Angelo Dureghello
  0 siblings, 1 reply; 6+ messages in thread
From: Jagan Teki @ 2015-06-29 20:00 UTC (permalink / raw)
  To: u-boot

On 22 June 2015 at 12:49, Angelo Dureghello <angelo@sysam.it> wrote:
>
>
> On 22/06/2015 08:44, Jagan Teki wrote:
>>
>> On 22 June 2015 at 03:10, Angelo Dureghello <angelo@sysam.it> wrote:
>>>
>>> Fix compilation warnings for redefined 'clamp' macro and non-uniform
>>> clamp macro types.
>>>
>>> Signed-off-by: Angelo Dureghello <angelo@sysam.it>
>>> ---
>>>   drivers/spi/cf_qspi.c | 3 +--
>>>   1 file changed, 1 insertion(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/spi/cf_qspi.c b/drivers/spi/cf_qspi.c
>>> index 834c5bd..e57e63e 100644
>>> --- a/drivers/spi/cf_qspi.c
>>> +++ b/drivers/spi/cf_qspi.c
>>> @@ -19,7 +19,6 @@
>>>
>>>   DECLARE_GLOBAL_DATA_PTR;
>>>
>>> -#define clamp(x, low, high) (min(max(low, x), high))
>>>   #define to_cf_qspi_slave(s) container_of(s, struct cf_qspi_slave,
>>> slave)
>>>
>>>   struct cf_qspi_slave {
>>> @@ -120,7 +119,7 @@ struct spi_slave *spi_setup_slave(unsigned int bus,
>>> unsigned int cs,
>>>                  dev->qmr = 2u;
>>>          else /* Get the closest baud rate */
>>>                  dev->qmr = clamp(((gd->bus_clk >> 2) + max_hz -
>>> 1)/max_hz,
>>> -                                       2u, 255u);
>>> +                                       2lu, 255lu);

replacing u with lu - any reason?

>>
>>
>> Any Tested-by ?
>>
>
> Hi Jagan,
>
> i am supposing there are no issues here, since 2 and 255 are inside the
> 8-bit range, and they was unsigned int instead of unsigned long so the
> change gives no effect to the clamp.
>
> I am still waiting the hardware here for proper mcf / qspi-testing. Will
> test it then.

thanks!
-- 
Jagan | openedev.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH v2] spi: cf_qspi: fix clamp macro type check compilation warnings
  2015-06-29 20:00     ` Jagan Teki
@ 2015-06-30 11:07       ` Angelo Dureghello
  2015-07-01 17:31         ` Jagan Teki
  0 siblings, 1 reply; 6+ messages in thread
From: Angelo Dureghello @ 2015-06-30 11:07 UTC (permalink / raw)
  To: u-boot

Hi Jagan,

On 29/06/2015 22:00, Jagan Teki wrote:
> On 22 June 2015 at 12:49, Angelo Dureghello <angelo@sysam.it> wrote:
>>
>>
>> On 22/06/2015 08:44, Jagan Teki wrote:
>>>
>>> On 22 June 2015 at 03:10, Angelo Dureghello <angelo@sysam.it> wrote:
>>>>
>>>> Fix compilation warnings for redefined 'clamp' macro and non-uniform
>>>> clamp macro types.
>>>>
>>>> Signed-off-by: Angelo Dureghello <angelo@sysam.it>
>>>> ---
>>>>    drivers/spi/cf_qspi.c | 3 +--
>>>>    1 file changed, 1 insertion(+), 2 deletions(-)
>>>>
>>>> diff --git a/drivers/spi/cf_qspi.c b/drivers/spi/cf_qspi.c
>>>> index 834c5bd..e57e63e 100644
>>>> --- a/drivers/spi/cf_qspi.c
>>>> +++ b/drivers/spi/cf_qspi.c
>>>> @@ -19,7 +19,6 @@
>>>>
>>>>    DECLARE_GLOBAL_DATA_PTR;
>>>>
>>>> -#define clamp(x, low, high) (min(max(low, x), high))
>>>>    #define to_cf_qspi_slave(s) container_of(s, struct cf_qspi_slave,
>>>> slave)
>>>>
>>>>    struct cf_qspi_slave {
>>>> @@ -120,7 +119,7 @@ struct spi_slave *spi_setup_slave(unsigned int bus,
>>>> unsigned int cs,
>>>>                   dev->qmr = 2u;
>>>>           else /* Get the closest baud rate */
>>>>                   dev->qmr = clamp(((gd->bus_clk >> 2) + max_hz -
>>>> 1)/max_hz,
>>>> -                                       2u, 255u);
>>>> +                                       2lu, 255lu);
>
> replacing u with lu - any reason?

Compiling this file you will get compilation warnings.
The reason is that the "unnecessary type check" throws the warnings 
since clamp (and so included min max) uses different types.

u is unsigned int
lu uniforms types to  gd->bus_clk, that is unsigned long.


Best regards
Angelo Dureghello

>
>>>
>>>
>>> Any Tested-by ?
>>>
>>
>> Hi Jagan,
>>
>> i am supposing there are no issues here, since 2 and 255 are inside the
>> 8-bit range, and they was unsigned int instead of unsigned long so the
>> change gives no effect to the clamp.
>>
>> I am still waiting the hardware here for proper mcf / qspi-testing. Will
>> test it then.
>
> thanks!
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [U-Boot] [PATCH v2] spi: cf_qspi: fix clamp macro type check compilation warnings
  2015-06-30 11:07       ` Angelo Dureghello
@ 2015-07-01 17:31         ` Jagan Teki
  0 siblings, 0 replies; 6+ messages in thread
From: Jagan Teki @ 2015-07-01 17:31 UTC (permalink / raw)
  To: u-boot

On 30 June 2015 at 16:37, Angelo Dureghello <angelo@sysam.it> wrote:
> Hi Jagan,
>
>
> On 29/06/2015 22:00, Jagan Teki wrote:
>>
>> On 22 June 2015 at 12:49, Angelo Dureghello <angelo@sysam.it> wrote:
>>>
>>>
>>>
>>> On 22/06/2015 08:44, Jagan Teki wrote:
>>>>
>>>>
>>>> On 22 June 2015 at 03:10, Angelo Dureghello <angelo@sysam.it> wrote:
>>>>>
>>>>>
>>>>> Fix compilation warnings for redefined 'clamp' macro and non-uniform
>>>>> clamp macro types.
>>>>>
>>>>> Signed-off-by: Angelo Dureghello <angelo@sysam.it>
>>>>> ---
>>>>>    drivers/spi/cf_qspi.c | 3 +--
>>>>>    1 file changed, 1 insertion(+), 2 deletions(-)
>>>>>
>>>>> diff --git a/drivers/spi/cf_qspi.c b/drivers/spi/cf_qspi.c
>>>>> index 834c5bd..e57e63e 100644
>>>>> --- a/drivers/spi/cf_qspi.c
>>>>> +++ b/drivers/spi/cf_qspi.c
>>>>> @@ -19,7 +19,6 @@
>>>>>
>>>>>    DECLARE_GLOBAL_DATA_PTR;
>>>>>
>>>>> -#define clamp(x, low, high) (min(max(low, x), high))
>>>>>    #define to_cf_qspi_slave(s) container_of(s, struct cf_qspi_slave,
>>>>> slave)
>>>>>
>>>>>    struct cf_qspi_slave {
>>>>> @@ -120,7 +119,7 @@ struct spi_slave *spi_setup_slave(unsigned int bus,
>>>>> unsigned int cs,
>>>>>                   dev->qmr = 2u;
>>>>>           else /* Get the closest baud rate */
>>>>>                   dev->qmr = clamp(((gd->bus_clk >> 2) + max_hz -
>>>>> 1)/max_hz,
>>>>> -                                       2u, 255u);
>>>>> +                                       2lu, 255lu);
>>
>>
>> replacing u with lu - any reason?
>
>
> Compiling this file you will get compilation warnings.
> The reason is that the "unnecessary type check" throws the warnings since
> clamp (and so included min max) uses different types.
>
> u is unsigned int
> lu uniforms types to  gd->bus_clk, that is unsigned long.

Applied to u-boot-spi/master

thanks!
-- 
Jagan | openedev.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-07-01 17:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-21 21:40 [U-Boot] [PATCH v2] spi: cf_qspi: fix clamp macro type check compilation warnings Angelo Dureghello
2015-06-22  6:44 ` Jagan Teki
2015-06-22  7:19   ` Angelo Dureghello
2015-06-29 20:00     ` Jagan Teki
2015-06-30 11:07       ` Angelo Dureghello
2015-07-01 17:31         ` Jagan Teki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.