diff mbox series

[U-Boot] usb: dwc2-otg: make regs_phy (in platdata) a uintptr_t

Message ID 1544056367-9255-1-git-send-email-philipp.tomsich@theobroma-systems.com
State Accepted
Commit 63162724e25778962672d5c0a85ed5af0aa1c78e
Delegated to: Lukasz Majewski
Headers show
Series [U-Boot] usb: dwc2-otg: make regs_phy (in platdata) a uintptr_t | expand

Commit Message

Philipp Tomsich Dec. 6, 2018, 12:32 a.m. UTC
The regs_phy field of the platform data structure for dwc2-otg is
today declared an unsigned int, but will eventually be cast into a
void* for a writel operation.  This triggers errors on modern GCC
versions.

E.g. we get the following error with GCC 6.3:
  drivers/usb/phy/rockchip_usb2_phy.c: In function 'property_enable':
  arch/arm/include/asm/io.h:49:29: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
   #define __arch_putl(v,a)  (*(volatile unsigned int *)(a) = (v))
                               ^
  arch/arm/include/asm/io.h:117:48: note: in expansion of macro '__arch_putl'
   #define writel(v,c) ({ u32 __v = v; __iowmb(); __arch_putl(__v,c); __v; })
                                                  ^~~~~~~~~~~
  drivers/usb/phy/rockchip_usb2_phy.c:61:2: note: in expansion of macro 'writel'
    writel(val, pdata->regs_phy + reg->offset);
    ^~~~~~

This commit changes regs_phy to be a uintptr_t to ensure that it is
large enough to hold any valid pointer (and fix the associated
warning).

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
---

 include/usb/dwc2_udc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Philipp Tomsich Dec. 6, 2018, 12:35 a.m. UTC | #1
Marek,

I need the below change before I can apply an overdue series to the rockchip tree.
Please review and let me know if it’s ok for you that I pick this one through the 
rockchip tree, so I can put the Rock960 series on top…

Thanks,
Philipp.

