Skip to content

Commit afef1e1

Browse files
author
Tzung-Bi Shih
committed
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 <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent f92dd14 commit afef1e1

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

drivers/platform/chrome/cros_kunit_util.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "cros_ec.h"
1414
#include "cros_kunit_util.h"
1515

16+
int cros_kunit_ec_xfer_mock_default_result;
1617
int cros_kunit_ec_xfer_mock_default_ret;
1718
int cros_kunit_ec_cmd_xfer_mock_called;
1819
int cros_kunit_ec_pkt_xfer_mock_called;
@@ -25,8 +26,10 @@ int cros_kunit_ec_xfer_mock(struct cros_ec_device *ec_dev, struct cros_ec_comman
2526
struct ec_xfer_mock *mock;
2627

2728
mock = list_first_entry_or_null(&cros_kunit_ec_xfer_mock_in, struct ec_xfer_mock, list);
28-
if (!mock)
29+
if (!mock) {
30+
msg->result = cros_kunit_ec_xfer_mock_default_result;
2931
return cros_kunit_ec_xfer_mock_default_ret;
32+
}
3033

3134
list_del(&mock->list);
3235

@@ -112,6 +115,7 @@ int cros_kunit_readmem_mock(struct cros_ec_device *ec_dev, unsigned int offset,
112115

113116
void cros_kunit_mock_reset(void)
114117
{
118+
cros_kunit_ec_xfer_mock_default_result = 0;
115119
cros_kunit_ec_xfer_mock_default_ret = 0;
116120
cros_kunit_ec_cmd_xfer_mock_called = 0;
117121
cros_kunit_ec_pkt_xfer_mock_called = 0;

drivers/platform/chrome/cros_kunit_util.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ struct ec_xfer_mock {
2323
u32 o_data_len;
2424
};
2525

26+
extern int cros_kunit_ec_xfer_mock_default_result;
2627
extern int cros_kunit_ec_xfer_mock_default_ret;
2728
extern int cros_kunit_ec_cmd_xfer_mock_called;
2829
extern int cros_kunit_ec_pkt_xfer_mock_called;

0 commit comments

Comments
 (0)