diff mbox

[U-Boot,07/11] arm: socfpga: sysmgr: Fix casting warning when enabling ARM64

Message ID 1471878163-3598-8-git-send-email-clsee@altera.com
State Superseded
Delegated to: Marek Vasut
Headers show

Commit Message

Chin Liang See Aug. 22, 2016, 3:02 p.m. UTC
Fix casting warning to pointer from integer of different size
when enabling ARM64 support

Signed-off-by: Chin Liang See <clsee@altera.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Dinh Nguyen <dinguyen@opensource.altera.com>
Cc: Ley Foon Tan <lftan@altera.com>
---
 arch/arm/mach-socfpga/system_manager.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Marek Vasut Sept. 5, 2016, 4:02 p.m. UTC | #1
On 08/22/2016 05:02 PM, Chin Liang See wrote:
> Fix casting warning to pointer from integer of different size
> when enabling ARM64 support

What sort of error did you observe ?

> Signed-off-by: Chin Liang See <clsee@altera.com>
> Cc: Marek Vasut <marex@denx.de>
> Cc: Dinh Nguyen <dinguyen@opensource.altera.com>
> Cc: Ley Foon Tan <lftan@altera.com>
> ---
>  arch/arm/mach-socfpga/system_manager.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm/mach-socfpga/system_manager.c b/arch/arm/mach-socfpga/system_manager.c
> index 75a65f3..89161bd 100644
> --- a/arch/arm/mach-socfpga/system_manager.c
> +++ b/arch/arm/mach-socfpga/system_manager.c
> @@ -56,7 +56,7 @@ static void populate_sysmgr_fpgaintf_module(void)
>   */
>  void sysmgr_pinmux_init(void)
>  {
> -	uint32_t regs = (uint32_t)&sysmgr_regs->emacio[0];
> +	uint32_t *regs = (uint32_t *)&sysmgr_regs->emacio[0];
>  	const u8 *sys_mgr_init_table;
>  	unsigned int len;
>  	int i;
>
Chin Liang See Sept. 6, 2016, 9:41 a.m. UTC | #2
On Mon, 2016-09-05 at 18:02 +0200, Marek Vasut wrote:
> On 08/22/2016 05:02 PM, Chin Liang See wrote:
> > Fix casting warning to pointer from integer of different size
> > when enabling ARM64 support
> 
> What sort of error did you observe ?

The warning is triggered as ARM64 has build flag -Wpointer-to-int-cast
and similar. Here is the build error log

arch/arm/mach-socfpga/system_manager.c: In function sysmgr_pinmux_init:
                                                                       
          arch/arm/mach-socfpga/system_manager.c:59:18: warning: cast
from pointer to integer of different size [-Wpointer-to-int-cast]      
                          uint32_t regs = (uint32_t)&sysmgr_regs
->emacio[0];                                                           
                                                              ^        
                                                                       
                                                          In file
included from arch/arm/mach-socfpga/system_manager.c:8:0:              
                                                                       
      ./arch/arm/include/asm/io.h:78:29: warning: cast to pointer from
integer of different size [-Wint-to-pointer-cast]                      
                    #define __arch_putl(v,a)  (*(volatile unsigned int
*)(a) = (v))                                                           
                                                             ^  
Thanks
Chin Liang


> 
> > Signed-off-by: Chin Liang See <clsee@altera.com>
> > Cc: Marek Vasut <marex@denx.de>
> > Cc: Dinh Nguyen <dinguyen@opensource.altera.com>
> > Cc: Ley Foon Tan <lftan@altera.com>
> > ---
> >  arch/arm/mach-socfpga/system_manager.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/arch/arm/mach-socfpga/system_manager.c b/arch/arm/mach
> > -socfpga/system_manager.c
> > index 75a65f3..89161bd 100644
> > --- a/arch/arm/mach-socfpga/system_manager.c
> > +++ b/arch/arm/mach-socfpga/system_manager.c
> > @@ -56,7 +56,7 @@ static void populate_sysmgr_fpgaintf_module(void)
> >   */
> >  void sysmgr_pinmux_init(void)
> >  {
> > -	uint32_t regs = (uint32_t)&sysmgr_regs->emacio[0];
> > +	uint32_t *regs = (uint32_t *)&sysmgr_regs->emacio[0];
> >  	const u8 *sys_mgr_init_table;
> >  	unsigned int len;
> >  	int i;
> > 
> 
>
Marek Vasut Sept. 6, 2016, 12:12 p.m. UTC | #3
On 09/06/2016 11:41 AM, Chin Liang See wrote:
> On Mon, 2016-09-05 at 18:02 +0200, Marek Vasut wrote:
>> On 08/22/2016 05:02 PM, Chin Liang See wrote:
>>> Fix casting warning to pointer from integer of different size
>>> when enabling ARM64 support
>>
>> What sort of error did you observe ?
> 
> The warning is triggered as ARM64 has build flag -Wpointer-to-int-cast
> and similar. Here is the build error log
> 
> arch/arm/mach-socfpga/system_manager.c: In function sysmgr_pinmux_init:
>                                                                        
>           arch/arm/mach-socfpga/system_manager.c:59:18: warning: cast
> from pointer to integer of different size [-Wpointer-to-int-cast]      
>                           uint32_t regs = (uint32_t)&sysmgr_regs
> ->emacio[0];                                                           
>                                                               ^        
>                                                                        
>                                                           In file
> included from arch/arm/mach-socfpga/system_manager.c:8:0:              
>                                                                        
>       ./arch/arm/include/asm/io.h:78:29: warning: cast to pointer from
> integer of different size [-Wint-to-pointer-cast]                      
>                     #define __arch_putl(v,a)  (*(volatile unsigned int
> *)(a) = (v))                                                           

