public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Angelo Dureghello <angelo@sysam.it>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2] spi: cf_qspi: fix clamp macro type check compilation warnings
Date: Tue, 30 Jun 2015 13:07:00 +0200	[thread overview]
Message-ID: <55927854.7090505@sysam.it> (raw)
In-Reply-To: <CAD6G_RQ94YErOZ7Zce0YRU-_2bwhQ5OTbM0Wnw4-p851T8zSxw@mail.gmail.com>

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!
>

  reply	other threads:[~2015-06-30 11:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2015-07-01 17:31         ` Jagan Teki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55927854.7090505@sysam.it \
    --to=angelo@sysam.it \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox