aboutsummaryrefslogtreecommitdiff
path: root/drivers/misc/swap_case.c
diff options
context:
space:
mode:
authorSimon Glass2021-07-18 14:14:23 -0600
committerTom Rini2021-07-28 19:30:22 -0400
commit05a7cabf5b86fb283c887309746d98e416edcc64 (patch)
treea4e411a7fb46e8bb571006e8d50bac6912acea5b /drivers/misc/swap_case.c
parentbbcacdf4cd23f2e5deb9ef916096c956c955243d (diff)
pci: swap_case: Allow compilation on 32-bit machines
At present this driver assumes that ulong is 64-bits long. On 32-bit machines it is not. Use the 64-bit code only on 64-bit machines. This makes things work correctly on 32-bit machines. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/misc/swap_case.c')
-rw-r--r--drivers/misc/swap_case.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/drivers/misc/swap_case.c b/drivers/misc/swap_case.c
index 3cbc8f37ec5..7093ad1cd4f 100644
--- a/drivers/misc/swap_case.c
+++ b/drivers/misc/swap_case.c
@@ -302,7 +302,6 @@ static int sandbox_swap_case_write_io(struct udevice *dev, unsigned int addr,
}
static int pci_ea_bar2_magic = PCI_EA_BAR2_MAGIC;
-static int pci_ea_bar4_magic = PCI_EA_BAR4_MAGIC;
static int sandbox_swap_case_map_physmem(struct udevice *dev,
phys_addr_t addr, unsigned long *lenp, void **ptrp)
@@ -332,12 +331,22 @@ static int sandbox_swap_case_map_physmem(struct udevice *dev,
*ptrp = &pci_ea_bar2_magic;
*lenp = PCI_CAP_EA_SIZE_LO;
break;
+#ifdef CONFIG_HOST_64BIT
+ /*
+ * This cannot be work on a 32-bit machine since *lenp is ulong
+ * which is 32-bits, but it needs to have a 64-bit value
+ * assigned
+ */
case (phys_addr_t)((PCI_CAP_EA_BASE_HI4 << 32) |
- PCI_CAP_EA_BASE_LO4):
+ PCI_CAP_EA_BASE_LO4): {
+ static int pci_ea_bar4_magic = PCI_EA_BAR4_MAGIC;
+
*ptrp = &pci_ea_bar4_magic;
*lenp = (PCI_CAP_EA_SIZE_HI << 32) |
PCI_CAP_EA_SIZE_LO;
break;
+ }
+#endif
default:
return -ENOENT;
}