Skip to contentSkip to conversation

phy: ralink: fix 64-bit build warning

PATCH In review Arnd Bergmann 5 participants 7 messages Aug 23, 2017 – Aug 24, 2017 Generic PHY framework

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 phy: ralink: fix 64-bit build warning

Casting between an 'int' and a pointer causes a warning on 64-bit architectures in compile-testing this driver:

drivers/phy/ralink/phy-ralink-usb.c: In function 'ralink_usb_phy_probe':
drivers/phy/ralink/phy-ralink-usb.c:195:13: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]

This changes the code to cast to uintptr_t instead. This is guaranteed to do what we want on all architectures and avoids the warning.

Fixes 2411a736ff09 ("phy: ralink-usb: add driver for Mediatek/Ralink")
---
 drivers/phy/ralink/phy-ralink-usb.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/phy/ralink/phy-ralink-usb.c +7 -7
index d19088c0ce5c..4fea31f8ac1c 100644
@@ -160,18 +160,18 @@ static struct phy_ops ralink_usb_phy_ops = {
 static const struct of_device_id ralink_usb_phy_of_match[] = {
 	{
 		.compatible = "ralink,rt3352-usbphy",
-		.data = (void *) (RT_CLKCFG1_UPHY1_CLK_EN |
-				  RT_CLKCFG1_UPHY0_CLK_EN)
+		.data = (void *)(uintptr_t)(RT_CLKCFG1_UPHY1_CLK_EN |
+					    RT_CLKCFG1_UPHY0_CLK_EN)
 	},
 	{
 		.compatible = "mediatek,mt7620-usbphy",
-		.data = (void *) (MT7620_CLKCFG1_UPHY1_CLK_EN |
-				  MT7620_CLKCFG1_UPHY0_CLK_EN)
+		.data = (void *)(uintptr_t)(MT7620_CLKCFG1_UPHY1_CLK_EN |
+					    MT7620_CLKCFG1_UPHY0_CLK_EN)
 	},
 	{
 		.compatible = "mediatek,mt7628-usbphy",
-		.data = (void *) (MT7620_CLKCFG1_UPHY1_CLK_EN |
-				  MT7620_CLKCFG1_UPHY0_CLK_EN) },
+		.data = (void *)(uintptr_t)(MT7620_CLKCFG1_UPHY1_CLK_EN |
+					    MT7620_CLKCFG1_UPHY0_CLK_EN) },
 	{ },
 };
 MODULE_DEVICE_TABLE(of, ralink_usb_phy_of_match);
@@ -192,7 +192,7 @@ static int ralink_usb_phy_probe(struct platform_device *pdev)
 	if (!phy)
 		return -ENOMEM;
 
-	phy->clk = (u32) match->data;
+	phy->clk = (uintptr_t)match->data;
 	phy->base = NULL;
 
 	phy->sysctl = syscon_regmap_lookup_by_phandle(dev->of_node, "ralink,sysctl");
Signature · 1 line
2.9.0
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Arnd Bergmann

Casting between an 'int' and a pointer causes a warning on 64-bit architectures in compile-testing this driver:

drivers/phy/ralink/phy-ralink-usb.c: In function 'ralink_usb_phy_probe':
drivers/phy/ralink/phy-ralink-usb.c:195:13: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]

Quoted 6 lines

This changes the code to cast to uintptr_t instead. This is guaranteed to do what we want on all architectures and avoids the warning.

Fixes 2411a736ff09 ("phy: ralink-usb: add driver for Mediatek/Ralink")

gregkh: can you fold this into the commit sitting inside usb-next ?

Quoted 42 lines
---
  drivers/phy/ralink/phy-ralink-usb.c | 14 +++++++-------
  1 file changed, 7 insertions(+), 7 deletions(-)
drivers/phy/ralink/phy-ralink-usb.c +7 -7
index d19088c0ce5c..4fea31f8ac1c 100644
@@ -160,18 +160,18 @@ static struct phy_ops ralink_usb_phy_ops = {
  static const struct of_device_id ralink_usb_phy_of_match[] = {
  	{
  		.compatible = "ralink,rt3352-usbphy",
-		.data = (void *) (RT_CLKCFG1_UPHY1_CLK_EN |
-				  RT_CLKCFG1_UPHY0_CLK_EN)
+		.data = (void *)(uintptr_t)(RT_CLKCFG1_UPHY1_CLK_EN |
+					    RT_CLKCFG1_UPHY0_CLK_EN)
  	},
  	{
  		.compatible = "mediatek,mt7620-usbphy",
-		.data = (void *) (MT7620_CLKCFG1_UPHY1_CLK_EN |
-				  MT7620_CLKCFG1_UPHY0_CLK_EN)
+		.data = (void *)(uintptr_t)(MT7620_CLKCFG1_UPHY1_CLK_EN |
+					    MT7620_CLKCFG1_UPHY0_CLK_EN)
  	},
  	{
  		.compatible = "mediatek,mt7628-usbphy",
-		.data = (void *) (MT7620_CLKCFG1_UPHY1_CLK_EN |
-				  MT7620_CLKCFG1_UPHY0_CLK_EN) },
+		.data = (void *)(uintptr_t)(MT7620_CLKCFG1_UPHY1_CLK_EN |
+					    MT7620_CLKCFG1_UPHY0_CLK_EN) },
  	{ },
  };
  MODULE_DEVICE_TABLE(of, ralink_usb_phy_of_match);
