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. " \
62 /* run only a specific test */
66 "only run the test with this number (0-based !)");
385 { .compatible = "linux,spi-loopback-test", },
398 .name = "spi-loopback-test",
408 MODULE_DESCRIPTION("test spi_driver to check core functionality");
473 /* check for unwritten test pattern on rx_buf */
555 /* second test after a (hopefull) translation */
574 struct spi_test *test)
580 for (i = 0; i < test->transfer_count; i++) {
581 struct spi_transfer *xfer = test->transfers + i;
592 if (test->elapsed_time < estimated_time) {
595 test->elapsed_time, estimated_time);
709 struct spi_test *test)
711 struct spi_transfer *xfers = test->transfers;
725 for (i = 0; i < test->transfer_count; i++) {
737 switch (test->fill_option) {
739 *tx_buf = test->fill_pattern;
742 *tx_buf = GET_VALUE_BYTE(test->fill_pattern,
746 *tx_buf = GET_VALUE_BYTE(test->fill_pattern,
750 *tx_buf = GET_VALUE_BYTE(test->fill_pattern,
783 test->fill_option);
793 struct spi_test *test,
796 struct spi_message *msg = &test->msg;
807 for (i = 0; i < test->transfer_count; i++) {
808 x = &test->transfers[i];
827 ret = spi_test_fill_pattern(spi, test);
832 if (test->execute_msg)
833 ret = test->execute_msg(spi, test, tx, rx);
835 ret = spi_test_execute_msg(spi, test, tx, rx);
838 if (ret == test->expected_return)
842 "test failed - test returned %i, but we expect %i\n",
843 ret, test->expected_return);
862 struct spi_test test;
865 /* copy the test template to test */
866 memcpy(&test, testtemplate, sizeof(test));
871 if (!(test.iterate_transfer_mask & (BIT(test.transfer_count) - 1)))
872 test.iterate_transfer_mask = 1;
876 for (i = 0; i < test.transfer_count; i++) {
877 if (test.transfers[i].tx_buf)
879 if (test.transfers[i].rx_buf)
889 test.description);
895 test.description);
901 dev_info(&spi->dev, "Running test %s\n", test.description);
909 for (i = 0; i < test.transfer_count; i++) {
911 if (!(test.iterate_transfer_mask & BIT(i)))
913 test.transfers[i].len = len;
914 if (test.transfers[i].tx_buf)
915 test.transfers[i].tx_buf += tx_off;
916 if (test.transfers[i].rx_buf)
917 test.transfers[i].rx_buf += rx_off;
921 return _spi_test_run_iter(spi, &test, tx, rx);
925 * spi_test_execute_msg - default implementation to run a test
928 * @test: the test to execute, which already contains @msg
929 * @tx: the tx buffer allocated for the test sequence
930 * @rx: the rx buffer allocated for the test sequence
934 int spi_test_execute_msg(struct spi_device *spi, struct spi_test *test,
937 struct spi_message *msg = &test->msg;
952 test->elapsed_time = ktime_to_ns(ktime_sub(ktime_get(), start));
981 ret = spi_test_check_elapsed_time(spi, test);
1000 * @test: the test which we need to execute
1001 * @tx: the tx buffer allocated for the test sequence
1002 * @rx: the rx buffer allocated for the test sequence
1007 int spi_test_run_test(struct spi_device *spi, const struct spi_test *test,
1015 /* test for transfer limits */
1016 if (test->transfer_count >= SPI_TEST_MAX_TRANSFERS) {
1019 test->description, test->transfer_count);
1033 var < (test->iterate_##var ? \
1036 test->iterate_##var) : \
1041 (len = test->iterate_len[idx_len]) != -1; idx_len++) {
1047 ret = spi_test_run_iter(spi, test,
1075 struct spi_test *test;
1098 for (test = tests, count = 0; test->description[0];
1099 test++, count++) {
1100 /* only run test if requested */
1104 if (test->run_test)
1105 ret = test->run_test(spi, test, tx, rx);
1107 ret = spi_test_run_test(spi, test, tx, rx);