2 * linux/drivers/spi/spi-loopback-test.c
4 * (c) Martin Sperl <kernel@martin.sperl.org>
6 * Loopback test driver to test several typical spi_message conditions
7 * that a spi_master driver may encounter
8 * this can also get used for regression testing
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
21 #include <linux/delay.h>
22 #include <linux/kernel.h>
23 #include <linux/list.h>
24 #include <linux/list_sort.h>
25 #include <linux/module.h>
26 #include <linux/of_device.h>
27 #include <linux/printk.h>
28 #include <linux/spi/spi.h>
32 /* flag to only simulate transfers */
34 module_param(simulate_only
, int, 0);
35 MODULE_PARM_DESC(simulate_only
, "if not 0 do not execute the spi message");
37 /* dump spi messages */
39 module_param(dump_messages
, int, 0);
40 MODULE_PARM_DESC(dump_messages
,
41 "=1 dump the basic spi_message_structure, " \
42 "=2 dump the spi_message_structure including data, " \
43 "=3 dump the spi_message structure before and after execution");
44 /* the device is jumpered for loopback - enabling some rx_buf tests */
46 module_param(loopback
, int, 0);
47 MODULE_PARM_DESC(loopback
,
48 "if set enable loopback mode, where the rx_buf " \
49 "is checked to match tx_buf after the spi_message " \
52 /* run only a specific test */
53 int run_only_test
= -1;
54 module_param(run_only_test
, int, 0);
55 MODULE_PARM_DESC(run_only_test
,
56 "only run the test with this number (0-based !)");
58 /* the actual tests to execute */
59 static struct spi_test spi_tests
[] = {
61 .description
= "tx/rx-transfer - start of page",
62 .fill_option
= FILL_COUNT_8
,
63 .iterate_len
= { ITERATE_MAX_LEN
},
64 .iterate_tx_align
= ITERATE_ALIGN
,
65 .iterate_rx_align
= ITERATE_ALIGN
,
75 .description
= "tx/rx-transfer - crossing PAGE_SIZE",
76 .fill_option
= FILL_COUNT_8
,
77 .iterate_len
= { ITERATE_MAX_LEN
},
78 .iterate_tx_align
= ITERATE_ALIGN
,
79 .iterate_rx_align
= ITERATE_ALIGN
,
83 .tx_buf
= TX(PAGE_SIZE
- 4),
84 .rx_buf
= RX(PAGE_SIZE
- 4),
89 .description
= "tx-transfer - only",
90 .fill_option
= FILL_COUNT_8
,
91 .iterate_len
= { ITERATE_MAX_LEN
},
92 .iterate_tx_align
= ITERATE_ALIGN
,
101 .description
= "rx-transfer - only",
102 .fill_option
= FILL_COUNT_8
,
103 .iterate_len
= { ITERATE_MAX_LEN
},
104 .iterate_rx_align
= ITERATE_ALIGN
,
113 .description
= "two tx-transfers - alter both",
114 .fill_option
= FILL_COUNT_8
,
115 .iterate_len
= { ITERATE_LEN
},
116 .iterate_tx_align
= ITERATE_ALIGN
,
117 .iterate_transfer_mask
= BIT(0) | BIT(1),
125 /* this is why we cant use ITERATE_MAX_LEN */
126 .tx_buf
= TX(SPI_TEST_MAX_SIZE_HALF
),
131 .description
= "two tx-transfers - alter first",
132 .fill_option
= FILL_COUNT_8
,
133 .iterate_len
= { ITERATE_MAX_LEN
},
134 .iterate_tx_align
= ITERATE_ALIGN
,
135 .iterate_transfer_mask
= BIT(1),
148 .description
= "two tx-transfers - alter second",
149 .fill_option
= FILL_COUNT_8
,
150 .iterate_len
= { ITERATE_MAX_LEN
},
151 .iterate_tx_align
= ITERATE_ALIGN
,
152 .iterate_transfer_mask
= BIT(0),
165 .description
= "two transfers tx then rx - alter both",
166 .fill_option
= FILL_COUNT_8
,
167 .iterate_len
= { ITERATE_MAX_LEN
},
168 .iterate_tx_align
= ITERATE_ALIGN
,
169 .iterate_transfer_mask
= BIT(0) | BIT(1),
182 .description
= "two transfers tx then rx - alter tx",
183 .fill_option
= FILL_COUNT_8
,
184 .iterate_len
= { ITERATE_MAX_LEN
},
185 .iterate_tx_align
= ITERATE_ALIGN
,
186 .iterate_transfer_mask
= BIT(0),
199 .description
= "two transfers tx then rx - alter rx",
200 .fill_option
= FILL_COUNT_8
,
201 .iterate_len
= { ITERATE_MAX_LEN
},
202 .iterate_tx_align
= ITERATE_ALIGN
,
203 .iterate_transfer_mask
= BIT(1),
216 .description
= "two tx+rx transfers - alter both",
217 .fill_option
= FILL_COUNT_8
,
218 .iterate_len
= { ITERATE_LEN
},
219 .iterate_tx_align
= ITERATE_ALIGN
,
220 .iterate_transfer_mask
= BIT(0) | BIT(1),
229 /* making sure we align without overwrite
230 * the reason we can not use ITERATE_MAX_LEN
232 .tx_buf
= TX(SPI_TEST_MAX_SIZE_HALF
),
233 .rx_buf
= RX(SPI_TEST_MAX_SIZE_HALF
),
238 .description
= "two tx+rx transfers - alter first",
239 .fill_option
= FILL_COUNT_8
,
240 .iterate_len
= { ITERATE_MAX_LEN
},
241 .iterate_tx_align
= ITERATE_ALIGN
,
242 .iterate_transfer_mask
= BIT(0),
246 /* making sure we align without overwrite */
252 /* making sure we align without overwrite */
259 .description
= "two tx+rx transfers - alter second",
260 .fill_option
= FILL_COUNT_8
,
261 .iterate_len
= { ITERATE_MAX_LEN
},
262 .iterate_tx_align
= ITERATE_ALIGN
,
263 .iterate_transfer_mask
= BIT(1),
272 /* making sure we align without overwrite */
279 { /* end of tests sequence */ }
282 static int spi_loopback_test_probe(struct spi_device
*spi
)
286 dev_info(&spi
->dev
, "Executing spi-loopback-tests\n");
288 ret
= spi_test_run_tests(spi
, spi_tests
);
290 dev_info(&spi
->dev
, "Finished spi-loopback-tests with return: %i\n",
296 /* non const match table to permit to change via a module parameter */
297 static struct of_device_id spi_loopback_test_of_match
[] = {
298 { .compatible
= "linux,spi-loopback-test", },
302 /* allow to override the compatible string via a module_parameter */
303 module_param_string(compatible
, spi_loopback_test_of_match
[0].compatible
,
304 sizeof(spi_loopback_test_of_match
[0].compatible
),
307 MODULE_DEVICE_TABLE(of
, spi_loopback_test_of_match
);
309 static struct spi_driver spi_loopback_test_driver
= {
311 .name
= "spi-loopback-test",
312 .owner
= THIS_MODULE
,
313 .of_match_table
= spi_loopback_test_of_match
,
315 .probe
= spi_loopback_test_probe
,
318 module_spi_driver(spi_loopback_test_driver
);
320 MODULE_AUTHOR("Martin Sperl <kernel@martin.sperl.org>");
321 MODULE_DESCRIPTION("test spi_driver to check core functionality");
322 MODULE_LICENSE("GPL");
324 /*-------------------------------------------------------------------------*/
326 /* spi_test implementation */
328 #define RANGE_CHECK(ptr, plen, start, slen) \
329 ((ptr >= start) && (ptr + plen <= start + slen))
331 /* we allocate one page more, to allow for offsets */
332 #define SPI_TEST_MAX_SIZE_PLUS (SPI_TEST_MAX_SIZE + PAGE_SIZE)
334 static void spi_test_print_hex_dump(char *pre
, const void *ptr
, size_t len
)
336 /* limit the hex_dump */
338 print_hex_dump(KERN_INFO
, pre
,
339 DUMP_PREFIX_OFFSET
, 16, 1,
344 print_hex_dump(KERN_INFO
, pre
,
345 DUMP_PREFIX_OFFSET
, 16, 1,
348 pr_info("%s truncated - continuing at offset %04zx\n",
350 print_hex_dump(KERN_INFO
, pre
,
351 DUMP_PREFIX_OFFSET
, 16, 1,
352 ptr
+ (len
- 512), 512, 0);
355 static void spi_test_dump_message(struct spi_device
*spi
,
356 struct spi_message
*msg
,
359 struct spi_transfer
*xfer
;
363 dev_info(&spi
->dev
, " spi_msg@%pK\n", msg
);
365 dev_info(&spi
->dev
, " status: %i\n",
367 dev_info(&spi
->dev
, " frame_length: %i\n",
369 dev_info(&spi
->dev
, " actual_length: %i\n",
372 list_for_each_entry(xfer
, &msg
->transfers
, transfer_list
) {
373 dev_info(&spi
->dev
, " spi_transfer@%pK\n", xfer
);
374 dev_info(&spi
->dev
, " len: %i\n", xfer
->len
);
375 dev_info(&spi
->dev
, " tx_buf: %pK\n", xfer
->tx_buf
);
376 if (dump_data
&& xfer
->tx_buf
)
377 spi_test_print_hex_dump(" TX: ",
381 dev_info(&spi
->dev
, " rx_buf: %pK\n", xfer
->rx_buf
);
382 if (dump_data
&& xfer
->rx_buf
)
383 spi_test_print_hex_dump(" RX: ",
386 /* check for unwritten test pattern on rx_buf */
388 for (i
= 0 ; i
< xfer
->len
; i
++) {
389 b
= ((u8
*)xfer
->rx_buf
)[xfer
->len
- 1 - i
];
390 if (b
!= SPI_TEST_PATTERN_UNWRITTEN
)
395 " rx_buf filled with %02x starts at offset: %i\n",
396 SPI_TEST_PATTERN_UNWRITTEN
,
403 struct list_head list
;
408 static int rx_ranges_cmp(void *priv
, struct list_head
*a
, struct list_head
*b
)
410 struct rx_ranges
*rx_a
= list_entry(a
, struct rx_ranges
, list
);
411 struct rx_ranges
*rx_b
= list_entry(b
, struct rx_ranges
, list
);
413 if (rx_a
->start
> rx_b
->start
)
415 if (rx_a
->start
< rx_b
->start
)
420 static int spi_check_rx_ranges(struct spi_device
*spi
,
421 struct spi_message
*msg
,
424 struct spi_transfer
*xfer
;
425 struct rx_ranges ranges
[SPI_TEST_MAX_TRANSFERS
], *r
;
427 LIST_HEAD(ranges_list
);
431 /* loop over all transfers to fill in the rx_ranges */
432 list_for_each_entry(xfer
, &msg
->transfers
, transfer_list
) {
433 /* if there is no rx, then no check is needed */
436 /* fill in the rx_range */
437 if (RANGE_CHECK(xfer
->rx_buf
, xfer
->len
,
438 rx
, SPI_TEST_MAX_SIZE_PLUS
)) {
439 ranges
[i
].start
= xfer
->rx_buf
;
440 ranges
[i
].end
= xfer
->rx_buf
+ xfer
->len
;
441 list_add(&ranges
[i
].list
, &ranges_list
);
446 /* if no ranges, then we can return and avoid the checks...*/
451 list_sort(NULL
, &ranges_list
, rx_ranges_cmp
);
453 /* and iterate over all the rx addresses */
454 for (addr
= rx
; addr
< (u8
*)rx
+ SPI_TEST_MAX_SIZE_PLUS
; addr
++) {
455 /* if we are the DO not write pattern,
456 * then continue with the loop...
458 if (*addr
== SPI_TEST_PATTERN_DO_NOT_WRITE
)
461 /* check if we are inside a range */
462 list_for_each_entry(r
, &ranges_list
, list
) {
463 /* if so then set to end... */
464 if ((addr
>= r
->start
) && (addr
< r
->end
))
467 /* second test after a (hopefull) translation */
468 if (*addr
== SPI_TEST_PATTERN_DO_NOT_WRITE
)
471 /* if still not found then something has modified too much */
472 /* we could list the "closest" transfer here... */
474 "loopback strangeness - rx changed outside of allowed range at: %pK\n",
476 /* do not return, only set ret,
477 * so that we list all addresses
485 static int spi_test_check_loopback_result(struct spi_device
*spi
,
486 struct spi_message
*msg
,
489 struct spi_transfer
*xfer
;
494 /* checks rx_buffer pattern are valid with loopback or without */
495 ret
= spi_check_rx_ranges(spi
, msg
, rx
);
499 /* if we run without loopback, then return now */
503 /* if applicable to transfer check that rx_buf is equal to tx_buf */
504 list_for_each_entry(xfer
, &msg
->transfers
, transfer_list
) {
505 /* if there is no rx, then no check is needed */
508 /* so depending on tx_buf we need to handle things */
510 for (i
= 1; i
< xfer
->len
; i
++) {
511 txb
= ((u8
*)xfer
->tx_buf
)[i
];
512 rxb
= ((u8
*)xfer
->rx_buf
)[i
];
517 /* first byte received */
518 txb
= ((u8
*)xfer
->rx_buf
)[0];
519 /* first byte may be 0 or xff */
520 if (!((txb
== 0) || (txb
== 0xff))) {
522 "loopback strangeness - we expect 0x00 or 0xff, but not 0x%02x\n",
526 /* check that all bytes are identical */
527 for (i
= 1; i
< xfer
->len
; i
++) {
528 rxb
= ((u8
*)xfer
->rx_buf
)[i
];
539 "loopback strangeness - transfer mismatch on byte %04zx - expected 0x%02x, but got 0x%02x\n",
545 static int spi_test_translate(struct spi_device
*spi
,
546 void **ptr
, size_t len
,
555 /* in the MAX_SIZE_HALF case modify the pointer */
556 if (((size_t)*ptr
) & SPI_TEST_MAX_SIZE_HALF
)
557 /* move the pointer to the correct range */
558 *ptr
+= (SPI_TEST_MAX_SIZE_PLUS
/ 2) -
559 SPI_TEST_MAX_SIZE_HALF
;
562 * - we check against MAX_SIZE_PLUS to allow for automated alignment
564 if (RANGE_CHECK(*ptr
, len
, RX(0), SPI_TEST_MAX_SIZE_PLUS
)) {
572 if (RANGE_CHECK(*ptr
, len
, TX(0), SPI_TEST_MAX_SIZE_PLUS
)) {
580 "PointerRange [%pK:%pK[ not in range [%pK:%pK[ or [%pK:%pK[\n",
582 RX(0), RX(SPI_TEST_MAX_SIZE
),
583 TX(0), TX(SPI_TEST_MAX_SIZE
));
588 static int spi_test_fill_pattern(struct spi_device
*spi
,
589 struct spi_test
*test
)
591 struct spi_transfer
*xfers
= test
->transfers
;
597 #define GET_VALUE_BYTE(value, index, bytes) \
598 (value >> (8 * (bytes - 1 - count % bytes)))
600 #define GET_VALUE_BYTE(value, index, bytes) \
601 (value >> (8 * (count % bytes)))
604 /* fill all transfers with the pattern requested */
605 for (i
= 0; i
< test
->transfer_count
; i
++) {
606 /* fill rx_buf with SPI_TEST_PATTERN_UNWRITTEN */
608 memset(xfers
[i
].rx_buf
, SPI_TEST_PATTERN_UNWRITTEN
,
610 /* if tx_buf is NULL then skip */
611 tx_buf
= (u8
*)xfers
[i
].tx_buf
;
614 /* modify all the transfers */
615 for (j
= 0; j
< xfers
[i
].len
; j
++, tx_buf
++, count
++) {
617 switch (test
->fill_option
) {
619 *tx_buf
= test
->fill_pattern
;
622 *tx_buf
= GET_VALUE_BYTE(test
->fill_pattern
,
626 *tx_buf
= GET_VALUE_BYTE(test
->fill_pattern
,
630 *tx_buf
= GET_VALUE_BYTE(test
->fill_pattern
,
637 *tx_buf
= GET_VALUE_BYTE(count
, count
, 2);
640 *tx_buf
= GET_VALUE_BYTE(count
, count
, 3);
643 *tx_buf
= GET_VALUE_BYTE(count
, count
, 4);
645 case FILL_TRANSFER_BYTE_8
:
648 case FILL_TRANSFER_BYTE_16
:
649 *tx_buf
= GET_VALUE_BYTE(j
, j
, 2);
651 case FILL_TRANSFER_BYTE_24
:
652 *tx_buf
= GET_VALUE_BYTE(j
, j
, 3);
654 case FILL_TRANSFER_BYTE_32
:
655 *tx_buf
= GET_VALUE_BYTE(j
, j
, 4);
657 case FILL_TRANSFER_NUM
:
662 "unsupported fill_option: %i\n",
672 static int _spi_test_run_iter(struct spi_device
*spi
,
673 struct spi_test
*test
,
676 struct spi_message
*msg
= &test
->msg
;
677 struct spi_transfer
*x
;
680 /* initialize message - zero-filled via static initialization */
681 spi_message_init_no_memset(msg
);
683 /* fill rx with the DO_NOT_WRITE pattern */
684 memset(rx
, SPI_TEST_PATTERN_DO_NOT_WRITE
, SPI_TEST_MAX_SIZE_PLUS
);
686 /* add the individual transfers */
687 for (i
= 0; i
< test
->transfer_count
; i
++) {
688 x
= &test
->transfers
[i
];
690 /* patch the values of tx_buf */
691 ret
= spi_test_translate(spi
, (void **)&x
->tx_buf
, x
->len
,
696 /* patch the values of rx_buf */
697 ret
= spi_test_translate(spi
, &x
->rx_buf
, x
->len
,
702 /* and add it to the list */
703 spi_message_add_tail(x
, msg
);
706 /* fill in the transfer buffers with pattern */
707 ret
= spi_test_fill_pattern(spi
, test
);
712 if (test
->execute_msg
)
713 ret
= test
->execute_msg(spi
, test
, tx
, rx
);
715 ret
= spi_test_execute_msg(spi
, test
, tx
, rx
);
718 if (ret
== test
->expected_return
)
722 "test failed - test returned %i, but we expect %i\n",
723 ret
, test
->expected_return
);
728 /* if it is 0, as we expected something else,
729 * then return something special
734 static int spi_test_run_iter(struct spi_device
*spi
,
735 const struct spi_test
*testtemplate
,
742 struct spi_test test
;
743 int i
, tx_count
, rx_count
;
745 /* copy the test template to test */
746 memcpy(&test
, testtemplate
, sizeof(test
));
748 /* set up test->transfers to the correct count */
749 if (!test
.transfer_count
) {
751 (i
< SPI_TEST_MAX_TRANSFERS
) && test
.transfers
[i
].len
;
753 test
.transfer_count
++;
757 /* if iterate_transfer_mask is not set,
758 * then set it to first transfer only
760 if (!(test
.iterate_transfer_mask
& (BIT(test
.transfer_count
) - 1)))
761 test
.iterate_transfer_mask
= 1;
763 /* count number of transfers with tx/rx_buf != NULL */
764 rx_count
= tx_count
= 0;
765 for (i
= 0; i
< test
.transfer_count
; i
++) {
766 if (test
.transfers
[i
].tx_buf
)
768 if (test
.transfers
[i
].rx_buf
)
772 /* in some iteration cases warn and exit early,
773 * as there is nothing to do, that has not been tested already...
775 if (tx_off
&& (!tx_count
)) {
776 dev_warn_once(&spi
->dev
,
777 "%s: iterate_tx_off configured with tx_buf==NULL - ignoring\n",
781 if (rx_off
&& (!rx_count
)) {
782 dev_warn_once(&spi
->dev
,
783 "%s: iterate_rx_off configured with rx_buf==NULL - ignoring\n",
789 if (!(len
|| tx_off
|| rx_off
)) {
790 dev_info(&spi
->dev
, "Running test %s\n", test
.description
);
793 " with iteration values: len = %zu, tx_off = %zu, rx_off = %zu\n",
794 len
, tx_off
, rx_off
);
797 /* update in the values from iteration values */
798 for (i
= 0; i
< test
.transfer_count
; i
++) {
799 /* only when bit in transfer mask is set */
800 if (!(test
.iterate_transfer_mask
& BIT(i
)))
803 test
.transfers
[i
].len
= len
;
804 if (test
.transfers
[i
].tx_buf
)
805 test
.transfers
[i
].tx_buf
+= tx_off
;
806 if (test
.transfers
[i
].tx_buf
)
807 test
.transfers
[i
].rx_buf
+= rx_off
;
811 return _spi_test_run_iter(spi
, &test
, tx
, rx
);
815 * spi_test_execute_msg - default implementation to run a test
817 * spi: @spi_device on which to run the @spi_message
818 * test: the test to execute, which already contains @msg
819 * tx: the tx buffer allocated for the test sequence
820 * rx: the rx buffer allocated for the test sequence
822 * Returns: error code of spi_sync as well as basic error checking
824 int spi_test_execute_msg(struct spi_device
*spi
, struct spi_test
*test
,
827 struct spi_message
*msg
= &test
->msg
;
831 /* only if we do not simulate */
832 if (!simulate_only
) {
833 /* dump the complete message before and after the transfer */
834 if (dump_messages
== 3)
835 spi_test_dump_message(spi
, msg
, true);
837 /* run spi message */
838 ret
= spi_sync(spi
, msg
);
839 if (ret
== -ETIMEDOUT
) {
841 "spi-message timed out - reruning...\n");
842 /* rerun after a few explicit schedules */
843 for (i
= 0; i
< 16; i
++)
845 ret
= spi_sync(spi
, msg
);
849 "Failed to execute spi_message: %i\n",
854 /* do some extra error checks */
855 if (msg
->frame_length
!= msg
->actual_length
) {
857 "actual length differs from expected\n");
862 /* run rx-buffer tests */
863 ret
= spi_test_check_loopback_result(spi
, msg
, tx
, rx
);
866 /* if requested or on error dump message (including data) */
868 if (dump_messages
|| ret
)
869 spi_test_dump_message(spi
, msg
,
870 (dump_messages
>= 2) || (ret
));
874 EXPORT_SYMBOL_GPL(spi_test_execute_msg
);
877 * spi_test_run_test - run an individual spi_test
878 * including all the relevant iterations on:
879 * length and buffer alignment
881 * spi: the spi_device to send the messages to
882 * test: the test which we need to execute
883 * tx: the tx buffer allocated for the test sequence
884 * rx: the rx buffer allocated for the test sequence
886 * Returns: status code of spi_sync or other failures
889 int spi_test_run_test(struct spi_device
*spi
, const struct spi_test
*test
,
894 size_t tx_align
, rx_align
;
897 /* test for transfer limits */
898 if (test
->transfer_count
>= SPI_TEST_MAX_TRANSFERS
) {
900 "%s: Exceeded max number of transfers with %i\n",
901 test
->description
, test
->transfer_count
);
905 /* setting up some values in spi_message
906 * based on some settings in spi_master
907 * some of this can also get done in the run() method
910 /* iterate over all the iterable values using macros
911 * (to make it a bit more readable...
913 #define FOR_EACH_ITERATE(var, defaultvalue) \
914 for (idx_##var = -1, var = defaultvalue; \
915 ((idx_##var < 0) || \
917 (idx_##var < SPI_TEST_MAX_ITERATE) && \
918 (var = test->iterate_##var[idx_##var]) \
922 #define FOR_EACH_ALIGNMENT(var) \
924 var < (test->iterate_##var ? \
925 (spi->master->dma_alignment ? \
926 spi->master->dma_alignment : \
927 test->iterate_##var) : \
931 FOR_EACH_ITERATE(len
, 0) {
932 FOR_EACH_ALIGNMENT(tx_align
) {
933 FOR_EACH_ALIGNMENT(rx_align
) {
934 /* and run the iteration */
935 ret
= spi_test_run_iter(spi
, test
,
948 EXPORT_SYMBOL_GPL(spi_test_run_test
);
951 * spi_test_run_tests - run an array of spi_messages tests
952 * @spi: the spi device on which to run the tests
953 * @tests: NULL-terminated array of @spi_test
955 * Returns: status errors as per @spi_test_run_test()
958 int spi_test_run_tests(struct spi_device
*spi
,
959 struct spi_test
*tests
)
961 char *rx
= NULL
, *tx
= NULL
;
962 int ret
= 0, count
= 0;
963 struct spi_test
*test
;
965 /* allocate rx/tx buffers of 128kB size without devm
966 * in the hope that is on a page boundary
968 rx
= kzalloc(SPI_TEST_MAX_SIZE_PLUS
, GFP_KERNEL
);
974 tx
= kzalloc(SPI_TEST_MAX_SIZE_PLUS
, GFP_KERNEL
);
980 /* now run the individual tests in the table */
981 for (test
= tests
, count
= 0; test
->description
[0];
983 /* only run test if requested */
984 if ((run_only_test
> -1) && (count
!= run_only_test
))
986 /* run custom implementation */
988 ret
= test
->run_test(spi
, test
, tx
, rx
);
990 ret
= spi_test_run_test(spi
, test
, tx
, rx
);
993 /* add some delays so that we can easily
994 * detect the individual tests when using a logic analyzer
995 * we also add scheduling to avoid potential spi_timeouts...
1006 EXPORT_SYMBOL_GPL(spi_test_run_tests
);