[v2] pinctrl: bcm: ns: Use uintptr_t for data

Message ID 20181011075003.8976-1-linus.walleij@linaro.org
State New
Headers show
Series
  • [v2] pinctrl: bcm: ns: Use uintptr_t for data
Related show

Commit Message

Linus Walleij Oct. 11, 2018, 7:50 a.m.
Fix up a compiler error on 64bit architectures where pointers
and integers differ in size.

Cc: Rafał Miłecki <rafal@milecki.pl>
Suggested-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

---
ChangeLog v1->v2:
- Make a proper change including cast type.
---
 drivers/pinctrl/bcm/pinctrl-ns.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

-- 
2.17.1

Comments

Rafał Miłecki Oct. 11, 2018, 11:11 a.m. | #1
On 2018-10-11 09:50, Linus Walleij wrote:
> Fix up a compiler error on 64bit architectures where pointers

> and integers differ in size.


I think you could just cast of_id->data to the uintptr_t and leave the
rest of the code as is.

I think assigning uintptr_t to unsigned int should be safe here and it's
also how e.g. pinctrl-mcp23s08.c handles it.

It feels more natural to keep using
unsigned int chipset_flag
for storing a flag.


> Cc: Rafał Miłecki <rafal@milecki.pl>

> Suggested-by: Arnd Bergmann <arnd@arndb.de>

> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

> ---

> ChangeLog v1->v2:

> - Make a proper change including cast type.

> ---

>  drivers/pinctrl/bcm/pinctrl-ns.c | 6 +++---

>  1 file changed, 3 insertions(+), 3 deletions(-)

> 

> diff --git a/drivers/pinctrl/bcm/pinctrl-ns.c 

> b/drivers/pinctrl/bcm/pinctrl-ns.c

> index aedbb2813c50..925823a1e33f 100644

> --- a/drivers/pinctrl/bcm/pinctrl-ns.c

> +++ b/drivers/pinctrl/bcm/pinctrl-ns.c

> @@ -20,7 +20,7 @@

> 

>  struct ns_pinctrl {

>  	struct device *dev;

> -	unsigned int chipset_flag;

> +	uintptr_t chipset_flag;

>  	struct pinctrl_dev *pctldev;

>  	void __iomem *base;

> 

> @@ -285,7 +285,7 @@ static int ns_pinctrl_probe(struct platform_device 

> *pdev)

>  	of_id = of_match_device(ns_pinctrl_of_match_table, dev);

>  	if (!of_id)

>  		return -EINVAL;

> -	ns_pinctrl->chipset_flag = (unsigned int)of_id->data;

> +	ns_pinctrl->chipset_flag = (uintptr_t)of_id->data;

> 

>  	res = platform_get_resource_byname(pdev, IORESOURCE_MEM,

>  					   "cru_gpio_control");

> @@ -307,7 +307,7 @@ static int ns_pinctrl_probe(struct platform_device 

> *pdev)

>  	for (i = 0, pin = (struct pinctrl_pin_desc *)&pctldesc->pins[0];

>  	     i < ARRAY_SIZE(ns_pinctrl_pins); i++) {

>  		const struct pinctrl_pin_desc *src = &ns_pinctrl_pins[i];

> -		unsigned int chipsets = (unsigned int)src->drv_data;

> +		uintptr_t chipsets = (uintptr_t)src->drv_data;

> 

>  		if (chipsets & ns_pinctrl->chipset_flag) {

>  			memcpy(pin++, src, sizeof(*src));

Patch

diff --git a/drivers/pinctrl/bcm/pinctrl-ns.c b/drivers/pinctrl/bcm/pinctrl-ns.c
index aedbb2813c50..925823a1e33f 100644
--- a/drivers/pinctrl/bcm/pinctrl-ns.c
+++ b/drivers/pinctrl/bcm/pinctrl-ns.c
@@ -20,7 +20,7 @@ 
 
 struct ns_pinctrl {
 	struct device *dev;
-	unsigned int chipset_flag;
+	uintptr_t chipset_flag;
 	struct pinctrl_dev *pctldev;
 	void __iomem *base;
 
@@ -285,7 +285,7 @@  static int ns_pinctrl_probe(struct platform_device *pdev)
 	of_id = of_match_device(ns_pinctrl_of_match_table, dev);
 	if (!of_id)
 		return -EINVAL;
-	ns_pinctrl->chipset_flag = (unsigned int)of_id->data;
+	ns_pinctrl->chipset_flag = (uintptr_t)of_id->data;
 
 	res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
 					   "cru_gpio_control");
@@ -307,7 +307,7 @@  static int ns_pinctrl_probe(struct platform_device *pdev)
 	for (i = 0, pin = (struct pinctrl_pin_desc *)&pctldesc->pins[0];
 	     i < ARRAY_SIZE(ns_pinctrl_pins); i++) {
 		const struct pinctrl_pin_desc *src = &ns_pinctrl_pins[i];
-		unsigned int chipsets = (unsigned int)src->drv_data;
+		uintptr_t chipsets = (uintptr_t)src->drv_data;
 
 		if (chipsets & ns_pinctrl->chipset_flag) {
 			memcpy(pin++, src, sizeof(*src));