The patch titled Subject: lib/test_bitmap.c: add for_each_set_clump8 test cases has been added to the -mm tree. Its filename is lib-test_bitmapc-add-for_each_set_clump8-test-cases.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/lib-test_bitmapc-add-for_each_set_clump8-test-cases.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/lib-test_bitmapc-add-for_each_set_clump8-test-cases.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: William Breathitt Gray <vilhelm.gray@xxxxxxxxx> Subject: lib/test_bitmap.c: add for_each_set_clump8 test cases The introduction of the for_each_set_clump8 macro warrants test cases to verify the implementation. This patch adds test case checks for whether an out-of-bounds clump index is returned, a zero clump is returned, or the returned clump value differs from the expected clump value. Link: http://lkml.kernel.org/r/febc0fb8151e3e3fdd61c34da9193d1c4d7e6c12.1570641097.git.vilhelm.gray@xxxxxxxxx Signed-off-by: William Breathitt Gray <vilhelm.gray@xxxxxxxxx> Reviewed-by: Andy Shevchenko <andy.shevchenko@xxxxxxxxx> Reviewed-by: Linus Walleij <linus.walleij@xxxxxxxxxx> Cc: Rasmus Villemoes <linux@xxxxxxxxxxxxxxxxxx> Cc: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx> Cc: Arnd Bergmann <arnd@xxxxxxxx> Cc: Bartosz Golaszewski <bgolaszewski@xxxxxxxxxxxx> Cc: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx> Cc: Geert Uytterhoeven <geert+renesas@xxxxxxxxx> Cc: Lukas Wunner <lukas@xxxxxxxxx> Cc: Masahiro Yamada <yamada.masahiro@xxxxxxxxxxxxx> Cc: Mathias Duckeck <m.duckeck@xxxxxxxxx> Cc: Morten Hein Tiljeset <morten.tiljeset@xxxxxxxxx> Cc: Phil Reid <preid@xxxxxxxxxxxxxxxxx> Cc: Sean Nyekjaer <sean.nyekjaer@xxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- lib/test_bitmap.c | 65 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) --- a/lib/test_bitmap.c~lib-test_bitmapc-add-for_each_set_clump8-test-cases +++ a/lib/test_bitmap.c @@ -92,6 +92,36 @@ __check_eq_u32_array(const char *srcfile return true; } +static bool __init __check_eq_clump8(const char *srcfile, unsigned int line, + const unsigned int offset, + const unsigned int size, + const unsigned char *const clump_exp, + const unsigned long *const clump) +{ + unsigned long exp; + + if (offset >= size) { + pr_warn("[%s:%u] bit offset for clump out-of-bounds: expected less than %u, got %u\n", + srcfile, line, size, offset); + return false; + } + + exp = clump_exp[offset / 8]; + if (!exp) { + pr_warn("[%s:%u] bit offset for zero clump: expected nonzero clump, got bit offset %u with clump value 0", + srcfile, line, offset); + return false; + } + + if (*clump != exp) { + pr_warn("[%s:%u] expected clump value of 0x%lX, got clump value of 0x%lX", + srcfile, line, exp, *clump); + return false; + } + + return true; +} + #define __expect_eq(suffix, ...) \ ({ \ int result = 0; \ @@ -108,6 +138,7 @@ __check_eq_u32_array(const char *srcfile #define expect_eq_bitmap(...) __expect_eq(bitmap, ##__VA_ARGS__) #define expect_eq_pbl(...) __expect_eq(pbl, ##__VA_ARGS__) #define expect_eq_u32_array(...) __expect_eq(u32_array, ##__VA_ARGS__) +#define expect_eq_clump8(...) __expect_eq(clump8, ##__VA_ARGS__) static void __init test_zero_clear(void) { @@ -404,6 +435,39 @@ static void noinline __init test_mem_opt } } +static const unsigned char clump_exp[] __initconst = { + 0x01, /* 1 bit set */ + 0x02, /* non-edge 1 bit set */ + 0x00, /* zero bits set */ + 0x38, /* 3 bits set across 4-bit boundary */ + 0x38, /* Repeated clump */ + 0x0F, /* 4 bits set */ + 0xFF, /* all bits set */ + 0x05, /* non-adjacent 2 bits set */ +}; + +static void __init test_for_each_set_clump8(void) +{ +#define CLUMP_EXP_NUMBITS 64 + DECLARE_BITMAP(bits, CLUMP_EXP_NUMBITS); + unsigned int start; + unsigned long clump; + + /* set bitmap to test case */ + bitmap_zero(bits, CLUMP_EXP_NUMBITS); + bitmap_set(bits, 0, 1); /* 0x01 */ + bitmap_set(bits, 9, 1); /* 0x02 */ + bitmap_set(bits, 27, 3); /* 0x28 */ + bitmap_set(bits, 35, 3); /* 0x28 */ + bitmap_set(bits, 40, 4); /* 0x0F */ + bitmap_set(bits, 48, 8); /* 0xFF */ + bitmap_set(bits, 56, 1); /* 0x05 - part 1 */ + bitmap_set(bits, 58, 1); /* 0x05 - part 2 */ + + for_each_set_clump8(start, clump, bits, CLUMP_EXP_NUMBITS) + expect_eq_clump8(start, CLUMP_EXP_NUMBITS, clump_exp, &clump); +} + static void __init selftest(void) { test_zero_clear(); @@ -413,6 +477,7 @@ static void __init selftest(void) test_bitmap_parselist(); test_bitmap_parselist_user(); test_mem_optimisations(); + test_for_each_set_clump8(); } KSTM_MODULE_LOADERS(test_bitmap); _ Patches currently in -mm which might be from vilhelm.gray@xxxxxxxxx are bitops-introduce-the-for_each_set_clump8-macro.patch lib-test_bitmapc-add-for_each_set_clump8-test-cases.patch gpio-104-dio-48e-utilize-for_each_set_clump8-macro.patch gpio-104-idi-48-utilize-for_each_set_clump8-macro.patch gpio-gpio-mm-utilize-for_each_set_clump8-macro.patch gpio-ws16c48-utilize-for_each_set_clump8-macro.patch gpio-pci-idio-16-utilize-for_each_set_clump8-macro.patch gpio-pcie-idio-24-utilize-for_each_set_clump8-macro.patch gpio-uniphier-utilize-for_each_set_clump8-macro.patch gpio-74x164-utilize-the-for_each_set_clump8-macro.patch thermal-intel-intel_soc_dts_iosf-utilize-for_each_set_clump8-macro.patch gpio-pisosr-utilize-the-for_each_set_clump8-macro.patch gpio-max3191x-utilize-the-for_each_set_clump8-macro.patch gpio-pca953x-utilize-the-for_each_set_clump8-macro.patch