linux/drivers/spi/spi-loopback-test.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 *  linux/drivers/spi/spi-loopback-test.c
 *
 *  (c) Martin Sperl <[email protected]>
 *
 *  Loopback test driver to test several typical spi_message conditions
 *  that a spi_master driver may encounter
 *  this can also get used for regression testing
 */

#include <linux/delay.h>
#include <linux/kernel.h>
#include <linux/ktime.h>
#include <linux/list.h>
#include <linux/list_sort.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/printk.h>
#include <linux/vmalloc.h>
#include <linux/spi/spi.h>

#include "spi-test.h"

/* flag to only simulate transfers */
static int simulate_only;
module_param(simulate_only, int, 0);
MODULE_PARM_DESC();

/* dump spi messages */
static int dump_messages;
module_param(dump_messages, int, 0);
MODULE_PARM_DESC();
/* the device is jumpered for loopback - enabling some rx_buf tests */
static int loopback;
module_param(loopback, int, 0);
MODULE_PARM_DESC();

static int loop_req;
module_param(loop_req, int, 0);
MODULE_PARM_DESC();

static int no_cs;
module_param(no_cs, int, 0);
MODULE_PARM_DESC();

/* run tests only for a specific length */
static int run_only_iter_len =;
module_param(run_only_iter_len, int, 0);
MODULE_PARM_DESC();

/* run only a specific test */
static int run_only_test =;
module_param(run_only_test, int, 0);
MODULE_PARM_DESC();

/* use vmalloc'ed buffers */
static int use_vmalloc;
module_param(use_vmalloc, int, 0644);
MODULE_PARM_DESC();

/* check rx ranges */
static int check_ranges =;
module_param(check_ranges, int, 0644);
MODULE_PARM_DESC();

static unsigned int delay_ms =;
module_param(delay_ms, uint, 0644);
MODULE_PARM_DESC();

/* the actual tests to execute */
static struct spi_test spi_tests[] =;

static int spi_loopback_test_probe(struct spi_device *spi)
{}

/* non const match table to permit to change via a module parameter */
static struct of_device_id spi_loopback_test_of_match[] =;

/* allow to override the compatible string via a module_parameter */
module_param_string();

MODULE_DEVICE_TABLE();

static struct spi_driver spi_loopback_test_driver =;

module_spi_driver();

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();

/*-------------------------------------------------------------------------*/

/* spi_test implementation */

#define RANGE_CHECK(ptr, plen, start, slen)

/* we allocate one page more, to allow for offsets */
#define SPI_TEST_MAX_SIZE_PLUS

static void spi_test_print_hex_dump(char *pre, const void *ptr, size_t len)
{}

static void spi_test_dump_message(struct spi_device *spi,
				  struct spi_message *msg,
				  bool dump_data)
{}

struct rx_ranges {};

static int rx_ranges_cmp(void *priv, const struct list_head *a,
			 const struct list_head *b)
{}

static int spi_check_rx_ranges(struct spi_device *spi,
			       struct spi_message *msg,
			       void *rx)
{}

static int spi_test_check_elapsed_time(struct spi_device *spi,
				       struct spi_test *test)
{}

static int spi_test_check_loopback_result(struct spi_device *spi,
					  struct spi_message *msg,
					  void *tx, void *rx)
{}

static int spi_test_translate(struct spi_device *spi,
			      void **ptr, size_t len,
			      void *tx, void *rx)
{}

static int spi_test_fill_pattern(struct spi_device *spi,
				 struct spi_test *test)
{}

static int _spi_test_run_iter(struct spi_device *spi,
			      struct spi_test *test,
			      void *tx, void *rx)
{}

static int spi_test_run_iter(struct spi_device *spi,
			     const struct spi_test *testtemplate,
			     void *tx, void *rx,
			     size_t len,
			     size_t tx_off,
			     size_t rx_off
	)
{}

/**
 * spi_test_execute_msg - default implementation to run a test
 *
 * @spi: @spi_device on which to run the @spi_message
 * @test: the test to execute, which already contains @msg
 * @tx:   the tx buffer allocated for the test sequence
 * @rx:   the rx buffer allocated for the test sequence
 *
 * Returns: error code of spi_sync as well as basic error checking
 */
int spi_test_execute_msg(struct spi_device *spi, struct spi_test *test,
			 void *tx, void *rx)
{}
EXPORT_SYMBOL_GPL();

/**
 * spi_test_run_test - run an individual spi_test
 *                     including all the relevant iterations on:
 *                     length and buffer alignment
 *
 * @spi:  the spi_device to send the messages to
 * @test: the test which we need to execute
 * @tx:   the tx buffer allocated for the test sequence
 * @rx:   the rx buffer allocated for the test sequence
 *
 * Returns: status code of spi_sync or other failures
 */

int spi_test_run_test(struct spi_device *spi, const struct spi_test *test,
		      void *tx, void *rx)
{}
EXPORT_SYMBOL_GPL();

/**
 * spi_test_run_tests - run an array of spi_messages tests
 * @spi: the spi device on which to run the tests
 * @tests: NULL-terminated array of @spi_test
 *
 * Returns: status errors as per @spi_test_run_test()
 */

int spi_test_run_tests(struct spi_device *spi,
		       struct spi_test *tests)
{}
EXPORT_SYMBOL_GPL();