I see ... Except the code below does regs += sizeof(regs); , which in
the original case increments the address by 4 , but with your change,
the increment would be 16 . So this patch breaks things.

btw it's not worth reposting patches while there is still ongoing
discussion.
Chin Liang See Sept. 7, 2016, 1:31 p.m. UTC | #4
On Tue, 2016-09-06 at 14:12 +0200, Marek Vasut wrote:
> On 09/06/2016 11:41 AM, Chin Liang See wrote:
> > On Mon, 2016-09-05 at 18:02 +0200, Marek Vasut wrote:
> > > On 08/22/2016 05:02 PM, Chin Liang See wrote:
> > > > Fix casting warning to pointer from integer of different size
> > > > when enabling ARM64 support
> > > 
> > > What sort of error did you observe ?
> > 
> > The warning is triggered as ARM64 has build flag -Wpointer-to-int
> > -cast
> > and similar. Here is the build error log
> > 
> > arch/arm/mach-socfpga/system_manager.c: In function
> > sysmgr_pinmux_init:
> >                                                                    
> >     
> >           arch/arm/mach-socfpga/system_manager.c:59:18: warning:
> > cast
> > from pointer to integer of different size [-Wpointer-to-int-cast]  
> >     
> >                           uint32_t regs = (uint32_t)&sysmgr_regs
> > ->emacio[0];                                                       
> >     
> >                                                               ^    
> >     
> >                                                                    
> >     
> >                                                           In file
> > included from arch/arm/mach-socfpga/system_manager.c:8:0:          
> >     
> >                                                                    
> >     
> >       ./arch/arm/include/asm/io.h:78:29: warning: cast to pointer
> > from
> > integer of different size [-Wint-to-pointer-cast]                  
> >     
> >                     #define __arch_putl(v,a)  (*(volatile unsigned
> > int
> > *)(a) = (v))                                                       
> >     
> 
> I see ... Except the code below does regs += sizeof(regs); , which in
> the original case increments the address by 4 , but with your change,
> the increment would be 16 . So this patch breaks things.
> 

Relook back, this portion is not being used and hence not being
validated. Will put #ifdef in place to skip out these code.

Thanks
Chin Liang


> btw it's not worth reposting patches while there is still ongoing
> discussion.
>
Marek Vasut Sept. 7, 2016, 2:54 p.m. UTC | #5
On 09/07/2016 03:31 PM, Chin Liang See wrote:
> On Tue, 2016-09-06 at 14:12 +0200, Marek Vasut wrote:
>> On 09/06/2016 11:41 AM, Chin Liang See wrote:
>>> On Mon, 2016-09-05 at 18:02 +0200, Marek Vasut wrote:
>>>> On 08/22/2016 05:02 PM, Chin Liang See wrote:
>>>>> Fix casting warning to pointer from integer of different size
>>>>> when enabling ARM64 support
>>>>
>>>> What sort of error did you observe ?
>>>
>>> The warning is triggered as ARM64 has build flag -Wpointer-to-int
>>> -cast
>>> and similar. Here is the build error log
>>>
>>> arch/arm/mach-socfpga/system_manager.c: In function
>>> sysmgr_pinmux_init:
>>>                                                                    
>>>     
>>>           arch/arm/mach-socfpga/system_manager.c:59:18: warning:
>>> cast
>>> from pointer to integer of different size [-Wpointer-to-int-cast]  
>>>     
>>>                           uint32_t regs = (uint32_t)&sysmgr_regs
>>> ->emacio[0];                                                       
>>>     
>>>                                                               ^    
>>>     
>>>                                                                    
>>>     
>>>                                                           In file
>>> included from arch/arm/mach-socfpga/system_manager.c:8:0:          
>>>     
>>>                                                                    
>>>     
>>>       ./arch/arm/include/asm/io.h:78:29: warning: cast to pointer
>>> from
>>> integer of different size [-Wint-to-pointer-cast]                  
>>>     
>>>                     #define __arch_putl(v,a)  (*(volatile unsigned
>>> int
>>> *)(a) = (v))                                                       
>>>     
>>
>> I see ... Except the code below does regs += sizeof(regs); , which in
>> the original case increments the address by 4 , but with your change,
>> the increment would be 16 . So this patch breaks things.
>>
> 
> Relook back, this portion is not being used and hence not being
> validated. Will put #ifdef in place to skip out these code.

Which portion is not used ? I don't understand why this patch is valid,
in fact I think it is wrong.
diff mbox

Patch

diff --git a/arch/arm/mach-socfpga/system_manager.c b/arch/arm/mach-socfpga/system_manager.c
index 75a65f3..89161bd 100644
--- a/arch/arm/mach-socfpga/system_manager.c
+++ b/arch/arm/mach-socfpga/system_manager.c
@@ -56,7 +56,7 @@  static void populate_sysmgr_fpgaintf_module(void)
  */
 void sysmgr_pinmux_init(void)
 {
-	uint32_t regs = (uint32_t)&sysmgr_regs->emacio[0];
+	uint32_t *regs = (uint32_t *)&sysmgr_regs->emacio[0];
 	const u8 *sys_mgr_init_table;
 	unsigned int len;
 	int i;