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

extending spitest with SPI_RTIOC_TRANSFER_N ioctl

The ioctl_n user parameter must be set to non-zero value
in order to perform ioctl(SPI_RTIOC_TRANSFER_N, TRANSFER_SIZE);
if ioctl_n is 0 or undefined then the test performs ioctl(SPI_RTIOC_TRANSFER).
Default SPI clock speed is set to 40MHz instead of 60MHz
because bbb am335x realtime SPI driver has its maximum set to this value.
Signed-off-by: default avatarLaurentiu-Cristian Duca <>
Signed-off-by: Jan Kiszka's avatarJan Kiszka <>
parent 3d8d59f9
......@@ -40,17 +40,19 @@ smokey_test_plugin(spi_transfer,
"Run a SPI transfer.\n"
"\tioctl_n=<set to non-zero to use SPI_RTIOC_TRANSFER_N ioctl>"
#define ONE_BILLION 1000000000
#define TEN_MILLIONS 10000000
static int with_traffic = 1, with_latency;
static int with_traffic = 1, with_latency, with_ioctl_n = 0;
#define SEQ_SHIFT 24
#define SEQ_MASK ((1 << SEQ_SHIFT) - 1)
......@@ -311,8 +313,16 @@ static int do_spi_loop(int fd)
if (ret < 0)
clock_gettime(CLOCK_MONOTONIC, &start);
if (!__Terrno(ret, ioctl(fd, SPI_RTIOC_TRANSFER)))
return ret;
if (with_ioctl_n == 0) {
if (!__Terrno(ret,
return ret;
} else {
if (!__Terrno(ret,
return ret;
if (with_latency) {
clock_gettime(CLOCK_MONOTONIC, &now);
dt = (int32_t)diff_ts(&now, &start);
......@@ -348,7 +358,7 @@ static int do_spi_loop(int fd)
static int run_spi_transfer(struct smokey_test *t, int argc, char *const argv[])
int fd, ret, speed_hz = 60000000;
int fd, ret, speed_hz = 40000000;
struct rtdm_spi_config config;
struct rtdm_spi_iobufs iobufs;
const char *device = NULL;
......@@ -366,7 +376,12 @@ static int run_spi_transfer(struct smokey_test *t, int argc, char *const argv[])
if (SMOKEY_ARG_ISSET(spi_transfer, speed))
speed_hz = SMOKEY_ARG_INT(spi_transfer, speed);
if (SMOKEY_ARG_ISSET(spi_transfer, ioctl_n)) {
with_ioctl_n = SMOKEY_ARG_INT(spi_transfer, ioctl_n);
smokey_note("ioctl_n enabled; using SPI_RTIOC_TRANSFER_N");
if (!SMOKEY_ARG_ISSET(spi_transfer, device)) {
warning("missing device= specification");
return -EINVAL;
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