> On 06.12.2018, at 01:32, Philipp Tomsich <philipp.tomsich@theobroma-systems.com> wrote:
> 
> The regs_phy field of the platform data structure for dwc2-otg is
> today declared an unsigned int, but will eventually be cast into a
> void* for a writel operation.  This triggers errors on modern GCC
> versions.
> 
> E.g. we get the following error with GCC 6.3:
>  drivers/usb/phy/rockchip_usb2_phy.c: In function 'property_enable':
>  arch/arm/include/asm/io.h:49:29: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
>   #define __arch_putl(v,a)  (*(volatile unsigned int *)(a) = (v))
>                               ^
>  arch/arm/include/asm/io.h:117:48: note: in expansion of macro '__arch_putl'
>   #define writel(v,c) ({ u32 __v = v; __iowmb(); __arch_putl(__v,c); __v; })
>                                                  ^~~~~~~~~~~
>  drivers/usb/phy/rockchip_usb2_phy.c:61:2: note: in expansion of macro 'writel'
>    writel(val, pdata->regs_phy + reg->offset);
>    ^~~~~~
> 
> This commit changes regs_phy to be a uintptr_t to ensure that it is
> large enough to hold any valid pointer (and fix the associated
> warning).
> 
> Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
> ---
> 
> include/usb/dwc2_udc.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/usb/dwc2_udc.h b/include/usb/dwc2_udc.h
> index 62e3236..4068de0 100644
> --- a/include/usb/dwc2_udc.h
> +++ b/include/usb/dwc2_udc.h
> @@ -14,7 +14,7 @@ struct dwc2_plat_otg_data {
> 	void		*priv;
> 	int		phy_of_node;
> 	int		(*phy_control)(int on);
> -	unsigned int	regs_phy;
> +	uintptr_t	regs_phy;
> 	uintptr_t	regs_otg;
> 	unsigned int    usb_phy_ctrl;
> 	unsigned int    usb_flags;
> -- 
> 2.1.4
>
Marek Vasut Dec. 6, 2018, 12:48 a.m. UTC | #2
On 12/06/2018 01:32 AM, Philipp Tomsich wrote:
> The regs_phy field of the platform data structure for dwc2-otg is
> today declared an unsigned int, but will eventually be cast into a
> void* for a writel operation.  This triggers errors on modern GCC
> versions.
> 
> E.g. we get the following error with GCC 6.3:
>   drivers/usb/phy/rockchip_usb2_phy.c: In function 'property_enable':
>   arch/arm/include/asm/io.h:49:29: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
>    #define __arch_putl(v,a)  (*(volatile unsigned int *)(a) = (v))
>                                ^
>   arch/arm/include/asm/io.h:117:48: note: in expansion of macro '__arch_putl'
>    #define writel(v,c) ({ u32 __v = v; __iowmb(); __arch_putl(__v,c); __v; })
>                                                   ^~~~~~~~~~~
>   drivers/usb/phy/rockchip_usb2_phy.c:61:2: note: in expansion of macro 'writel'
>     writel(val, pdata->regs_phy + reg->offset);
>     ^~~~~~
> 
> This commit changes regs_phy to be a uintptr_t to ensure that it is
> large enough to hold any valid pointer (and fix the associated
> warning).
> 
> Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>

Oh, ew. Good catch.

Acked-by: Marek Vasut <marex@denx.de>

Apply it alongside the Rock960 series, thanks.

> ---
> 
>  include/usb/dwc2_udc.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/usb/dwc2_udc.h b/include/usb/dwc2_udc.h
> index 62e3236..4068de0 100644
> --- a/include/usb/dwc2_udc.h
> +++ b/include/usb/dwc2_udc.h
> @@ -14,7 +14,7 @@ struct dwc2_plat_otg_data {
>  	void		*priv;
>  	int		phy_of_node;
>  	int		(*phy_control)(int on);
> -	unsigned int	regs_phy;
> +	uintptr_t	regs_phy;
>  	uintptr_t	regs_otg;
>  	unsigned int    usb_phy_ctrl;
>  	unsigned int    usb_flags;
>
Philipp Tomsich Dec. 6, 2018, 3 p.m. UTC | #3
> On 06.12.2018, at 01:48, Marek Vasut <marex@denx.de> wrote:
> 
> On 12/06/2018 01:32 AM, Philipp Tomsich wrote:
>> The regs_phy field of the platform data structure for dwc2-otg is
>> today declared an unsigned int, but will eventually be cast into a
>> void* for a writel operation.  This triggers errors on modern GCC
>> versions.
>> 
>> E.g. we get the following error with GCC 6.3:
>>  drivers/usb/phy/rockchip_usb2_phy.c: In function 'property_enable':
>>  arch/arm/include/asm/io.h:49:29: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
>>   #define __arch_putl(v,a)  (*(volatile unsigned int *)(a) = (v))
>>                               ^
>>  arch/arm/include/asm/io.h:117:48: note: in expansion of macro '__arch_putl'
>>   #define writel(v,c) ({ u32 __v = v; __iowmb(); __arch_putl(__v,c); __v; })
>>                                                  ^~~~~~~~~~~
>>  drivers/usb/phy/rockchip_usb2_phy.c:61:2: note: in expansion of macro 'writel'
>>    writel(val, pdata->regs_phy + reg->offset);
>>    ^~~~~~
>> 
>> This commit changes regs_phy to be a uintptr_t to ensure that it is
>> large enough to hold any valid pointer (and fix the associated
>> warning).
>> 
>> Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
> 
> Oh, ew. Good catch.
> 
> Acked-by: Marek Vasut <marex@denx.de>
> 
> Apply it alongside the 

Applied to u-boot-rockchip/master.
diff mbox series

Patch

diff --git a/include/usb/dwc2_udc.h b/include/usb/dwc2_udc.h
index 62e3236..4068de0 100644
--- a/include/usb/dwc2_udc.h
+++ b/include/usb/dwc2_udc.h
@@ -14,7 +14,7 @@  struct dwc2_plat_otg_data {
 	void		*priv;
 	int		phy_of_node;
 	int		(*phy_control)(int on);
-	unsigned int	regs_phy;
+	uintptr_t	regs_phy;
 	uintptr_t	regs_otg;
 	unsigned int    usb_phy_ctrl;
 	unsigned int    usb_flags;