platform/chrome: avoid garbage bytes in `msg->result`
Subsystems (2)
Tzung-Bi Shih
maintainercover platform/chrome: avoid garbage bytes in `msg->result`
The 1st patch merges Kunit utils and test cases. The idea is basically from the review comment in [1].
The 2nd patch fixes that msg->result would be garbage bytes if the mock list is empty. This is separated from previous series [2].
[1]: https://patchwork.kernel.org/project/chrome-platform/patch/[email protected]/#24944149
[2]: https://patchwork.kernel.org/project/chrome-platform/patch/[email protected]/
Tzung-Bi Shih (2):
platform/chrome: merge Kunit utils and test cases platform/chrome: cros_kunit_util: add default value for msg->result
drivers/platform/chrome/Kconfig | 10 ++-------- drivers/platform/chrome/Makefile | 5 +++-- drivers/platform/chrome/cros_kunit_util.c | 20 +++++--------------- drivers/platform/chrome/cros_kunit_util.h | 1 + 4 files changed, 11 insertions(+), 25 deletions(-)
Signature · 1 line
2.37.0.170.g444d1eabd0-goog
Tzung-Bi Shih
maintainerPATCH 1/2 platform/chrome: merge Kunit utils and test cases
Merge CROS_KUNIT and CROS_EC_PROTO_KUNIT_TEST so that when they're built as modules cros_kunit_util doesn't need to export the symbols.
--- drivers/platform/chrome/Kconfig | 10 ++-------- drivers/platform/chrome/Makefile | 5 +++-- drivers/platform/chrome/cros_kunit_util.c | 14 -------------- 3 files changed, 5 insertions(+), 24 deletions(-)
drivers/platform/chrome/Kconfig +2 -8
@@ -269,17 +269,11 @@ source "drivers/platform/chrome/wilco_ec/Kconfig" # Kunit test cases config CROS_KUNIT - tristate - help - ChromeOS Kunit. - -config CROS_EC_PROTO_KUNIT_TEST - tristate "Kunit tests for ChromeOS EC protocol" if !KUNIT_ALL_TESTS + tristate "Kunit tests for ChromeOS" if !KUNIT_ALL_TESTS depends on KUNIT && CROS_EC default KUNIT_ALL_TESTS select CROS_EC_PROTO - select CROS_KUNIT help - Kunit tests for the ChromeOS Embedded Controller protocol. + ChromeOS Kunit tests. endif # CHROMEOS_PLATFORMS
drivers/platform/chrome/Makefile +3 -2
@@ -32,5 +32,6 @@ obj-$(CONFIG_CROS_USBPD_NOTIFY) += cros_usbpd_notify.o obj-$(CONFIG_WILCO_EC) += wilco_ec/ # Kunit test cases -obj-$(CONFIG_CROS_KUNIT) += cros_kunit_util.o -obj-$(CONFIG_CROS_EC_PROTO_KUNIT_TEST) += cros_ec_proto_test.o +obj-$(CONFIG_CROS_KUNIT) += cros_kunit.o +cros_kunit-objs := cros_kunit_util.o +cros_kunit-objs += cros_ec_proto_test.o
drivers/platform/chrome/cros_kunit_util.c +0 -14
@@ -14,11 +14,8 @@#include "cros_kunit_util.h" int cros_kunit_ec_xfer_mock_default_ret; -EXPORT_SYMBOL_GPL (cros_kunit_ec_xfer_mock_default_ret);int cros_kunit_ec_cmd_xfer_mock_called; -EXPORT_SYMBOL_GPL (cros_kunit_ec_cmd_xfer_mock_called);int cros_kunit_ec_pkt_xfer_mock_called; -EXPORT_SYMBOL_GPL (cros_kunit_ec_pkt_xfer_mock_called);static struct list_head cros_kunit_ec_xfer_mock_in;static struct list_head cros_kunit_ec_xfer_mock_out;
@@ -48,27 +45,23 @@ int cros_kunit_ec_xfer_mock(struct cros_ec_device *ec_dev, struct cros_ec_commanreturn mock->ret; } -EXPORT_SYMBOL_GPL (cros_kunit_ec_xfer_mock);int cros_kunit_ec_cmd_xfer_mock (struct cros_ec_device *ec_dev,struct cros_ec_command *msg) { ++cros_kunit_ec_cmd_xfer_mock_called;return cros_kunit_ec_xfer_mock (ec_dev, msg); } -EXPORT_SYMBOL_GPL (cros_kunit_ec_cmd_xfer_mock);int cros_kunit_ec_pkt_xfer_mock (struct cros_ec_device *ec_dev,struct cros_ec_command *msg) { ++cros_kunit_ec_pkt_xfer_mock_called;return cros_kunit_ec_xfer_mock (ec_dev, msg); } -EXPORT_SYMBOL_GPL (cros_kunit_ec_pkt_xfer_mock);struct ec_xfer_mock *cros_kunit_ec_xfer_mock_add (struct kunit *test,size_t size) {return cros_kunit_ec_xfer_mock_addx (test, size,EC_RES_SUCCESS , size); } -EXPORT_SYMBOL_GPL (cros_kunit_ec_xfer_mock_add);struct ec_xfer_mock *cros_kunit_ec_xfer_mock_addx (struct kunit *test,int ret,int result,size_t size)
@@ -91,7 +84,6 @@ struct ec_xfer_mock *cros_kunit_ec_xfer_mock_addx(struct kunit *test,return mock; } -EXPORT_SYMBOL_GPL (cros_kunit_ec_xfer_mock_addx);struct ec_xfer_mock *cros_kunit_ec_xfer_mock_next (void ) {
@@ -103,14 +95,10 @@ struct ec_xfer_mock *cros_kunit_ec_xfer_mock_next(void)return mock; } -EXPORT_SYMBOL_GPL (cros_kunit_ec_xfer_mock_next);int cros_kunit_readmem_mock_offset; -EXPORT_SYMBOL_GPL (cros_kunit_readmem_mock_offset);u8 *cros_kunit_readmem_mock_data; -EXPORT_SYMBOL_GPL (cros_kunit_readmem_mock_data);int cros_kunit_readmem_mock_ret; -EXPORT_SYMBOL_GPL (cros_kunit_readmem_mock_ret);int cros_kunit_readmem_mock (struct cros_ec_device *ec_dev,unsigned int offset,unsigned int bytes,void *dest)
@@ -121,7 +109,6 @@ int cros_kunit_readmem_mock(struct cros_ec_device *ec_dev, unsigned int offset,return cros_kunit_readmem_mock_ret; } -EXPORT_SYMBOL_GPL (cros_kunit_readmem_mock);void cros_kunit_mock_reset (void ) {
@@ -135,6 +122,5 @@ void cros_kunit_mock_reset(void) cros_kunit_readmem_mock_data =NULL ; cros_kunit_readmem_mock_ret =0 ; } -EXPORT_SYMBOL_GPL (cros_kunit_mock_reset);MODULE_LICENSE ("GPL" );
Signature · 1 line
2.37.0.170.g444d1eabd0-goog
Re: [PATCH 1/2] platform/chrome: merge Kunit utils and test cases
Quoted 4 lines · Tzung-Bi Shih
Merge
CROS_KUNITandCROS_EC_PROTO_KUNIT_TESTso that when they're built as modulescros_kunit_utildoesn't need to export the symbols.
Quoted 129 lines
Signed-off-by Tzung-Bi Shih <[email protected]>--- drivers/platform/chrome/Kconfig | 10 ++-------- drivers/platform/chrome/Makefile | 5 +++-- drivers/platform/chrome/cros_kunit_util.c | 14 -------------- 3 files changed, 5 insertions(+), 24 deletions(-)drivers/platform/chrome/Kconfig +2
-8@@ -269,17 +269,11 @@ source "drivers/platform/chrome/wilco_ec/Kconfig" # Kunit test cases config CROS_KUNIT - tristate - help - ChromeOS Kunit. - -config CROS_EC_PROTO_KUNIT_TEST - tristate "Kunit tests for ChromeOS EC protocol" if !KUNIT_ALL_TESTS + tristate "Kunit tests for ChromeOS" if !KUNIT_ALL_TESTS depends on KUNIT && CROS_EC default KUNIT_ALL_TESTS select CROS_EC_PROTO - select CROS_KUNIT help - Kunit tests for the ChromeOS Embedded Controller protocol. + ChromeOS Kunit tests. endif # CHROMEOS_PLATFORMSdrivers/platform/chrome/Makefile +3
-2@@ -32,5 +32,6 @@ obj-$(CONFIG_CROS_USBPD_NOTIFY) += cros_usbpd_notify.o obj-$(CONFIG_WILCO_EC) += wilco_ec/ # Kunit test cases -obj-$(CONFIG_CROS_KUNIT) += cros_kunit_util.o -obj-$(CONFIG_CROS_EC_PROTO_KUNIT_TEST) += cros_ec_proto_test.o +obj-$(CONFIG_CROS_KUNIT) += cros_kunit.o +cros_kunit-objs := cros_kunit_util.o +cros_kunit-objs += cros_ec_proto_test.odrivers/platform/chrome/cros_kunit_util.c +0
-15@@ -14,11 +14,8 @@#include "cros_kunit_util.h" int cros_kunit_ec_xfer_mock_default_ret; -EXPORT_SYMBOL_GPL (cros_kunit_ec_xfer_mock_default_ret);int cros_kunit_ec_cmd_xfer_mock_called; -EXPORT_SYMBOL_GPL (cros_kunit_ec_cmd_xfer_mock_called);int cros_kunit_ec_pkt_xfer_mock_called; -EXPORT_SYMBOL_GPL (cros_kunit_ec_pkt_xfer_mock_called);static struct list_head cros_kunit_ec_xfer_mock_in;static struct list_head cros_kunit_ec_xfer_mock_out;@@ -48,27 +45,23 @@ int cros_kunit_ec_xfer_mock(struct cros_ec_device *ec_dev, struct cros_ec_commanreturn mock->ret; } -EXPORT_SYMBOL_GPL (cros_kunit_ec_xfer_mock);int cros_kunit_ec_cmd_xfer_mock (struct cros_ec_device *ec_dev,struct cros_ec_command *msg) { ++cros_kunit_ec_cmd_xfer_mock_called;return cros_kunit_ec_xfer_mock (ec_dev, msg); } -EXPORT_SYMBOL_GPL (cros_kunit_ec_cmd_xfer_mock);int cros_kunit_ec_pkt_xfer_mock (struct cros_ec_device *ec_dev,struct cros_ec_command *msg) { ++cros_kunit_ec_pkt_xfer_mock_called;return cros_kunit_ec_xfer_mock (ec_dev, msg); } -EXPORT_SYMBOL_GPL (cros_kunit_ec_pkt_xfer_mock);struct ec_xfer_mock *cros_kunit_ec_xfer_mock_add (struct kunit *test,size_t size) {return cros_kunit_ec_xfer_mock_addx (test, size,EC_RES_SUCCESS , size); } -EXPORT_SYMBOL_GPL (cros_kunit_ec_xfer_mock_add);struct ec_xfer_mock *cros_kunit_ec_xfer_mock_addx (struct kunit *test,int ret,int result,size_t size)@@ -91,7 +84,6 @@ struct ec_xfer_mock *cros_kunit_ec_xfer_mock_addx(struct kunit *test,return mock; } -EXPORT_SYMBOL_GPL (cros_kunit_ec_xfer_mock_addx);struct ec_xfer_mock *cros_kunit_ec_xfer_mock_next (void ) {@@ -103,14 +95,10 @@ struct ec_xfer_mock *cros_kunit_ec_xfer_mock_next(void)return mock; } -EXPORT_SYMBOL_GPL (cros_kunit_ec_xfer_mock_next);int cros_kunit_readmem_mock_offset; -EXPORT_SYMBOL_GPL (cros_kunit_readmem_mock_offset);u8 *cros_kunit_readmem_mock_data; -EXPORT_SYMBOL_GPL (cros_kunit_readmem_mock_data);int cros_kunit_readmem_mock_ret; -EXPORT_SYMBOL_GPL (cros_kunit_readmem_mock_ret);int cros_kunit_readmem_mock (struct cros_ec_device *ec_dev,unsigned int offset,unsigned int bytes,void *dest)@@ -121,7 +109,6 @@ int cros_kunit_readmem_mock(struct cros_ec_device *ec_dev, unsigned int offset,return cros_kunit_readmem_mock_ret; } -EXPORT_SYMBOL_GPL (cros_kunit_readmem_mock);void cros_kunit_mock_reset (void ) {@@ -135,6 +122,5 @@ void cros_kunit_mock_reset(void) cros_kunit_readmem_mock_data =NULL ; cros_kunit_readmem_mock_ret =0 ; } -EXPORT_SYMBOL_GPL (cros_kunit_mock_reset);MODULE_LICENSE ("GPL" ); --2.37.0.170.g444d1eabd0-goog
Tzung-Bi Shih
maintainerPATCH 2/2 platform/chrome: cros_kunit_util: add default value for `msg->result`
In reply to Tzung-Bi ShihAdd default value for msg->result so that it won't be garbage bytes when the mock list is empty.
--- drivers/platform/chrome/cros_kunit_util.c | 6 +++++- drivers/platform/chrome/cros_kunit_util.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-)
drivers/platform/chrome/cros_kunit_util.c +5 -1
@@ -13,6 +13,7 @@#include "cros_ec.h" #include "cros_kunit_util.h" +int cros_kunit_ec_xfer_mock_default_result;int cros_kunit_ec_xfer_mock_default_ret;int cros_kunit_ec_cmd_xfer_mock_called;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_commanstruct ec_xfer_mock *mock; mock = list_first_entry_or_null(&cros_kunit_ec_xfer_mock_in, struct ec_xfer_mock, list); -if (!mock) +if (!mock) { + msg->result = cros_kunit_ec_xfer_mock_default_result;return cros_kunit_ec_xfer_mock_default_ret; + }list_del (&mock->list);
@@ -112,6 +115,7 @@ int cros_kunit_readmem_mock(struct cros_ec_device *ec_dev, unsigned int offset,void cros_kunit_mock_reset (void ) { + cros_kunit_ec_xfer_mock_default_result =0 ; cros_kunit_ec_xfer_mock_default_ret =0 ; cros_kunit_ec_cmd_xfer_mock_called =0 ; cros_kunit_ec_pkt_xfer_mock_called =0 ;
drivers/platform/chrome/cros_kunit_util.h +1 -0
@@ -23,6 +23,7 @@ struct ec_xfer_mock {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;
Signature · 1 line
2.37.0.170.g444d1eabd0-goog
Re: [PATCH 2/2] platform/chrome: cros_kunit_util: add default value for `msg->result`
Quoted 5 lines · Tzung-Bi Shih
Add default value for
msg->resultso that it won't be garbage bytes when the mock list is empty.Signed-off-by Tzung-Bi Shih <[email protected]>
Quoted 52 lines
--- drivers/platform/chrome/cros_kunit_util.c | 6 +++++- drivers/platform/chrome/cros_kunit_util.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-)drivers/platform/chrome/cros_kunit_util.c +5
-1@@ -13,6 +13,7 @@#include "cros_ec.h" #include "cros_kunit_util.h" +int cros_kunit_ec_xfer_mock_default_result;int cros_kunit_ec_xfer_mock_default_ret;int cros_kunit_ec_cmd_xfer_mock_called;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_commanstruct ec_xfer_mock *mock; mock = list_first_entry_or_null(&cros_kunit_ec_xfer_mock_in, struct ec_xfer_mock, list); -if (!mock) +if (!mock) { + msg->result = cros_kunit_ec_xfer_mock_default_result;return cros_kunit_ec_xfer_mock_default_ret; + }list_del (&mock->list);@@ -112,6 +115,7 @@ int cros_kunit_readmem_mock(struct cros_ec_device *ec_dev, unsigned int offset,void cros_kunit_mock_reset (void ) { + cros_kunit_ec_xfer_mock_default_result =0 ; cros_kunit_ec_xfer_mock_default_ret =0 ; cros_kunit_ec_cmd_xfer_mock_called =0 ; cros_kunit_ec_pkt_xfer_mock_called =0 ;drivers/platform/chrome/cros_kunit_util.h +1
-1@@ -23,6 +23,7 @@ struct ec_xfer_mock {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; --2.37.0.170.g444d1eabd0-goog
This series was applied to chrome-platform/linux.git (for-kernelci) by Tzung-Bi Shih <[email protected]>:
Hello:
This series was applied to chrome-platform/linux.git (for-kernelci) by Tzung-Bi Shih <[email protected]>:
Quoted 10 lines · On Wed, 20 Jul 2022 04:47:52 +0000 you wrote:
The 1st patch merges Kunit utils and test cases. The idea is basically from the review comment in [1].
The 2nd patch fixes that
msg->resultwould be garbage bytes if the mock list is empty. This is separated from previous series [2].[1]: https://patchwork.kernel.org/project/chrome-platform/patch/[email protected]/#24944149
[2]: https://patchwork.kernel.org/project/chrome-platform/patch/[email protected]/[...]
Here is the summary with links:
- [1/2] platform/chrome: merge Kunit utils and test cases
https://git.kernel.org/chrome-platform/c/f92dd1475b06 - [2/2] platform/chrome: cros_kunit_util: add default value for `msg->result` https://git.kernel.org/chrome-platform/c/afef1e1a0223
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
This series was applied to chrome-platform/linux.git (for-next) by Tzung-Bi Shih <[email protected]>:
Hello:
This series was applied to chrome-platform/linux.git (for-next) by Tzung-Bi Shih <[email protected]>:
Quoted 10 lines · On Wed, 20 Jul 2022 04:47:52 +0000 you wrote:
The 1st patch merges Kunit utils and test cases. The idea is basically from the review comment in [1].
The 2nd patch fixes that
msg->resultwould be garbage bytes if the mock list is empty. This is separated from previous series [2].[1]: https://patchwork.kernel.org/project/chrome-platform/patch/[email protected]/#24944149
[2]: https://patchwork.kernel.org/project/chrome-platform/patch/[email protected]/[...]
Here is the summary with links:
- [1/2] platform/chrome: merge Kunit utils and test cases
https://git.kernel.org/chrome-platform/c/f92dd1475b06 - [2/2] platform/chrome: cros_kunit_util: add default value for `msg->result` https://git.kernel.org/chrome-platform/c/afef1e1a0223
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html