@@ -192,7 +192,7 @@ static int ralink_usb_phy_probe(struct platform_device *pdev)
  	if (!phy)
  		return -ENOMEM;
 
-	phy->clk = (u32) match->data;
+	phy->clk = (uintptr_t)match->data;
  	phy->base = NULL;
 
  	phy->sysctl = syscon_regmap_lookup_by_phandle(dev->of_node, "ralink,sysctl");
Acked-by on v1 1/1
#2 lore raw
In reply to Arnd Bergmann
Quoted 6 lines · Arnd Bergmann

Casting between an 'int' and a pointer causes a warning on 64-bit architectures in compile-testing this driver:

drivers/phy/ralink/phy-ralink-usb.c: In function 'ralink_usb_phy_probe':
drivers/phy/ralink/phy-ralink-usb.c:195:13: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]

Quoted 6 lines

This changes the code to cast to uintptr_t instead. This is guaranteed to do what we want on all architectures and avoids the warning.

Fixes 2411a736ff09 ("phy: ralink-usb: add driver for Mediatek/Ralink")
Quoted 43 lines
---
 drivers/phy/ralink/phy-ralink-usb.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/phy/ralink/phy-ralink-usb.c +7 -7
index d19088c0ce5c..4fea31f8ac1c 100644
@@ -160,18 +160,18 @@ static struct phy_ops ralink_usb_phy_ops = {
 static const struct of_device_id ralink_usb_phy_of_match[] = {
 	{
 		.compatible = "ralink,rt3352-usbphy",
-		.data = (void *) (RT_CLKCFG1_UPHY1_CLK_EN |
-				  RT_CLKCFG1_UPHY0_CLK_EN)
+		.data = (void *)(uintptr_t)(RT_CLKCFG1_UPHY1_CLK_EN |
+					    RT_CLKCFG1_UPHY0_CLK_EN)
 	},
 	{
 		.compatible = "mediatek,mt7620-usbphy",
-		.data = (void *) (MT7620_CLKCFG1_UPHY1_CLK_EN |
-				  MT7620_CLKCFG1_UPHY0_CLK_EN)
+		.data = (void *)(uintptr_t)(MT7620_CLKCFG1_UPHY1_CLK_EN |
+					    MT7620_CLKCFG1_UPHY0_CLK_EN)
 	},
 	{
 		.compatible = "mediatek,mt7628-usbphy",
-		.data = (void *) (MT7620_CLKCFG1_UPHY1_CLK_EN |
-				  MT7620_CLKCFG1_UPHY0_CLK_EN) },
+		.data = (void *)(uintptr_t)(MT7620_CLKCFG1_UPHY1_CLK_EN |
+					    MT7620_CLKCFG1_UPHY0_CLK_EN) },
 	{ },
 };
 MODULE_DEVICE_TABLE(of, ralink_usb_phy_of_match);
@@ -192,7 +192,7 @@ static int ralink_usb_phy_probe(struct platform_device *pdev)
 	if (!phy)
 		return -ENOMEM;
 
-	phy->clk = (u32) match->data;
+	phy->clk = (uintptr_t)match->data;
 	phy->base = NULL;
 
 	phy->sysctl = syscon_regmap_lookup_by_phandle(dev->of_node, "ralink,sysctl");
#3 lore raw
In reply to Arnd Bergmann

Hi Arnd,

Quoted 10 lines · Arnd Bergmann

Casting between an 'int' and a pointer causes a warning on 64-bit architectures in compile-testing this driver:

drivers/phy/ralink/phy-ralink-usb.c: In function 'ralink_usb_phy_probe':
drivers/phy/ralink/phy-ralink-usb.c:195:13: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]

This changes the code to cast to uintptr_t instead. This is guaranteed to do what we want on all architectures and avoids the warning.

Quoted 5 lines
Fixes 2411a736ff09 ("phy: ralink-usb: add driver for Mediatek/Ralink")
---
  drivers/phy/ralink/phy-ralink-usb.c | 14 +++++++-------
  1 file changed, 7 insertions(+), 7 deletions(-)

