i2c: aspeed: add KUnit tests for clock parameters
PATCH 1/1 i2c: aspeed: add KUnit tests for clock parameters
Add KUnit tests for Aspeed I2C driver to test setting clock divider registers given an input clock speed.
I wrote this test a while ago and it found a bug in the Aspeed I2C driver a couple years ago[1].
Link[1]: https://lore.kernel.org/patchwork/patch/989312/
Signed-off-by Brendan Higgins <[email protected]>
--- MAINTAINERS | 1 + drivers/i2c/busses/Kconfig | 18 ++- drivers/i2c/busses/i2c-aspeed-test.c | 218 +++++++++++++++++++++++++++ drivers/i2c/busses/i2c-aspeed.c | 4 + 4 files changed, 240 insertions(+), 1 deletion(-) create mode 100644 drivers/i2c/busses/i2c-aspeed-test.c
MAINTAINERS +1 -0
@@ -1653,6 +1653,7 @@ L: openbmc at lists.ozlabs.org (moderated for non-subscribers) S: Maintained F: Documentation/devicetree/bindings/i2c/i2c-aspeed.txt F: Documentation/devicetree/bindings/interrupt-controller/aspeed,ast2400-i2c-ic.txt +F: drivers/i2c/busses/i2c-aspeed-test.c F: drivers/i2c/busses/i2c-aspeed.c F: drivers/irqchip/irq-aspeed-i2c-ic.c
drivers/i2c/busses/Kconfig +17 -1
@@ -379,7 +379,7 @@ config I2C_ALTERA config I2C_ASPEED tristate "Aspeed I2C Controller" - depends on ARCH_ASPEED || COMPILE_TEST + depends on ARCH_ASPEED || COMPILE_TEST || KUNIT=y help If you say yes to this option, support will be included for the Aspeed I2C controller.
@@ -387,6 +387,22 @@ config I2C_ASPEED This driver can also be built as a module. If so, the module will be called i2c-aspeed. +config I2C_ASPEED_KUNIT_TEST + bool "Aspeed I2C Controller KUnit test" + depends on I2C_ASPEED=y + help + This builds the Aspeed I2C KUnit tests. + + KUnit tests run during boot and output the results to the debug log + in TAP format (https://testanything.org/). Only useful for kernel devs + running KUnit test harness and are not for inclusion into a + production build. + + For more information on KUnit and unit tests in general please refer + to the KUnit documentation in Documentation/dev-tools/kunit/. + + If unsure, say N. + config I2C_AT91 tristate "Atmel AT91 I2C Two-Wire interface (TWI)" depends on ARCH_AT91 || COMPILE_TEST
drivers/i2c/busses/i2c-aspeed-test.c new file +218 -0
218 lines not on this page · raw message
drivers/i2c/busses/i2c-aspeed.c +4 -0
@@ -1082,6 +1082,10 @@ static struct platform_driver aspeed_i2c_bus_driver = { };module_platform_driver (aspeed_i2c_bus_driver); +#ifdef CONFIG_I2C_ASPEED_KUNIT_TEST +#include "i2c-aspeed-test.c" +#endif /* CONFIG_I2C_ASPEED_KUNIT_TEST */ +MODULE_AUTHOR ("Brendan Higgins <[email protected]>" );MODULE_DESCRIPTION ("Aspeed I2C Bus Driver" );MODULE_LICENSE ("GPL v2" );
base-commit: 1abdd39f14b25dd2d69096b624a4f86f158a9feb
Signature · 1 line
2.29.0.rc1.297.gfa9743e501-goog