Lines Matching refs: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",
407 MODULE_DESCRIPTION("test spi_driver to check core functionality");
472 /* check for unwritten test pattern on rx_buf */
554 /* second test after a (hopefull) translation */
573 struct spi_test *test)
579 for (i = 0; i < test->transfer_count; i++) {
580 struct spi_transfer *xfer = test->transfers + i;
591 if (test->elapsed_time < estimated_time) {
594 test->elapsed_time, estimated_time);
708 struct spi_test *test)
710 struct spi_transfer *xfers = test->transfers;
724 for (i = 0; i < test->transfer_count; i++) {
736 switch (test->fill_option) {
738 *tx_buf = test->fill_pattern;
741 *tx_buf = GET_VALUE_BYTE(test->fill_pattern,
745 *tx_buf = GET_VALUE_BYTE(test->fill_pattern,
749 *tx_buf = GET_VALUE_BYTE(test->fill_pattern,
782 test->fill_option);
792 struct spi_test *test,
795 struct spi_message *msg = &test->msg;
806 for (i = 0; i < test->transfer_count; i++) {
807 x = &test->transfers[i];
826 ret = spi_test_fill_pattern(spi, test);
831 if (test->execute_msg)
832 ret = test->execute_msg(spi, test, tx, rx);
834 ret = spi_test_execute_msg(spi, test, tx, rx);
837 if (ret == test->expected_return)
841 "test failed - test returned %i, but we expect %i\n",
842 ret, test->expected_return);
861 struct spi_test test;
864 /* copy the test template to test */
865 memcpy(&test, testtemplate, sizeof(test));
870 if (!(test.iterate_transfer_mask & (BIT(test.transfer_count) - 1)))
871 test.iterate_transfer_mask = 1;
875 for (i = 0; i < test.transfer_count; i++) {
876 if (test.transfers[i].tx_buf)
878 if (test.transfers[i].rx_buf)
888 test.description);
894 test.description);
900 dev_info(&spi->dev, "Running test %s\n", test.description);
908 for (i = 0; i < test.transfer_count; i++) {
910 if (!(test.iterate_transfer_mask & BIT(i)))
912 test.transfers[i].len = len;
913 if (test.transfers[i].tx_buf)
914 test.transfers[i].tx_buf += tx_off;
915 if (test.transfers[i].rx_buf)
916 test.transfers[i].rx_buf += rx_off;
920 return _spi_test_run_iter(spi, &test, tx, rx);
924 * spi_test_execute_msg - default implementation to run a test
927 * @test: the test to execute, which already contains @msg
928 * @tx: the tx buffer allocated for the test sequence
929 * @rx: the rx buffer allocated for the test sequence
933 int spi_test_execute_msg(struct spi_device *spi, struct spi_test *test,
936 struct spi_message *msg = &test->msg;
951 test->elapsed_time = ktime_to_ns(ktime_sub(ktime_get(), start));
980 ret = spi_test_check_elapsed_time(spi, test);
999 * @test: the test which we need to execute
1000 * @tx: the tx buffer allocated for the test sequence
1001 * @rx: the rx buffer allocated for the test sequence
1006 int spi_test_run_test(struct spi_device *spi, const struct spi_test *test,
1014 /* test for transfer limits */
1015 if (test->transfer_count >= SPI_TEST_MAX_TRANSFERS) {
1018 test->description, test->transfer_count);
1032 var < (test->iterate_##var ? \
1035 test->iterate_##var) : \
1040 (len = test->iterate_len[idx_len]) != -1; idx_len++) {
1046 ret = spi_test_run_iter(spi, test,
1074 struct spi_test *test;
1097 for (test = tests, count = 0; test->description[0];
1098 test++, count++) {
1099 /* only run test if requested */
1103 if (test->run_test)
1104 ret = test->run_test(spi, test, tx, rx);
1106 ret = spi_test_run_test(spi, test, tx, rx);