Module: xenomai-3
Branch: wip/drivers
Commit: 11a3a75f92cecabf2a202698ebde60287dd5ef3f
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=11a3a75f92cecabf2a202698ebde60287dd5ef3f

Author: Philippe Gerum <r...@xenomai.org>
Date:   Tue Jun 28 10:41:33 2016 +0200

drivers/spi: introduce iobufs.map_len to expose the mapping length

Overwriting iobufs.io_len for returning the length of the user-space
mapping makes no sense, since both values have different meanings
(DMA_ALIGNED(io_len) * 2 == map_len).

---

 include/rtdm/uapi/spi.h          |    1 +
 kernel/drivers/spi/spi-bcm2835.c |    2 +-
 testsuite/spitest/spitest.c      |    4 ++--
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/include/rtdm/uapi/spi.h b/include/rtdm/uapi/spi.h
index 45bc92d..8f04237 100644
--- a/include/rtdm/uapi/spi.h
+++ b/include/rtdm/uapi/spi.h
@@ -30,6 +30,7 @@ struct rtdm_spi_iobufs {
        __u32 io_len;
        __u32 i_offset;
        __u32 o_offset;
+       __u32 map_len;
 };
 
 #define SPI_RTIOC_SET_CONFIG           _IOW(RTDM_CLASS_SPI, 0, struct 
rtdm_spi_config)
diff --git a/kernel/drivers/spi/spi-bcm2835.c b/kernel/drivers/spi/spi-bcm2835.c
index 02ebecd..118cfd5 100644
--- a/kernel/drivers/spi/spi-bcm2835.c
+++ b/kernel/drivers/spi/spi-bcm2835.c
@@ -409,7 +409,7 @@ static int bcm2835_set_iobufs(struct rtdm_spi_remote_slave 
*slave,
 
        p->i_offset = 0;
        p->o_offset = bcm->io_len / 2;
-       p->io_len = bcm->io_len;
+       p->map_len = bcm->io_len;
        
        return 0;
 }
diff --git a/testsuite/spitest/spitest.c b/testsuite/spitest/spitest.c
index 0609bad..40ef9a9 100644
--- a/testsuite/spitest/spitest.c
+++ b/testsuite/spitest/spitest.c
@@ -385,14 +385,14 @@ static int run_spi_transfer(struct smokey_test *t, int 
argc, char *const argv[])
        if (!__T(ret, ioctl(fd, SPI_RTIOC_SET_IOBUFS, &iobufs)))
                return ret;
 
-       p = mmap(NULL, iobufs.io_len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
+       p = mmap(NULL, iobufs.map_len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
        if (!__Fassert(p == MAP_FAILED))
                return -EINVAL;
        
        smokey_trace("input_area[%u..%u], output_area[%u..%u], mapping 
length=%u",
                     iobufs.i_offset, iobufs.i_offset + TRANSFER_SIZE - 1,
                     iobufs.o_offset, iobufs.o_offset + TRANSFER_SIZE - 1,
-                    iobufs.io_len);
+                    iobufs.map_len);
        
        i_area = p + iobufs.i_offset;
        o_area = p + iobufs.o_offset;


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git

Reply via email to