Skip to contentSkip to conversation

staging: gpib: Fix i386 build issue

PATCH Superseded Dave Penkler 2 participants 4 messages Dec 2, 2024 – Dec 4, 2024 Staging

v2 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 staging: gpib: Fix i386 build issue

Both drivers cast resource_type_t to void * causing the build to fail.

With CONFIG_X86_PAE enabled the resource_size_t type is a 64bit unsigned int which cannot be cast to a 32 bit pointer.

Use ioremap() instead of pci_resource_start()

Reported_by: Guenter Roeck <[email protected]>

Fixes bb1bd92fa0f2 ("staging: gpib: Add ines GPIB driver")
Fixes e1339245eba3 ("staging: gpib: Add Computer Equipment Corporation GPIB driver")

---
v1 -> v2 changed pci_resource_start to pci_resource_len for second parameter of ioremap

 drivers/staging/gpib/cec/cec_gpib.c   | 3 ++-
 drivers/staging/gpib/ines/ines_gpib.c | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)
drivers/staging/gpib/cec/cec_gpib.c +2 -1
index 3dc933deb401..a1ea4d9e370a 100644
@@ -297,7 +297,8 @@ int cec_pci_attach(gpib_board_t *board, const gpib_board_config_t *config)
 
 	cec_priv->plx_iobase = pci_resource_start(cec_priv->pci_device, 1);
 	pr_info(" plx9050 base address 0x%lx\n", cec_priv->plx_iobase);
-	nec_priv->iobase = (void *)(pci_resource_start(cec_priv->pci_device, 3));
+	nec_priv->iobase = ioremap(pci_resource_start(cec_priv->pci_device, 3),
+				   pci_resource_len(cec_priv->pci_device, 3));
 	pr_info(" nec7210 base address 0x%p\n", nec_priv->iobase);
 
 	isr_flags |= IRQF_SHARED;
drivers/staging/gpib/ines/ines_gpib.c +2 -2
index 9d8387c3bf01..b5f8ea57fd9d 100644
@@ -780,8 +780,8 @@ static int ines_common_pci_attach(gpib_board_t *board, const gpib_board_config_t
 
 	if (pci_request_regions(ines_priv->pci_device, "ines-gpib"))
 		return -1;
-	nec_priv->iobase = (void *)(pci_resource_start(ines_priv->pci_device,
-						       found_id.gpib_region));
+	nec_priv->iobase = ioremap(pci_resource_start(ines_priv->pci_device, found_id.gpib_region),
+				   pci_resource_len(ines_priv->pci_device, found_id.gpib_region));
 
 	ines_priv->pci_chip_type = found_id.pci_chip_type;
 	nec_priv->offset = found_id.io_offset;
Signature · 1 line
2.46.2
#1 lore raw
Quoted 7 lines · Dave Penkler

Both drivers cast resource_type_t to void * causing the build to fail.

With CONFIG_X86_PAE enabled the resource_size_t type is a 64bit unsigned int which cannot be cast to a 32 bit pointer.

Use ioremap() instead of pci_resource_start()

Quoted 9 lines

Reported_by: Guenter Roeck <[email protected]>

Fixes bb1bd92fa0f2 ("staging: gpib: Add ines GPIB driver")
Fixes e1339245eba3 ("staging: gpib: Add Computer Equipment Corporation GPIB driver")

---
v1 -> v2 changed pci_resource_start to pci_resource_len for second parameter of ioremap

Sorry, there are some more.

drivers/staging/gpib/tnt4882/tnt4882_gpib.c: In function ‘ni_isa_attach_common’:
drivers/staging/gpib/tnt4882/tnt4882_gpib.c:1430:26: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]

drivers/staging/gpib/cb7210/cb7210.c: In function 'cb_pci_attach':
drivers/staging/gpib/cb7210/cb7210.c:974:36: error: cast to pointer from integer of different size

Not sure if that really fixes the problem though, since there is other code which maps the void * back to phys_addr_t (or, rather, to unsigned long). It might be better to work around the problem for now by disabling support for platforms where sizeof(phys_addr_t) > sizeof(void *).

Guenter

#2 lore raw
Quoted 22 lines · Guenter Roeck
Quoted 7 lines · Dave Penkler

Both drivers cast resource_type_t to void * causing the build to fail.

With CONFIG_X86_PAE enabled the resource_size_t type is a 64bit unsigned int which cannot be cast to a 32 bit pointer.

Use ioremap() instead of pci_resource_start()

Quoted 9 lines

Reported_by: Guenter Roeck <[email protected]>

Fixes bb1bd92fa0f2 ("staging: gpib: Add ines GPIB driver")
Fixes e1339245eba3 ("staging: gpib: Add Computer Equipment Corporation GPIB driver")

---
v1 -> v2 changed pci_resource_start to pci_resource_len for second parameter of ioremap

Sorry, there are some more.

drivers/staging/gpib/tnt4882/tnt4882_gpib.c: In function ???ni_isa_attach_common???:
drivers/staging/gpib/tnt4882/tnt4882_gpib.c:1430:26: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]

Quoted 7 lines

drivers/staging/gpib/cb7210/cb7210.c: In function 'cb_pci_attach':
drivers/staging/gpib/cb7210/cb7210.c:974:36: error: cast to pointer from integer of different size

Not sure if that really fixes the problem though, since there is other code which maps the void * back to phys_addr_t (or, rather, to unsigned long). It might be better to work around the problem for now by disabling support for platforms where sizeof(phys_addr_t) > sizeof(void *).

I think it is dealt with in v3.
- Dave

#3 lore raw
Quoted 26 lines · Dave Penkler
Quoted 25 lines · Guenter Roeck
Quoted 7 lines · Dave Penkler

Both drivers cast resource_type_t to void * causing the build to fail.

With CONFIG_X86_PAE enabled the resource_size_t type is a 64bit unsigned int which cannot be cast to a 32 bit pointer.

Use ioremap() instead of pci_resource_start()

Quoted 9 lines

Reported_by: Guenter Roeck <[email protected]>

Fixes bb1bd92fa0f2 ("staging: gpib: Add ines GPIB driver")
Fixes e1339245eba3 ("staging: gpib: Add Computer Equipment Corporation GPIB driver")

---
v1 -> v2 changed pci_resource_start to pci_resource_len for second parameter of ioremap

Sorry, there are some more.

drivers/staging/gpib/tnt4882/tnt4882_gpib.c: In function ???ni_isa_attach_common???:
drivers/staging/gpib/tnt4882/tnt4882_gpib.c:1430:26: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]

drivers/staging/gpib/cb7210/cb7210.c: In function 'cb_pci_attach':
drivers/staging/gpib/cb7210/cb7210.c:974:36: error: cast to pointer from integer of different size

Quoted 7 lines
Quoted 4 lines

Not sure if that really fixes the problem though, since there is other code which maps the void * back to phys_addr_t (or, rather, to unsigned long). It might be better to work around the problem for now by disabling support for platforms where sizeof(phys_addr_t) > sizeof(void *).

I think it is dealt with in v3.
- Dave

OK this does not work so I will submit a v4 which makes these drivers depend on !X86_PAE
-Dave