From: Tom Rini <trini@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 9/9] arch/arm/include/asm/arch-omap5/clocks.h: Fix GCC 4.2 warnings
Date: Mon, 5 Dec 2011 08:08:11 -0700 [thread overview]
Message-ID: <4EDCDE5B.1020402@ti.com> (raw)
In-Reply-To: <20111204145919.160880f3@wker>
On 12/04/2011 06:59 AM, Anatolij Gustschin wrote:
> On Sun, 4 Dec 2011 12:30:40 +0100
> Marek Vasut <marek.vasut@gmail.com> wrote:
>
>>> Fix:
>>> clocks.c: In function 'setup_post_dividers':
>>> clocks.c:175: warning: comparison is always true due to limited range of
>>> data type
>>> clocks.c:177: warning: comparison is always true due to limited range of
>>> data type
>>> clocks.c:179: warning: comparison is always true due to limited range of
>>> data type
>>> clocks.c:181: warning: comparison is always true due to limited range of
>>> data type
>>> clocks.c:183: warning: comparison is always true due to limited range of
>>> data type
>>> clocks.c:185: warning: comparison is always true due to limited range of
>>> data type
>>> clocks.c:187: warning: comparison is always true due to limited range of
>>> data type
>>> clocks.c:189: warning: comparison is always true due to limited range of
>>> data type
>>>
>>> Signed-off-by: Anatolij Gustschin <agust@denx.de>
>>> Cc: sricharan <r.sricharan@ti.com>
>>> Cc: Tom Rini <trini@ti.com>
>>> ---
>>> Some notes:
>>>
>>> - GCC v4.5.1 didn't warn here
>>> - GCC v4.6.1 seems to have a bug and can't compile this code:
>>> clocks.c: In function 'enable_non_essential_clocks':
>>> clocks.c:349:13: internal compiler error: in decode_addr_const, at
>>> varasm.c:2632
>>>
>>> arch/arm/include/asm/arch-omap5/clocks.h | 16 ++++++++--------
>>> 1 files changed, 8 insertions(+), 8 deletions(-)
>>>
>>> diff --git a/arch/arm/include/asm/arch-omap5/clocks.h
>>> b/arch/arm/include/asm/arch-omap5/clocks.h index fa99f65..d0e6dd6 100644
>>> --- a/arch/arm/include/asm/arch-omap5/clocks.h
>>> +++ b/arch/arm/include/asm/arch-omap5/clocks.h
>>> @@ -686,14 +686,14 @@ struct dpll_regs {
>>> struct dpll_params {
>>> u32 m;
>>> u32 n;
>>> - u8 m2;
>>> - u8 m3;
>>> - u8 h11;
>>> - u8 h12;
>>> - u8 h13;
>>> - u8 h14;
>>> - u8 h22;
>>> - u8 h23;
>>> + s8 m2;
>>> + s8 m3;
>>> + s8 h11;
>>> + s8 h12;
>>> + s8 h13;
>>> + s8 h14;
>>> + s8 h22;
>>> + s8 h23;
>>> };
>>>
>>> extern struct omap5_prcm_regs *const prcm;
>>
>> Make clock registers a signed type? whoa
>
> No, we don't make registers a signed type. This is parameters structure
> for some parameter tables containing -1 as an indicator that the
> parameter shouldn't be written to the register. Using unsigned type
> for structure field results in parameter value 255:
>
> static const struct dpll_params per_dpll_params_768mhz[NUM_SYS_CLKS] = {
> {32, 0, 4, 3, 6, 4, -1, 2, -1, -1}, /* 12 MHz */
> {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, /* 13 MHz */
> {160, 6, 4, 3, 6, 4, -1, 2, -1, -1}, /* 16.8 MHz */
> {20, 0, 4, 3, 6, 4, -1, 2, -1, -1}, /* 19.2 MHz */
> {192, 12, 4, 3, 6, 4, -1, 2, -1, -1}, /* 26 MHz */
> {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, /* 27 MHz */
> {10, 0, 4, 3, 6, 4, -1, 2, -1, -1} /* 38.4 MHz */
> };
>
> The code then checks:
>
> void setup_post_dividers(u32 *const base, const struct dpll_params *params)
> {
> struct dpll_regs *const dpll_regs = (struct dpll_regs *)base;
>
> /* Setup post-dividers */
> if (params->m2 >= 0)
> writel(params->m2, &dpll_regs->cm_div_m2_dpll);
> if (params->m3 >= 0)
> writel(params->m3, &dpll_regs->cm_div_m3_dpll);
> if (params->h11 >= 0)
> writel(params->h11, &dpll_regs->cm_div_h11_dpll);
> if (params->h12 >= 0)
> writel(params->h12, &dpll_regs->cm_div_h12_dpll);
> if (params->h13 >= 0)
> writel(params->h13, &dpll_regs->cm_div_h13_dpll);
> if (params->h14 >= 0)
> writel(params->h14, &dpll_regs->cm_div_h14_dpll);
> if (params->h22 >= 0)
> writel(params->h22, &dpll_regs->cm_div_h22_dpll);
> if (params->h23 >= 0)
> writel(params->h23, &dpll_regs->cm_div_h23_dpll);
> }
>
> The result is that the registers will always be written to, since
> the comparison is always true. This is apparently not intended in
> the code.
>
> The actual registers structure 'struct dpll_regs' uses unsigned type.
>
> This sneaked in in the commit 2e5ba489 adding omap5 clock support.
> The similar parameter structure for omap4 used signed type for the
> fields in question.
>
> Newer gcc doesn't warn here unless -Wextra option is used.
Sricharan, my examination, this analysis is correct, can you confirm
that omap5 is supposed to work like omap4 in this case? Thanks.
--
Tom
next prev parent reply other threads:[~2011-12-05 15:08 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-03 16:46 [U-Boot] [PATCH 1/9] common/menu.c: Fix build warning Anatolij Gustschin
2011-12-03 16:46 ` [U-Boot] [PATCH 2/9] drivers/mtd/nand/nand_spl_simple.c: Fix GCC 4.6 warnings Anatolij Gustschin
2011-12-04 9:07 ` Heiko Schocher
2011-12-04 11:24 ` Marek Vasut
2011-12-07 22:10 ` Scott Wood
2011-12-03 16:46 ` [U-Boot] [PATCH 3/9] drivers/mtd/nand/nand_spl_load.c: Fix GCC 4.6 warning Anatolij Gustschin
2011-12-04 9:15 ` Heiko Schocher
2011-12-04 11:24 ` Marek Vasut
2011-12-07 22:11 ` Scott Wood
2011-12-03 16:46 ` [U-Boot] [PATCH 4/9] drivers/usb/musb/musb_udc.c: " Anatolij Gustschin
2011-12-04 11:10 ` Remy Bohmer
2011-12-04 11:25 ` Marek Vasut
2011-12-09 9:36 ` Wolfgang Denk
2011-12-03 16:46 ` [U-Boot] [PATCH 5/9] drivers/usb/gadget/core.c: " Anatolij Gustschin
2011-12-04 11:06 ` Remy Bohmer
2011-12-04 11:27 ` Marek Vasut
2011-12-09 9:37 ` Wolfgang Denk
2011-12-03 16:46 ` [U-Boot] [PATCH 6/9] drivers/usb/gadget/ep0.c: " Anatolij Gustschin
2011-12-04 11:11 ` Remy Bohmer
2011-12-04 11:28 ` Marek Vasut
2011-12-09 9:37 ` Wolfgang Denk
2011-12-03 16:46 ` [U-Boot] [PATCH 7/9] arch/arm/cpu/armv7/omap-common/spl.c: Fix GCC 4.2 warnings Anatolij Gustschin
2011-12-04 11:28 ` Marek Vasut
2011-12-05 15:04 ` Tom Rini
2011-12-03 16:46 ` [U-Boot] [PATCH 8/9] arch/arm/cpu/armv7/omap-common/clocks-common.c: Fix GCC 4.6 warnings Anatolij Gustschin
2011-12-04 11:29 ` Marek Vasut
2011-12-05 15:02 ` Tom Rini
2011-12-05 16:32 ` Anatolij Gustschin
2011-12-05 17:11 ` Tom Rini
2011-12-03 16:46 ` [U-Boot] [PATCH 9/9] arch/arm/include/asm/arch-omap5/clocks.h: Fix GCC 4.2 warnings Anatolij Gustschin
2011-12-04 11:30 ` Marek Vasut
2011-12-04 13:59 ` Anatolij Gustschin
2011-12-05 15:08 ` Tom Rini [this message]
2011-12-06 5:52 ` R, Sricharan
2011-12-04 9:17 ` [U-Boot] [PATCH 1/9] common/menu.c: Fix build warning Heiko Schocher
2011-12-04 11:27 ` Marek Vasut
2011-12-04 11:49 ` Anatolij Gustschin
2011-12-05 22:26 ` Wolfgang Denk
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=4EDCDE5B.1020402@ti.com \
--to=trini@ti.com \
--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