Lines Matching defs:test
3 * linux/drivers/spi/spi-loopback-test.c
7 * Loopback test driver to test several typical spi_message conditions
23 #include "spi-test.h"
48 "if set controller will be asked to enable test loop mode. " \
56 /* run only a specific test */
60 "only run the test with this number (0-based !)");
347 { .compatible = "linux,spi-loopback-test", },
360 .name = "spi-loopback-test",
370 MODULE_DESCRIPTION("test spi_driver to check core functionality");
435 /* check for unwritten test pattern on rx_buf */
517 /* second test after a (hopefull) translation */
536 struct spi_test *test)
542 for (i = 0; i < test->transfer_count; i++) {
543 struct spi_transfer *xfer = test->transfers + i;
554 if (test->elapsed_time < estimated_time) {
557 test->elapsed_time, estimated_time);
671 struct spi_test *test)
673 struct spi_transfer *xfers = test->transfers;
687 for (i = 0; i < test->transfer_count; i++) {
699 switch (test->fill_option) {
701 *tx_buf = test->fill_pattern;
704 *tx_buf = GET_VALUE_BYTE(test->fill_pattern,
708 *tx_buf = GET_VALUE_BYTE(test->fill_pattern,
712 *tx_buf = GET_VALUE_BYTE(test->fill_pattern,
745 test->fill_option);
755 struct spi_test *test,
758 struct spi_message *msg = &test->msg;
769 for (i = 0; i < test->transfer_count; i++) {
770 x = &test->transfers[i];
789 ret = spi_test_fill_pattern(spi, test);
794 if (test->execute_msg)
795 ret = test->execute_msg(spi, test, tx, rx);
797 ret = spi_test_execute_msg(spi, test, tx, rx);
800 if (ret == test->expected_return)
804 "test failed - test returned %i, but we expect %i\n",
805 ret, test->expected_return);
824 struct spi_test test;
827 /* copy the test template to test */
828 memcpy(&test, testtemplate, sizeof(test));
833 if (!(test.iterate_transfer_mask & (BIT(test.transfer_count) - 1)))
834 test.iterate_transfer_mask = 1;
838 for (i = 0; i < test.transfer_count; i++) {
839 if (test.transfers[i].tx_buf)
841 if (test.transfers[i].rx_buf)
851 test.description);
857 test.description);
863 dev_info(&spi->dev, "Running test %s\n", test.description);
871 for (i = 0; i < test.transfer_count; i++) {
873 if (!(test.iterate_transfer_mask & BIT(i)))
875 test.transfers[i].len = len;
876 if (test.transfers[i].tx_buf)
877 test.transfers[i].tx_buf += tx_off;
878 if (test.transfers[i].rx_buf)
879 test.transfers[i].rx_buf += rx_off;
883 return _spi_test_run_iter(spi, &test, tx, rx);
887 * spi_test_execute_msg - default implementation to run a test
890 * @test: the test to execute, which already contains @msg
891 * @tx: the tx buffer allocated for the test sequence
892 * @rx: the rx buffer allocated for the test sequence
896 int spi_test_execute_msg(struct spi_device *spi, struct spi_test *test,
899 struct spi_message *msg = &test->msg;
914 test->elapsed_time = ktime_to_ns(ktime_sub(ktime_get(), start));
943 ret = spi_test_check_elapsed_time(spi, test);
962 * @test: the test which we need to execute
963 * @tx: the tx buffer allocated for the test sequence
964 * @rx: the rx buffer allocated for the test sequence
969 int spi_test_run_test(struct spi_device *spi, const struct spi_test *test,
977 /* test for transfer limits */
978 if (test->transfer_count >= SPI_TEST_MAX_TRANSFERS) {
981 test->description, test->transfer_count);
995 var < (test->iterate_##var ? \
998 test->iterate_##var) : \
1003 (len = test->iterate_len[idx_len]) != -1; idx_len++) {
1007 ret = spi_test_run_iter(spi, test,
1035 struct spi_test *test;
1058 for (test = tests, count = 0; test->description[0];
1059 test++, count++) {
1060 /* only run test if requested */
1064 if (test->run_test)
1065 ret = test->run_test(spi, test, tx, rx);
1067 ret = spi_test_run_test(spi, test, tx, rx);