* [PATCH v2] lib: utils/gpio: Fix RV32 compile error for designware GPIO driver
@ 2023-07-12 4:03 Anup Patel
2023-07-12 5:54 ` Anup Patel
2023-07-12 9:19 ` Ben Dooks
0 siblings, 2 replies; 4+ messages in thread
From: Anup Patel @ 2023-07-12 4:03 UTC (permalink / raw)
To: opensbi
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")
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Reviewed-by: Xiang W <wxjstz@126.com>
---
Changes since v1:
- Use uintptr_t in-place of ulong data type.
---
lib/utils/gpio/fdt_gpio_designware.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/utils/gpio/fdt_gpio_designware.c b/lib/utils/gpio/fdt_gpio_designware.c
index 6223d7e..018e2d5 100644
--- a/lib/utils/gpio/fdt_gpio_designware.c
+++ b/lib/utils/gpio/fdt_gpio_designware.c
@@ -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 *)(uintptr_t)addr + (bank * 0xc);
+ chip->ext = (void *)(uintptr_t)addr + (bank * 4) + 0x50;
chip->chip.driver = &fdt_gpio_designware;
chip->chip.id = phandle;
chip->chip.ngpio = nr_pins;
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH v2] lib: utils/gpio: Fix RV32 compile error for designware GPIO driver
2023-07-12 4:03 [PATCH v2] lib: utils/gpio: Fix RV32 compile error for designware GPIO driver Anup Patel
@ 2023-07-12 5:54 ` Anup Patel
2023-07-12 9:19 ` Ben Dooks
1 sibling, 0 replies; 4+ messages in thread
From: Anup Patel @ 2023-07-12 5:54 UTC (permalink / raw)
To: opensbi
On Wed, Jul 12, 2023 at 9:33?AM Anup Patel <apatel@ventanamicro.com> wrote:
>
> 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")
> Signed-off-by: Anup Patel <apatel@ventanamicro.com>
> Reviewed-by: Xiang W <wxjstz@126.com>
Applied this patch to the riscv/opensbi repo.
Regards,
Anup
> ---
> Changes since v1:
> - Use uintptr_t in-place of ulong data type.
> ---
> lib/utils/gpio/fdt_gpio_designware.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/lib/utils/gpio/fdt_gpio_designware.c b/lib/utils/gpio/fdt_gpio_designware.c
> index 6223d7e..018e2d5 100644
> --- a/lib/utils/gpio/fdt_gpio_designware.c
> +++ b/lib/utils/gpio/fdt_gpio_designware.c
> @@ -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 *)(uintptr_t)addr + (bank * 0xc);
> + chip->ext = (void *)(uintptr_t)addr + (bank * 4) + 0x50;
> chip->chip.driver = &fdt_gpio_designware;
> chip->chip.id = phandle;
> chip->chip.ngpio = nr_pins;
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH v2] lib: utils/gpio: Fix RV32 compile error for designware GPIO driver
2023-07-12 4:03 [PATCH v2] lib: utils/gpio: Fix RV32 compile error for designware GPIO driver Anup Patel
2023-07-12 5:54 ` Anup Patel
@ 2023-07-12 9:19 ` Ben Dooks
2023-07-13 9:29 ` Anup Patel
1 sibling, 1 reply; 4+ messages in thread
From: Ben Dooks @ 2023-07-12 9:19 UTC (permalink / raw)
To: opensbi
On 12/07/2023 05:03, Anup Patel wrote:
> 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")
> Signed-off-by: Anup Patel <apatel@ventanamicro.com>
> Reviewed-by: Xiang W <wxjstz@126.com>
> ---
> Changes since v1:
> - Use uintptr_t in-place of ulong data type.
> ---
> lib/utils/gpio/fdt_gpio_designware.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/lib/utils/gpio/fdt_gpio_designware.c b/lib/utils/gpio/fdt_gpio_designware.c
> index 6223d7e..018e2d5 100644
> --- a/lib/utils/gpio/fdt_gpio_designware.c
> +++ b/lib/utils/gpio/fdt_gpio_designware.c
> @@ -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 *)(uintptr_t)addr + (bank * 0xc);
> + chip->ext = (void *)(uintptr_t)addr + (bank * 4) + 0x50;
would a macro to do this, maybe called fdt_addr_to_ptr(addr) ?
> chip->chip.driver = &fdt_gpio_designware;
> chip->chip.id = phandle;
> chip->chip.ngpio = nr_pins;
--
Ben Dooks http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
https://www.codethink.co.uk/privacy.html
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH v2] lib: utils/gpio: Fix RV32 compile error for designware GPIO driver
2023-07-12 9:19 ` Ben Dooks
@ 2023-07-13 9:29 ` Anup Patel
0 siblings, 0 replies; 4+ messages in thread
From: Anup Patel @ 2023-07-13 9:29 UTC (permalink / raw)
To: opensbi
On Wed, Jul 12, 2023 at 2:49?PM Ben Dooks <ben.dooks@codethink.co.uk> wrote:
>
> On 12/07/2023 05:03, Anup Patel wrote:
> > 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")
> > Signed-off-by: Anup Patel <apatel@ventanamicro.com>
> > Reviewed-by: Xiang W <wxjstz@126.com>
> > ---
> > Changes since v1:
> > - Use uintptr_t in-place of ulong data type.
> > ---
> > lib/utils/gpio/fdt_gpio_designware.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/lib/utils/gpio/fdt_gpio_designware.c b/lib/utils/gpio/fdt_gpio_designware.c
> > index 6223d7e..018e2d5 100644
> > --- a/lib/utils/gpio/fdt_gpio_designware.c
> > +++ b/lib/utils/gpio/fdt_gpio_designware.c
> > @@ -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 *)(uintptr_t)addr + (bank * 0xc);
> > + chip->ext = (void *)(uintptr_t)addr + (bank * 4) + 0x50;
>
> would a macro to do this, maybe called fdt_addr_to_ptr(addr) ?
Yes, some generic addr_to_ptr() macro would be useful to avoid
compile error in future. It need not be FDT specific.
>
> > chip->chip.driver = &fdt_gpio_designware;
> > chip->chip.id = phandle;
> > chip->chip.ngpio = nr_pins;
>
> --
> Ben Dooks http://www.codethink.co.uk/
> Senior Engineer Codethink - Providing Genius
>
> https://www.codethink.co.uk/privacy.html
>
Regards,
Anup
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-07-13 9:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-12 4:03 [PATCH v2] lib: utils/gpio: Fix RV32 compile error for designware GPIO driver Anup Patel
2023-07-12 5:54 ` Anup Patel
2023-07-12 9:19 ` Ben Dooks
2023-07-13 9:29 ` Anup Patel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox