Skip to contentSkip to conversation

lib: utils/gpio: Fix RV32 compile error for designware GPIO driver

PATCH Superseded Anup Patel 2 participants 2 messages Jul 11, 2023

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Anup Patel

author
#0 lore raw

PATCH 1/1 lib: utils/gpio: Fix RV32 compile error for designware GPIO driver

Currently, we see following compile error in the designeware GPIO driver for RV32 systems:

lib/utils/gpio/fdt_gpio_designware.c:115:20: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
115 | chip->dr = (void *)addr + (bank * 0xc);
| ^
lib/utils/gpio/fdt_gpio_designware.c:116:21: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
116 | chip->ext = (void *)addr + (bank * 4) + 0x50;

We fix the above error using an explicit type-cast to 'unsigned long'.

Fixes 7828eebaaa77 ("gpio/desginware: add Synopsys DesignWare APB GPIO support")
---
 lib/utils/gpio/fdt_gpio_designware.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/utils/gpio/fdt_gpio_designware.c +2 -2
index 6223d7e..603e5a0 100644
@@ -112,8 +112,8 @@ static int dw_gpio_init_bank(void *fdt, int nodeoff, u32 phandle,
 
 	chip = &dw_gpio_chip_array[dw_gpio_chip_count];
 
-	chip->dr = (void *)addr + (bank * 0xc);
-	chip->ext = (void *)addr + (bank * 4) + 0x50;
+	chip->dr = (void *)(ulong)addr + (bank * 0xc);
+	chip->ext = (void *)(ulong)addr + (bank * 4) + 0x50;
 	chip->chip.driver = &fdt_gpio_designware;
 	chip->chip.id = phandle;
 	chip->chip.ngpio = nr_pins;
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/1 lib: utils/gpio: Fix RV32 compile error for designware GPIO driver

? 2023-07-11???? 18:15 +0530?Anup Patel???

Quoted 22 lines

Currently, we see following compile error in the designeware GPIO driver for RV32 systems:

lib/utils/gpio/fdt_gpio_designware.c:115:20: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] ? 115 |???????? chip->dr = (void *)addr + (bank * 0xc);
????? |??????????????????? ^
lib/utils/gpio/fdt_gpio_designware.c:116:21: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] ? 116 |???????? chip->ext = (void *)addr + (bank * 4) + 0x50;

We fix the above error using an explicit type-cast to 'unsigned long'.

Fixes 7828eebaaa77 ("gpio/desginware: add Synopsys DesignWare APB GPIO support")

---
?lib/utils/gpio/fdt_gpio_designware.c | 4 ++--
?1 file changed, 2 insertions(+), 2 deletions(-)

lib/utils/gpio/fdt_gpio_designware.c +0 -0
index 6223d7e..603e5a0 100644
@@ -112,8 +112,8 @@ static int dw_gpio_init_bank(void *fdt, int nodeoff, u32 phandle,
Quoted 7 lines

?
????????chip = &dw_gpio_chip_array[dw_gpio_chip_count]; ?
-???????chip->dr = (void *)addr + (bank * 0xc); -???????chip->ext = (void *)addr + (bank * 4) + 0x50; +???????chip->dr = (void *)(ulong)addr + (bank * 0xc); +???????chip->ext = (void *)(ulong)addr + (bank * 4) + 0x50;

Replacing ulong with uintptr_t would be better.

Otherwise it looks good to me.

Quoted 7 lines

????????chip->chip.driver = &fdt_gpio_designware;
????????chip->chip.id = phandle;
????????chip->chip.ngpio = nr_pins;

Signature · 1 line
2.34.1