linux/drivers/platform/chrome/cros_kunit_util.h
Tzung-Bi Shih afef1e1a02 platform/chrome: cros_kunit_util: add default value for msg->result
Add default value for `msg->result` so that it won't be garbage bytes
when the mock list is empty.

Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
Link: https://lore.kernel.org/r/20220720044754.4026295-3-tzungbi@kernel.org
2022-07-21 08:49:28 +00:00

49 lines
1.4 KiB
C

/* SPDX-License-Identifier: GPL-2.0 */
/*
* CrOS Kunit tests utilities.
*/
#ifndef _CROS_KUNIT_UTIL_H_
#define _CROS_KUNIT_UTIL_H_
#include <linux/platform_data/cros_ec_proto.h>
struct ec_xfer_mock {
struct list_head list;
struct kunit *test;
/* input */
struct cros_ec_command msg;
void *i_data;
/* output */
int ret;
int result;
void *o_data;
u32 o_data_len;
};
extern int cros_kunit_ec_xfer_mock_default_result;
extern int cros_kunit_ec_xfer_mock_default_ret;
extern int cros_kunit_ec_cmd_xfer_mock_called;
extern int cros_kunit_ec_pkt_xfer_mock_called;
int cros_kunit_ec_xfer_mock(struct cros_ec_device *ec_dev, struct cros_ec_command *msg);
int cros_kunit_ec_cmd_xfer_mock(struct cros_ec_device *ec_dev, struct cros_ec_command *msg);
int cros_kunit_ec_pkt_xfer_mock(struct cros_ec_device *ec_dev, struct cros_ec_command *msg);
struct ec_xfer_mock *cros_kunit_ec_xfer_mock_add(struct kunit *test, size_t size);
struct ec_xfer_mock *cros_kunit_ec_xfer_mock_addx(struct kunit *test,
int ret, int result, size_t size);
struct ec_xfer_mock *cros_kunit_ec_xfer_mock_next(void);
extern int cros_kunit_readmem_mock_offset;
extern u8 *cros_kunit_readmem_mock_data;
extern int cros_kunit_readmem_mock_ret;
int cros_kunit_readmem_mock(struct cros_ec_device *ec_dev, unsigned int offset,
unsigned int bytes, void *dest);
void cros_kunit_mock_reset(void);
#endif