Author: stefanct
Date: Wed Aug  6 00:16:01 2014
New Revision: 1836
URL: http://flashrom.org/trac/flashrom/changeset/1836

Log:
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 <[email protected]>
Reviewed-by: David Hendricks <[email protected]>
Acked-by: Stefan Tauner <[email protected]>

Modified:
   trunk/linux_spi.c

Modified: trunk/linux_spi.c
==============================================================================
--- trunk/linux_spi.c   Sun Aug  3 16:15:14 2014        (r1835)
+++ trunk/linux_spi.c   Wed Aug  6 00:16:01 2014        (r1836)
@@ -142,11 +142,11 @@
        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,
                },
        };

_______________________________________________
flashrom mailing list
[email protected]
http://www.flashrom.org/mailman/listinfo/flashrom

Reply via email to