summaryrefslogtreecommitdiff
path: root/linux_spi.c
diff options
context:
space:
mode:
authorstefanct <stefanct@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2014-08-05 22:16:01 +0000
committerstefanct <stefanct@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2014-08-05 22:16:01 +0000
commitd851a29d2b7548a7fdc26c012cad6d20c31a5737 (patch)
treea302ee3839d61da639b806e99b7aa7c9ec2fb43a /linux_spi.c
parentb049a063a934e2207d134d65269895f224103cdf (diff)
downloadflashrom-d851a29d2b7548a7fdc26c012cad6d20c31a5737.tar.gz
linux_spi: properly convert pointers to kernel's u64.
For arm64 with 32-bit userspace, pointers such as 0xff96ebf8 were incorrectly getting converted to u64_t 0xffffffffff96ebf8 in the spi_ioc_transfer struct which was causing ioctl()s to be rejected by the kernel. With this patch we first cast to uintptr_t (to avoid warnings on architectures where char * are not 64b wide) and then to uint64_t which is always big enough and does not produce warnings. This patch is taken from ChromiumOS' Change-Id: I5a15b4ca5d9657c3cb1ddccd42eafd91c852dd26 Signed-off-by: David Riley <davidriley@chromium.org> Reviewed-by: David Hendricks <dhendrix@chromium.org> Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@1836 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'linux_spi.c')
-rw-r--r--linux_spi.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/linux_spi.c b/linux_spi.c
index 2315c2a..26725e1 100644
--- a/linux_spi.c
+++ b/linux_spi.c
@@ -142,11 +142,11 @@ static int linux_spi_send_command(struct flashctx *flash, unsigned int writecnt,
int iocontrol_code;
struct spi_ioc_transfer msg[2] = {
{
- .tx_buf = (uint64_t)(ptrdiff_t)txbuf,
+ .tx_buf = (uint64_t)(uintptr_t)txbuf,
.len = writecnt,
},
{
- .rx_buf = (uint64_t)(ptrdiff_t)rxbuf,
+ .rx_buf = (uint64_t)(uintptr_t)rxbuf,
.len = readcnt,
},
};