Commit 46da3a31 authored by Laurentiu-Cristian Duca's avatar Laurentiu-Cristian Duca Committed by Jan Kiszka

spi: new SPI_RTIOC_TRANSFER_N ioctl option

SPI_RTIOC_TRANSFER_N allows the user
to make SPI transfers of arbitrary lengths
by using the same mmapped memory area.
Signed-off-by: default avatarLaurentiu-Cristian Duca <laurentiu.duca@gmail.com>
Signed-off-by: Jan Kiszka's avatarJan Kiszka <jan.kiszka@siemens.com>
parent 8d64fc50
...@@ -37,5 +37,6 @@ struct rtdm_spi_iobufs { ...@@ -37,5 +37,6 @@ struct rtdm_spi_iobufs {
#define SPI_RTIOC_GET_CONFIG _IOR(RTDM_CLASS_SPI, 1, struct rtdm_spi_config) #define SPI_RTIOC_GET_CONFIG _IOR(RTDM_CLASS_SPI, 1, struct rtdm_spi_config)
#define SPI_RTIOC_SET_IOBUFS _IOR(RTDM_CLASS_SPI, 2, struct rtdm_spi_iobufs) #define SPI_RTIOC_SET_IOBUFS _IOR(RTDM_CLASS_SPI, 2, struct rtdm_spi_iobufs)
#define SPI_RTIOC_TRANSFER _IO(RTDM_CLASS_SPI, 3) #define SPI_RTIOC_TRANSFER _IO(RTDM_CLASS_SPI, 3)
#define SPI_RTIOC_TRANSFER_N _IOR(RTDM_CLASS_SPI, 4, int)
#endif /* !_RTDM_UAPI_SPI_H */ #endif /* !_RTDM_UAPI_SPI_H */
...@@ -150,7 +150,7 @@ static int spi_master_ioctl_rt(struct rtdm_fd *fd, ...@@ -150,7 +150,7 @@ static int spi_master_ioctl_rt(struct rtdm_fd *fd,
struct rtdm_spi_remote_slave *slave = fd_to_slave(fd); struct rtdm_spi_remote_slave *slave = fd_to_slave(fd);
struct rtdm_spi_master *master = slave->master; struct rtdm_spi_master *master = slave->master;
struct rtdm_spi_config config; struct rtdm_spi_config config;
int ret; int ret, len;
switch (request) { switch (request) {
case SPI_RTIOC_SET_CONFIG: case SPI_RTIOC_SET_CONFIG:
...@@ -178,6 +178,19 @@ static int spi_master_ioctl_rt(struct rtdm_fd *fd, ...@@ -178,6 +178,19 @@ static int spi_master_ioctl_rt(struct rtdm_fd *fd,
rtdm_mutex_unlock(&master->bus_lock); rtdm_mutex_unlock(&master->bus_lock);
} }
break; break;
case SPI_RTIOC_TRANSFER_N:
ret = -EINVAL;
if (master->ops->transfer_iobufs_n) {
len = (int)arg;
rtdm_mutex_lock(&master->bus_lock);
ret = do_chip_select(slave);
if (ret == 0) {
ret = master->ops->transfer_iobufs_n(slave, len);
do_chip_deselect(slave);
}
rtdm_mutex_unlock(&master->bus_lock);
}
break;
default: default:
ret = -ENOSYS; ret = -ENOSYS;
} }
......
...@@ -39,6 +39,7 @@ struct rtdm_spi_master_ops { ...@@ -39,6 +39,7 @@ struct rtdm_spi_master_ops {
struct vm_area_struct *vma); struct vm_area_struct *vma);
void (*mmap_release)(struct rtdm_spi_remote_slave *slave); void (*mmap_release)(struct rtdm_spi_remote_slave *slave);
int (*transfer_iobufs)(struct rtdm_spi_remote_slave *slave); int (*transfer_iobufs)(struct rtdm_spi_remote_slave *slave);
int (*transfer_iobufs_n)(struct rtdm_spi_remote_slave *slave, int len);
ssize_t (*write)(struct rtdm_spi_remote_slave *slave, ssize_t (*write)(struct rtdm_spi_remote_slave *slave,
const void *tx, size_t len); const void *tx, size_t len);
ssize_t (*read)(struct rtdm_spi_remote_slave *slave, ssize_t (*read)(struct rtdm_spi_remote_slave *slave,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment