| 1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
| 2 |
/* |
| 3 |
* CrOS Kunit tests utilities. |
| 4 |
*/ |
| 5 |
|
| 6 |
#ifndef _CROS_KUNIT_UTIL_H_ |
| 7 |
#define _CROS_KUNIT_UTIL_H_ |
| 8 |
|
| 9 |
#include <linux/platform_data/cros_ec_proto.h> |
| 10 |
|
| 11 |
struct ec_xfer_mock { |
| 12 |
struct list_head list; |
| 13 |
struct kunit *test; |
| 14 |
|
| 15 |
/* input */ |
| 16 |
void *i_data; |
| 17 |
|
| 18 |
/* output */ |
| 19 |
int ret; |
| 20 |
int result; |
| 21 |
void *o_data; |
| 22 |
u32 o_data_len; |
| 23 |
|
| 24 |
/* input */ |
| 25 |
/* Must be last -ends in a flexible-array member. */ |
| 26 |
struct cros_ec_command msg; |
| 27 |
}; |
| 28 |
|
| 29 |
extern int cros_kunit_ec_xfer_mock_default_result; |
| 30 |
extern int cros_kunit_ec_xfer_mock_default_ret; |
| 31 |
extern int cros_kunit_ec_cmd_xfer_mock_called; |
| 32 |
extern int cros_kunit_ec_pkt_xfer_mock_called; |
| 33 |
|
| 34 |
int cros_kunit_ec_xfer_mock(struct cros_ec_device *ec_dev, struct cros_ec_command *msg); |
| 35 |
int cros_kunit_ec_cmd_xfer_mock(struct cros_ec_device *ec_dev, struct cros_ec_command *msg); |
| 36 |
int cros_kunit_ec_pkt_xfer_mock(struct cros_ec_device *ec_dev, struct cros_ec_command *msg); |
| 37 |
struct ec_xfer_mock *cros_kunit_ec_xfer_mock_add(struct kunit *test, size_t size); |
| 38 |
struct ec_xfer_mock *cros_kunit_ec_xfer_mock_addx(struct kunit *test, |
| 39 |
int ret, int result, size_t size); |
| 40 |
struct ec_xfer_mock *cros_kunit_ec_xfer_mock_next(void); |
| 41 |
|
| 42 |
extern int cros_kunit_readmem_mock_offset; |
| 43 |
extern u8 *cros_kunit_readmem_mock_data; |
| 44 |
extern int cros_kunit_readmem_mock_ret; |
| 45 |
|
| 46 |
int cros_kunit_readmem_mock(struct cros_ec_device *ec_dev, unsigned int offset, |
| 47 |
unsigned int bytes, void *dest); |
| 48 |
|
| 49 |
void cros_kunit_mock_reset(void); |
| 50 |
|
| 51 |
#endif |