All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: U-Boot Mailing List <u-boot@lists.denx.de>
Cc: Tom Rini <trini@konsulko.com>,
	Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Simon Glass <sjg@chromium.org>
Subject: [PATCH v2 2/5] pci: swap_case: Allow compilation on 32-bit machines
Date: Sun, 18 Jul 2021 14:14:23 -0600	[thread overview]
Message-ID: <20210718201426.759240-3-sjg@chromium.org> (raw)
In-Reply-To: <20210718201426.759240-1-sjg@chromium.org>

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>
---

Changes in v2:
- Update commit message to indicate that things work now

 drivers/misc/swap_case.c | 13 +++++++++++--
 1 file 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;
 		}
-- 
2.32.0.402.g57bb445576-goog


  parent reply	other threads:[~2021-07-18 20:15 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-18 20:14 [PATCH v2 0/5] Fix compiler warnings for 32-bit ARM Simon Glass
2021-07-18 20:14 ` [PATCH v2 1/5] checkpatch: Support wide strings Simon Glass
2021-08-01  3:28   ` Tom Rini
2021-08-02 19:20     ` Simon Glass
2021-08-02 21:30       ` Tom Rini
2021-07-18 20:14 ` Simon Glass [this message]
2021-07-29 16:49   ` [PATCH v2 2/5] pci: swap_case: Allow compilation on 32-bit machines Tom Rini
2021-07-18 20:14 ` [PATCH v2 3/5] doc: sandbox: Fix up dependencies Simon Glass
2021-07-29 16:49   ` Tom Rini
2021-07-18 20:14 ` [PATCH v2 4/5] efi: Use 16-bit unicode strings Simon Glass
2021-07-19  0:41   ` Heinrich Schuchardt
2021-07-19  1:01     ` Tom Rini
2021-07-19  1:07       ` Heinrich Schuchardt
2021-07-19  1:36         ` Tom Rini
2021-08-01  3:28           ` Tom Rini
2021-08-01 22:54             ` Simon Glass
2021-08-01 23:46               ` Tom Rini
2021-08-02  0:03                 ` Simon Glass
2021-07-18 20:14 ` [PATCH v2 5/5] sandbox: Detect the host bit size automatically Simon Glass
2021-07-19  0:54   ` Heinrich Schuchardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210718201426.759240-3-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.