[PATCH v3] staging: gpib: Fix i386 build issue

From: Dave Penkler
Date: Tue Dec 03 2024 - 04:12:43 EST


These 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() / pnp_port_start() to
initialize iobase.

Reported_by: Guenter Roeck <linux@xxxxxxxxxxxx>
Link: https://lore.kernel.org/all/f10e976e-7a04-4454-b38d-39cd18f142da@xxxxxxxxxxxx/
Fixes: e9dc69956d4d ("staging: gpib: Add Computer Boards GPIB driver")
Fixes: e1339245eba3 ("staging: gpib: Add Computer Equipment Corporation GPIB driver")
Fixes: bb1bd92fa0f2 ("staging: gpib: Add ines GPIB driver")
Fixes: 0cd5b05551e0 ("staging: gpib: Add TNT4882 chip based GPIB driver")

Signed-off-by: Dave Penkler <dpenkler@xxxxxxxxx>
---
v1 -> v2 changed pci_resource_start to pci_resource_len for second parameter of ioremap
v2 -> v3 add changes for cb7210 and tnt4882 drivers

drivers/staging/gpib/cb7210/cb7210.c | 6 ++++--
drivers/staging/gpib/cec/cec_gpib.c | 3 ++-
drivers/staging/gpib/ines/ines_gpib.c | 4 ++--
drivers/staging/gpib/tnt4882/tnt4882_gpib.c | 12 +++++++-----
4 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/gpib/cb7210/cb7210.c b/drivers/staging/gpib/cb7210/cb7210.c
index 63df7f3eb3f3..356a3404e128 100644
--- a/drivers/staging/gpib/cb7210/cb7210.c
+++ b/drivers/staging/gpib/cb7210/cb7210.c
@@ -971,11 +971,13 @@ int cb_pci_attach(gpib_board_t *board, const gpib_board_config_t *config)
switch (cb_priv->pci_chip) {
case PCI_CHIP_AMCC_S5933:
cb_priv->amcc_iobase = pci_resource_start(cb_priv->pci_device, 0);
- nec_priv->iobase = (void *)(pci_resource_start(cb_priv->pci_device, 1));
+ nec_priv->iobase = ioremap(pci_resource_start(cb_priv->pci_device, 1),
+ pci_resource_len(cb_priv->pci_device, 1));
cb_priv->fifo_iobase = pci_resource_start(cb_priv->pci_device, 2);
break;
case PCI_CHIP_QUANCOM:
- nec_priv->iobase = (void *)(pci_resource_start(cb_priv->pci_device, 0));
+ nec_priv->iobase = ioremap(pci_resource_start(cb_priv->pci_device, 0),
+ pci_resource_len(cb_priv->pci_device, 0));
cb_priv->fifo_iobase = (unsigned long)nec_priv->iobase;
break;
default:
diff --git a/drivers/staging/gpib/cec/cec_gpib.c b/drivers/staging/gpib/cec/cec_gpib.c
index 3dc933deb401..26c0cce1e917 100644
--- a/drivers/staging/gpib/cec/cec_gpib.c
+++ b/drivers/staging/gpib/cec/cec_gpib.c
@@ -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;
diff --git a/drivers/staging/gpib/ines/ines_gpib.c b/drivers/staging/gpib/ines/ines_gpib.c
index 9d8387c3bf01..b5f8ea57fd9d 100644
--- a/drivers/staging/gpib/ines/ines_gpib.c
+++ b/drivers/staging/gpib/ines/ines_gpib.c
@@ -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;
diff --git a/drivers/staging/gpib/tnt4882/tnt4882_gpib.c b/drivers/staging/gpib/tnt4882/tnt4882_gpib.c
index e49a952fa0d8..1e41a48e6fca 100644
--- a/drivers/staging/gpib/tnt4882/tnt4882_gpib.c
+++ b/drivers/staging/gpib/tnt4882/tnt4882_gpib.c
@@ -1400,7 +1400,8 @@ static int ni_isa_attach_common(gpib_board_t *board, const gpib_board_config_t *
struct tnt4882_priv *tnt_priv;
struct nec7210_priv *nec_priv;
int isr_flags = 0;
- void *iobase;
+ resource_size_t iobase;
+ unsigned long ibbase;
int irq;

board->status = 0;
@@ -1427,18 +1428,19 @@ static int ni_isa_attach_common(gpib_board_t *board, const gpib_board_config_t *
if (retval < 0)
return retval;
tnt_priv->pnp_dev = dev;
- iobase = (void *)(pnp_port_start(dev, 0));
+ iobase = pnp_port_start(dev, 0);
irq = pnp_irq(dev, 0);
} else {
- iobase = config->ibbase;
+ ibbase = (unsigned long)config->ibbase;
+ iobase = ibbase;
irq = config->ibirq;
}
// allocate ioports
- if (!request_region((unsigned long)(iobase), atgpib_iosize, "atgpib")) {
+ if (!request_region(iobase, atgpib_iosize, "atgpib")) {
pr_err("tnt4882: failed to allocate ioports\n");
return -1;
}
- nec_priv->iobase = iobase;
+ nec_priv->iobase = ioremap(iobase, pnp_port_len(tnt_priv->pnp_dev, 0));

// get irq
if (request_irq(irq, tnt4882_interrupt, isr_flags, "atgpib", board)) {
--
2.46.2