[...]

Thanks for fixing this - it was on my TODO list.

Tested-by Harvey Hunt <[email protected]>
Reviewed-by Harvey Hunt <[email protected]>

Thanks,

Harvey

#4 lore raw
In reply to Arnd Bergmann

Greg,

Quoted 6 lines · Arnd Bergmann

Casting between an 'int' and a pointer causes a warning on 64-bit architectures in compile-testing this driver:

drivers/phy/ralink/phy-ralink-usb.c: In function 'ralink_usb_phy_probe':
drivers/phy/ralink/phy-ralink-usb.c:195:13: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]

Quoted 6 lines

This changes the code to cast to uintptr_t instead. This is guaranteed to do what we want on all architectures and avoids the warning.

Fixes 2411a736ff09 ("phy: ralink-usb: add driver for Mediatek/Ralink")

Can you pick this patch to fix the compiler warning.

Thanks
Kishon

Quoted 43 lines
---
 drivers/phy/ralink/phy-ralink-usb.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/phy/ralink/phy-ralink-usb.c +7 -7
index d19088c0ce5c..4fea31f8ac1c 100644
@@ -160,18 +160,18 @@ static struct phy_ops ralink_usb_phy_ops = {
 static const struct of_device_id ralink_usb_phy_of_match[] = {
 	{
 		.compatible = "ralink,rt3352-usbphy",
-		.data = (void *) (RT_CLKCFG1_UPHY1_CLK_EN |
-				  RT_CLKCFG1_UPHY0_CLK_EN)
+		.data = (void *)(uintptr_t)(RT_CLKCFG1_UPHY1_CLK_EN |
+					    RT_CLKCFG1_UPHY0_CLK_EN)
 	},
 	{
 		.compatible = "mediatek,mt7620-usbphy",
-		.data = (void *) (MT7620_CLKCFG1_UPHY1_CLK_EN |
-				  MT7620_CLKCFG1_UPHY0_CLK_EN)
+		.data = (void *)(uintptr_t)(MT7620_CLKCFG1_UPHY1_CLK_EN |
+					    MT7620_CLKCFG1_UPHY0_CLK_EN)
 	},
 	{
 		.compatible = "mediatek,mt7628-usbphy",
-		.data = (void *) (MT7620_CLKCFG1_UPHY1_CLK_EN |
-				  MT7620_CLKCFG1_UPHY0_CLK_EN) },
+		.data = (void *)(uintptr_t)(MT7620_CLKCFG1_UPHY1_CLK_EN |
+					    MT7620_CLKCFG1_UPHY0_CLK_EN) },
 	{ },
 };
 MODULE_DEVICE_TABLE(of, ralink_usb_phy_of_match);
@@ -192,7 +192,7 @@ static int ralink_usb_phy_probe(struct platform_device *pdev)
 	if (!phy)
 		return -ENOMEM;
 
-	phy->clk = (u32) match->data;
+	phy->clk = (uintptr_t)match->data;
 	phy->base = NULL;
 
 	phy->sysctl = syscon_regmap_lookup_by_phandle(dev->of_node, "ralink,sysctl");
#5 lore raw
Quoted 9 lines · Kishon Vijay Abraham I

Greg,

Quoted 6 lines · Arnd Bergmann

Casting between an 'int' and a pointer causes a warning on 64-bit architectures in compile-testing this driver:

drivers/phy/ralink/phy-ralink-usb.c: In function 'ralink_usb_phy_probe':
drivers/phy/ralink/phy-ralink-usb.c:195:13: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]

Quoted 8 lines
Quoted 6 lines

This changes the code to cast to uintptr_t instead. This is guaranteed to do what we want on all architectures and avoids the warning.

Fixes 2411a736ff09 ("phy: ralink-usb: add driver for Mediatek/Ralink")

Can you pick this patch to fix the compiler warning.

Can you resend it to me in a format that I can apply it in?

thanks,

greg k-h

#6 lore raw

Greg,

Quoted 14 lines · Greg Kroah-Hartman
Quoted 13 lines · Kishon Vijay Abraham I

Greg,

Quoted 10 lines · Arnd Bergmann

Casting between an 'int' and a pointer causes a warning on 64-bit architectures in compile-testing this driver:

drivers/phy/ralink/phy-ralink-usb.c: In function 'ralink_usb_phy_probe':
drivers/phy/ralink/phy-ralink-usb.c:195:13: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]

This changes the code to cast to uintptr_t instead. This is guaranteed to do what we want on all architectures and avoids the warning.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Fixes 2411a736ff09 ("phy: ralink-usb: add driver for Mediatek/Ralink")

Can you pick this patch to fix the compiler warning.

Can you resend it to me in a format that I can apply it in?

sent them now.

Thanks
Kishon