Lines Matching refs:test

155 static struct regmap *gen_regmap(struct kunit *test,  in gen_regmap()  argument
159 const struct regmap_test_param *param = test->param_value; in gen_regmap()
160 struct regmap_test_priv *priv = test->priv; in gen_regmap()
192 defaults = kunit_kcalloc(test, in gen_regmap()
212 error = kunit_add_action_or_reset(test, regmap_exit_action, ret); in gen_regmap()
227 struct kunit *test = dev_get_drvdata(dev); in reg_5_false() local
228 const struct regmap_test_param *param = test->param_value; in reg_5_false()
233 static void basic_read_write(struct kunit *test) in basic_read_write() argument
242 map = gen_regmap(test, &config, &data); in basic_read_write()
243 KUNIT_ASSERT_FALSE(test, IS_ERR(map)); in basic_read_write()
250 KUNIT_EXPECT_EQ(test, 0, regmap_write(map, 0, val)); in basic_read_write()
251 KUNIT_EXPECT_EQ(test, 0, regmap_read(map, 0, &rval)); in basic_read_write()
252 KUNIT_EXPECT_EQ(test, val, rval); in basic_read_write()
255 KUNIT_EXPECT_EQ(test, config.cache_type == REGCACHE_NONE, data->read[0]); in basic_read_write()
258 static void bulk_write(struct kunit *test) in bulk_write() argument
268 map = gen_regmap(test, &config, &data); in bulk_write()
269 KUNIT_ASSERT_FALSE(test, IS_ERR(map)); in bulk_write()
279 KUNIT_EXPECT_EQ(test, 0, regmap_bulk_write(map, 0, val, in bulk_write()
282 KUNIT_EXPECT_EQ(test, 0, regmap_read(map, i, &rval[i])); in bulk_write()
284 KUNIT_EXPECT_MEMEQ(test, val, rval, sizeof(val)); in bulk_write()
288 KUNIT_EXPECT_EQ(test, config.cache_type == REGCACHE_NONE, data->read[i]); in bulk_write()
291 static void bulk_read(struct kunit *test) in bulk_read() argument
301 map = gen_regmap(test, &config, &data); in bulk_read()
302 KUNIT_ASSERT_FALSE(test, IS_ERR(map)); in bulk_read()
310 KUNIT_EXPECT_EQ(test, 0, regmap_write(map, i, val[i])); in bulk_read()
311 KUNIT_EXPECT_EQ(test, 0, regmap_bulk_read(map, 0, rval, in bulk_read()
313 KUNIT_EXPECT_MEMEQ(test, val, rval, sizeof(val)); in bulk_read()
317 KUNIT_EXPECT_EQ(test, config.cache_type == REGCACHE_NONE, data->read[i]); in bulk_read()
320 static void multi_write(struct kunit *test) in multi_write() argument
331 map = gen_regmap(test, &config, &data); in multi_write()
332 KUNIT_ASSERT_FALSE(test, IS_ERR(map)); in multi_write()
347 KUNIT_EXPECT_EQ(test, 0, in multi_write()
350 KUNIT_EXPECT_EQ(test, 0, regmap_read(map, i, &rval[i])); in multi_write()
352 KUNIT_EXPECT_MEMEQ(test, val, rval, sizeof(val)); in multi_write()
356 KUNIT_EXPECT_EQ(test, config.cache_type == REGCACHE_NONE, data->read[i]); in multi_write()
359 static void multi_read(struct kunit *test) in multi_read() argument
370 map = gen_regmap(test, &config, &data); in multi_read()
371 KUNIT_ASSERT_FALSE(test, IS_ERR(map)); in multi_read()
380 KUNIT_EXPECT_EQ(test, 0, regmap_write(map, i, val[i])); in multi_read()
382 KUNIT_EXPECT_EQ(test, 0, in multi_read()
384 KUNIT_EXPECT_MEMEQ(test, val, rval, sizeof(val)); in multi_read()
388 KUNIT_EXPECT_EQ(test, config.cache_type == REGCACHE_NONE, data->read[i]); in multi_read()
391 static void read_bypassed(struct kunit *test) in read_bypassed() argument
393 const struct regmap_test_param *param = test->param_value; in read_bypassed()
402 map = gen_regmap(test, &config, &data); in read_bypassed()
403 KUNIT_ASSERT_FALSE(test, IS_ERR(map)); in read_bypassed()
407 KUNIT_EXPECT_FALSE(test, map->cache_bypass); in read_bypassed()
412 KUNIT_EXPECT_EQ(test, 0, regmap_bulk_write(map, param->from_reg, val, ARRAY_SIZE(val))); in read_bypassed()
423 KUNIT_EXPECT_EQ(test, 0, regmap_read(map, param->from_reg + i, &rval)); in read_bypassed()
424 KUNIT_EXPECT_EQ(test, val[i], rval); in read_bypassed()
427 KUNIT_EXPECT_EQ(test, 0, regmap_read_bypassed(map, param->from_reg + i, &rval)); in read_bypassed()
428 KUNIT_EXPECT_EQ(test, val[i], rval); in read_bypassed()
429 KUNIT_EXPECT_TRUE(test, map->cache_only); in read_bypassed()
430 KUNIT_EXPECT_FALSE(test, map->cache_bypass); in read_bypassed()
444 KUNIT_EXPECT_EQ(test, 0, regmap_read(map, param->from_reg + i, &rval)); in read_bypassed()
445 KUNIT_EXPECT_NE(test, val[i], rval); in read_bypassed()
448 KUNIT_EXPECT_EQ(test, 0, regmap_read_bypassed(map, param->from_reg + i, &rval)); in read_bypassed()
449 KUNIT_EXPECT_EQ(test, val[i], rval); in read_bypassed()
450 KUNIT_EXPECT_TRUE(test, map->cache_only); in read_bypassed()
451 KUNIT_EXPECT_FALSE(test, map->cache_bypass); in read_bypassed()
455 static void read_bypassed_volatile(struct kunit *test) in read_bypassed_volatile() argument
457 const struct regmap_test_param *param = test->param_value; in read_bypassed_volatile()
468 map = gen_regmap(test, &config, &data); in read_bypassed_volatile()
469 KUNIT_ASSERT_FALSE(test, IS_ERR(map)); in read_bypassed_volatile()
473 KUNIT_EXPECT_FALSE(test, map->cache_bypass); in read_bypassed_volatile()
478 KUNIT_EXPECT_EQ(test, 0, regmap_bulk_write(map, param->from_reg, val, ARRAY_SIZE(val))); in read_bypassed_volatile()
488 KUNIT_EXPECT_EQ(test, (i == 5) ? 0 : -EBUSY, in read_bypassed_volatile()
493 KUNIT_EXPECT_EQ(test, 0, regmap_read_bypassed(map, param->from_reg + i, &rval)); in read_bypassed_volatile()
494 KUNIT_EXPECT_EQ(test, val[i], rval); in read_bypassed_volatile()
495 KUNIT_EXPECT_TRUE(test, map->cache_only); in read_bypassed_volatile()
496 KUNIT_EXPECT_FALSE(test, map->cache_bypass); in read_bypassed_volatile()
513 KUNIT_EXPECT_EQ(test, 0, regmap_read_bypassed(map, param->from_reg + i, &rval)); in read_bypassed_volatile()
514 KUNIT_EXPECT_EQ(test, val[i], rval); in read_bypassed_volatile()
515 KUNIT_EXPECT_TRUE(test, map->cache_only); in read_bypassed_volatile()
516 KUNIT_EXPECT_FALSE(test, map->cache_bypass); in read_bypassed_volatile()
520 static void write_readonly(struct kunit *test) in write_readonly() argument
532 map = gen_regmap(test, &config, &data); in write_readonly()
533 KUNIT_ASSERT_FALSE(test, IS_ERR(map)); in write_readonly()
544 KUNIT_EXPECT_EQ(test, i != 5, regmap_write(map, i, val) == 0); in write_readonly()
548 KUNIT_EXPECT_EQ(test, i != 5, data->written[i]); in write_readonly()
551 static void read_writeonly(struct kunit *test) in read_writeonly() argument
562 map = gen_regmap(test, &config, &data); in read_writeonly()
563 KUNIT_ASSERT_FALSE(test, IS_ERR(map)); in read_writeonly()
576 KUNIT_EXPECT_EQ(test, i != 5, in read_writeonly()
579 KUNIT_EXPECT_EQ(test, 0, regmap_read(map, i, &val)); in read_writeonly()
584 KUNIT_EXPECT_FALSE(test, data->read[5]); in read_writeonly()
587 static void reg_defaults(struct kunit *test) in reg_defaults() argument
598 map = gen_regmap(test, &config, &data); in reg_defaults()
599 KUNIT_ASSERT_FALSE(test, IS_ERR(map)); in reg_defaults()
604 KUNIT_EXPECT_EQ(test, 0, regmap_bulk_read(map, 0, rval, in reg_defaults()
606 KUNIT_EXPECT_MEMEQ(test, data->vals, rval, sizeof(rval)); in reg_defaults()
610 KUNIT_EXPECT_EQ(test, config.cache_type == REGCACHE_NONE, data->read[i]); in reg_defaults()
613 static void reg_defaults_read_dev(struct kunit *test) in reg_defaults_read_dev() argument
624 map = gen_regmap(test, &config, &data); in reg_defaults_read_dev()
625 KUNIT_ASSERT_FALSE(test, IS_ERR(map)); in reg_defaults_read_dev()
631 KUNIT_EXPECT_EQ(test, config.cache_type != REGCACHE_NONE, data->read[i]); in reg_defaults_read_dev()
636 KUNIT_EXPECT_EQ(test, 0, regmap_bulk_read(map, 0, rval, in reg_defaults_read_dev()
638 KUNIT_EXPECT_MEMEQ(test, data->vals, rval, sizeof(rval)); in reg_defaults_read_dev()
642 KUNIT_EXPECT_EQ(test, config.cache_type == REGCACHE_NONE, data->read[i]); in reg_defaults_read_dev()
645 static void register_patch(struct kunit *test) in register_patch() argument
658 map = gen_regmap(test, &config, &data); in register_patch()
659 KUNIT_ASSERT_FALSE(test, IS_ERR(map)); in register_patch()
664 KUNIT_EXPECT_EQ(test, 0, regmap_bulk_read(map, 0, rval, in register_patch()
674 KUNIT_EXPECT_EQ(test, 0, regmap_register_patch(map, patch, in register_patch()
682 KUNIT_EXPECT_TRUE(test, data->written[i]); in register_patch()
683 KUNIT_EXPECT_EQ(test, data->vals[i], rval[i] + 1); in register_patch()
686 KUNIT_EXPECT_FALSE(test, data->written[i]); in register_patch()
687 KUNIT_EXPECT_EQ(test, data->vals[i], rval[i]); in register_patch()
693 static void stride(struct kunit *test) in stride() argument
712 map = gen_regmap(test, &config, &data); in stride()
713 KUNIT_ASSERT_FALSE(test, IS_ERR(map)); in stride()
723 KUNIT_EXPECT_NE(test, 0, regmap_read(map, i, &rval)); in stride()
724 KUNIT_EXPECT_NE(test, 0, regmap_write(map, i, rval)); in stride()
725 KUNIT_EXPECT_FALSE(test, data->read[i]); in stride()
726 KUNIT_EXPECT_FALSE(test, data->written[i]); in stride()
728 KUNIT_EXPECT_EQ(test, 0, regmap_read(map, i, &rval)); in stride()
729 KUNIT_EXPECT_EQ(test, data->vals[i], rval); in stride()
730 KUNIT_EXPECT_EQ(test, config.cache_type == REGCACHE_NONE, in stride()
733 KUNIT_EXPECT_EQ(test, 0, regmap_write(map, i, rval)); in stride()
734 KUNIT_EXPECT_TRUE(test, data->written[i]); in stride()
770 static void basic_ranges(struct kunit *test) in basic_ranges() argument
784 map = gen_regmap(test, &config, &data); in basic_ranges()
785 KUNIT_ASSERT_FALSE(test, IS_ERR(map)); in basic_ranges()
795 KUNIT_EXPECT_EQ(test, 0, regmap_write(map, test_range.selector_reg, in basic_ranges()
801 KUNIT_EXPECT_EQ(test, 0, regmap_write(map, test_range.range_min, 0)); in basic_ranges()
802 KUNIT_EXPECT_TRUE(test, data->written[test_range.selector_reg]); in basic_ranges()
803 KUNIT_EXPECT_TRUE(test, data->written[test_range.window_start]); in basic_ranges()
807 KUNIT_EXPECT_EQ(test, 0, regmap_write(map, in basic_ranges()
811 KUNIT_EXPECT_TRUE(test, data->written[test_range.selector_reg]); in basic_ranges()
812 KUNIT_EXPECT_TRUE(test, data->written[test_range.window_start]); in basic_ranges()
817 KUNIT_EXPECT_EQ(test, 0, regmap_read(map, test_range.range_min, &val)); in basic_ranges()
818 KUNIT_EXPECT_TRUE(test, data->written[test_range.selector_reg]); in basic_ranges()
819 KUNIT_EXPECT_TRUE(test, data->read[test_range.window_start]); in basic_ranges()
823 KUNIT_EXPECT_EQ(test, 0, regmap_read(map, in basic_ranges()
827 KUNIT_EXPECT_TRUE(test, data->written[test_range.selector_reg]); in basic_ranges()
828 KUNIT_EXPECT_TRUE(test, data->read[test_range.window_start]); in basic_ranges()
832 KUNIT_EXPECT_FALSE(test, data->read[i]); in basic_ranges()
833 KUNIT_EXPECT_FALSE(test, data->written[i]); in basic_ranges()
838 static void stress_insert(struct kunit *test) in stress_insert() argument
850 map = gen_regmap(test, &config, &data); in stress_insert()
851 KUNIT_ASSERT_FALSE(test, IS_ERR(map)); in stress_insert()
856 vals = kunit_kmalloc(test, buf_sz, GFP_KERNEL); in stress_insert()
857 KUNIT_ASSERT_FALSE(test, vals == NULL); in stress_insert()
863 KUNIT_EXPECT_EQ(test, 0, regmap_write(map, i, vals[i])); in stress_insert()
865 KUNIT_EXPECT_EQ(test, 0, regmap_write(map, i, vals[i])); in stress_insert()
867 KUNIT_EXPECT_EQ(test, 0, regmap_write(map, i, vals[i])); in stress_insert()
869 KUNIT_EXPECT_EQ(test, 0, regmap_write(map, i, vals[i])); in stress_insert()
871 KUNIT_EXPECT_EQ(test, 0, regmap_write(map, i, vals[i])); in stress_insert()
873 KUNIT_EXPECT_EQ(test, 0, regmap_write(map, i, vals[i])); in stress_insert()
875 KUNIT_EXPECT_EQ(test, 0, regmap_write(map, i, vals[i])); in stress_insert()
877 KUNIT_EXPECT_EQ(test, 0, regmap_write(map, i, vals[i])); in stress_insert()
881 KUNIT_EXPECT_EQ(test, 0, regmap_read(map, i, &rval)); in stress_insert()
882 KUNIT_EXPECT_EQ(test, rval, vals[i]); in stress_insert()
883 KUNIT_EXPECT_EQ(test, config.cache_type == REGCACHE_NONE, data->read[i]); in stress_insert()
887 static void cache_bypass(struct kunit *test) in cache_bypass() argument
889 const struct regmap_test_param *param = test->param_value; in cache_bypass()
897 map = gen_regmap(test, &config, &data); in cache_bypass()
898 KUNIT_ASSERT_FALSE(test, IS_ERR(map)); in cache_bypass()
905 KUNIT_EXPECT_EQ(test, 0, regmap_write(map, param->from_reg, val)); in cache_bypass()
909 KUNIT_EXPECT_EQ(test, 0, regmap_write(map, param->from_reg, val + 1)); in cache_bypass()
912 KUNIT_EXPECT_EQ(test, 0, regmap_read(map, param->from_reg, &rval)); in cache_bypass()
913 KUNIT_EXPECT_EQ(test, val + 1, rval); in cache_bypass()
914 KUNIT_EXPECT_EQ(test, data->vals[param->from_reg], rval); in cache_bypass()
918 KUNIT_EXPECT_EQ(test, 0, regmap_read(map, param->from_reg, &rval)); in cache_bypass()
919 KUNIT_EXPECT_EQ(test, val, rval); in cache_bypass()
922 static void cache_sync_marked_dirty(struct kunit *test) in cache_sync_marked_dirty() argument
924 const struct regmap_test_param *param = test->param_value; in cache_sync_marked_dirty()
933 map = gen_regmap(test, &config, &data); in cache_sync_marked_dirty()
934 KUNIT_ASSERT_FALSE(test, IS_ERR(map)); in cache_sync_marked_dirty()
941 KUNIT_EXPECT_EQ(test, 0, regmap_bulk_write(map, param->from_reg, val, in cache_sync_marked_dirty()
949 KUNIT_EXPECT_EQ(test, 0, regcache_sync(map)); in cache_sync_marked_dirty()
952 KUNIT_EXPECT_MEMEQ(test, &data->vals[param->from_reg], val, sizeof(val)); in cache_sync_marked_dirty()
954 KUNIT_EXPECT_EQ(test, true, data->written[param->from_reg + i]); in cache_sync_marked_dirty()
957 static void cache_sync_after_cache_only(struct kunit *test) in cache_sync_after_cache_only() argument
959 const struct regmap_test_param *param = test->param_value; in cache_sync_after_cache_only()
969 map = gen_regmap(test, &config, &data); in cache_sync_after_cache_only()
970 KUNIT_ASSERT_FALSE(test, IS_ERR(map)); in cache_sync_after_cache_only()
978 KUNIT_EXPECT_EQ(test, 0, regmap_bulk_write(map, param->from_reg, val, in cache_sync_after_cache_only()
988 KUNIT_EXPECT_EQ(test, 0, regmap_bulk_write(map, param->from_reg, val, in cache_sync_after_cache_only()
991 KUNIT_EXPECT_FALSE(test, data->written[param->from_reg + i]); in cache_sync_after_cache_only()
993 KUNIT_EXPECT_MEMNEQ(test, &data->vals[param->from_reg], val, sizeof(val)); in cache_sync_after_cache_only()
998 KUNIT_EXPECT_EQ(test, 0, regcache_sync(map)); in cache_sync_after_cache_only()
1001 KUNIT_EXPECT_MEMEQ(test, &data->vals[param->from_reg], val, sizeof(val)); in cache_sync_after_cache_only()
1003 KUNIT_EXPECT_TRUE(test, data->written[param->from_reg + i]); in cache_sync_after_cache_only()
1006 static void cache_sync_defaults_marked_dirty(struct kunit *test) in cache_sync_defaults_marked_dirty() argument
1008 const struct regmap_test_param *param = test->param_value; in cache_sync_defaults_marked_dirty()
1018 map = gen_regmap(test, &config, &data); in cache_sync_defaults_marked_dirty()
1019 KUNIT_ASSERT_FALSE(test, IS_ERR(map)); in cache_sync_defaults_marked_dirty()
1026 KUNIT_EXPECT_EQ(test, 0, regmap_write(map, param->from_reg + 2, val)); in cache_sync_defaults_marked_dirty()
1032 KUNIT_EXPECT_EQ(test, 0, regcache_sync(map)); in cache_sync_defaults_marked_dirty()
1036 KUNIT_EXPECT_EQ(test, i == 2, data->written[param->from_reg + i]); in cache_sync_defaults_marked_dirty()
1040 KUNIT_EXPECT_EQ(test, 0, regmap_write(map, config.reg_defaults[i].reg, in cache_sync_defaults_marked_dirty()
1050 KUNIT_EXPECT_EQ(test, 0, regcache_sync(map)); in cache_sync_defaults_marked_dirty()
1052 KUNIT_EXPECT_FALSE(test, data->written[param->from_reg + i]); in cache_sync_defaults_marked_dirty()
1055 static void cache_sync_default_after_cache_only(struct kunit *test) in cache_sync_default_after_cache_only() argument
1057 const struct regmap_test_param *param = test->param_value; in cache_sync_default_after_cache_only()
1067 map = gen_regmap(test, &config, &data); in cache_sync_default_after_cache_only()
1068 KUNIT_ASSERT_FALSE(test, IS_ERR(map)); in cache_sync_default_after_cache_only()
1072 KUNIT_EXPECT_EQ(test, 0, regmap_read(map, param->from_reg + 2, &orig_val)); in cache_sync_default_after_cache_only()
1076 KUNIT_EXPECT_EQ(test, 0, regmap_write(map, param->from_reg + 2, orig_val + 1)); in cache_sync_default_after_cache_only()
1082 KUNIT_EXPECT_EQ(test, 0, regcache_sync(map)); in cache_sync_default_after_cache_only()
1085 KUNIT_EXPECT_TRUE(test, data->written[param->from_reg + 2]); in cache_sync_default_after_cache_only()
1086 KUNIT_EXPECT_EQ(test, data->vals[param->from_reg + 2], orig_val + 1); in cache_sync_default_after_cache_only()
1090 KUNIT_EXPECT_EQ(test, 0, regmap_write(map, param->from_reg + 2, orig_val)); in cache_sync_default_after_cache_only()
1097 KUNIT_EXPECT_EQ(test, 0, regcache_sync(map)); in cache_sync_default_after_cache_only()
1098 KUNIT_EXPECT_TRUE(test, data->written[param->from_reg + 2]); in cache_sync_default_after_cache_only()
1099 KUNIT_EXPECT_EQ(test, data->vals[param->from_reg + 2], orig_val); in cache_sync_default_after_cache_only()
1102 static void cache_sync_readonly(struct kunit *test) in cache_sync_readonly() argument
1104 const struct regmap_test_param *param = test->param_value; in cache_sync_readonly()
1114 map = gen_regmap(test, &config, &data); in cache_sync_readonly()
1115 KUNIT_ASSERT_FALSE(test, IS_ERR(map)); in cache_sync_readonly()
1121 KUNIT_EXPECT_EQ(test, 0, regmap_read(map, param->from_reg + i, &val)); in cache_sync_readonly()
1127 KUNIT_EXPECT_EQ(test, i != 5, regmap_write(map, param->from_reg + i, val) == 0); in cache_sync_readonly()
1133 KUNIT_EXPECT_EQ(test, 0, regcache_sync(map)); in cache_sync_readonly()
1137 KUNIT_EXPECT_EQ(test, i != 5, data->written[param->from_reg + i]); in cache_sync_readonly()
1140 static void cache_sync_patch(struct kunit *test) in cache_sync_patch() argument
1142 const struct regmap_test_param *param = test->param_value; in cache_sync_patch()
1154 map = gen_regmap(test, &config, &data); in cache_sync_patch()
1155 KUNIT_ASSERT_FALSE(test, IS_ERR(map)); in cache_sync_patch()
1160 KUNIT_EXPECT_EQ(test, 0, regmap_bulk_read(map, param->from_reg, rval, in cache_sync_patch()
1170 KUNIT_EXPECT_EQ(test, 0, regmap_register_patch(map, patch, in cache_sync_patch()
1177 KUNIT_EXPECT_EQ(test, 0, regcache_sync(map)); in cache_sync_patch()
1181 KUNIT_EXPECT_EQ(test, 0, regmap_read(map, param->from_reg + i, &val)); in cache_sync_patch()
1182 KUNIT_EXPECT_EQ(test, val, rval[i]); in cache_sync_patch()
1187 KUNIT_EXPECT_EQ(test, true, data->written[param->from_reg + i]); in cache_sync_patch()
1188 KUNIT_EXPECT_EQ(test, data->vals[param->from_reg + i], rval[i] + 1); in cache_sync_patch()
1191 KUNIT_EXPECT_EQ(test, false, data->written[param->from_reg + i]); in cache_sync_patch()
1192 KUNIT_EXPECT_EQ(test, data->vals[param->from_reg + i], rval[i]); in cache_sync_patch()
1198 static void cache_drop(struct kunit *test) in cache_drop() argument
1200 const struct regmap_test_param *param = test->param_value; in cache_drop()
1210 map = gen_regmap(test, &config, &data); in cache_drop()
1211 KUNIT_ASSERT_FALSE(test, IS_ERR(map)); in cache_drop()
1218 KUNIT_EXPECT_EQ(test, 0, regmap_bulk_read(map, param->from_reg, rval, in cache_drop()
1221 KUNIT_EXPECT_FALSE(test, data->read[param->from_reg + i]); in cache_drop()
1224 KUNIT_EXPECT_MEMEQ(test, &data->vals[param->from_reg], rval, sizeof(rval)); in cache_drop()
1227 KUNIT_EXPECT_EQ(test, 0, regcache_drop_region(map, param->from_reg + 3, in cache_drop()
1231 KUNIT_EXPECT_EQ(test, 0, regmap_bulk_read(map, param->from_reg, rval, in cache_drop()
1234 KUNIT_EXPECT_EQ(test, data->read[param->from_reg + i], i >= 3 && i <= 5); in cache_drop()
1235 KUNIT_EXPECT_MEMEQ(test, &data->vals[param->from_reg], rval, sizeof(rval)); in cache_drop()
1238 static void cache_drop_with_non_contiguous_ranges(struct kunit *test) in cache_drop_with_non_contiguous_ranges() argument
1240 const struct regmap_test_param *param = test->param_value; in cache_drop_with_non_contiguous_ranges()
1254 map = gen_regmap(test, &config, &data); in cache_drop_with_non_contiguous_ranges()
1255 KUNIT_ASSERT_FALSE(test, IS_ERR(map)); in cache_drop_with_non_contiguous_ranges()
1266 KUNIT_EXPECT_EQ(test, 0, regmap_bulk_write(map, reg, in cache_drop_with_non_contiguous_ranges()
1269 KUNIT_EXPECT_MEMEQ(test, &data->vals[reg], in cache_drop_with_non_contiguous_ranges()
1277 KUNIT_EXPECT_FALSE(test, data->written[reg + i]); in cache_drop_with_non_contiguous_ranges()
1282 KUNIT_EXPECT_EQ(test, 0, regcache_drop_region(map, reg, reg + BLOCK_TEST_SIZE - 1)); in cache_drop_with_non_contiguous_ranges()
1286 KUNIT_EXPECT_EQ(test, 0, regcache_drop_region(map, reg + 3, reg + 5)); in cache_drop_with_non_contiguous_ranges()
1301 KUNIT_EXPECT_EQ(test, 0, regcache_sync(map)); in cache_drop_with_non_contiguous_ranges()
1307 KUNIT_EXPECT_FALSE(test, data->written[reg + i]); in cache_drop_with_non_contiguous_ranges()
1317 KUNIT_EXPECT_TRUE(test, data->written[reg + i]); in cache_drop_with_non_contiguous_ranges()
1319 KUNIT_EXPECT_MEMEQ(test, &data->vals[reg], in cache_drop_with_non_contiguous_ranges()
1326 KUNIT_EXPECT_FALSE(test, data->written[reg + i]); in cache_drop_with_non_contiguous_ranges()
1331 KUNIT_EXPECT_EQ(test, data->written[reg + i], i < 3 || i > 5); in cache_drop_with_non_contiguous_ranges()
1333 KUNIT_EXPECT_MEMEQ(test, &data->vals[reg], &val[4 / 2], sizeof(val[4 / 2])); in cache_drop_with_non_contiguous_ranges()
1337 KUNIT_EXPECT_FALSE(test, data->written[i]); in cache_drop_with_non_contiguous_ranges()
1340 static void cache_drop_all_and_sync_marked_dirty(struct kunit *test) in cache_drop_all_and_sync_marked_dirty() argument
1342 const struct regmap_test_param *param = test->param_value; in cache_drop_all_and_sync_marked_dirty()
1352 map = gen_regmap(test, &config, &data); in cache_drop_all_and_sync_marked_dirty()
1353 KUNIT_ASSERT_FALSE(test, IS_ERR(map)); in cache_drop_all_and_sync_marked_dirty()
1360 KUNIT_EXPECT_EQ(test, 0, regmap_bulk_read(map, param->from_reg, rval, in cache_drop_all_and_sync_marked_dirty()
1362 KUNIT_EXPECT_MEMEQ(test, &data->vals[param->from_reg], rval, sizeof(rval)); in cache_drop_all_and_sync_marked_dirty()
1366 KUNIT_EXPECT_EQ(test, 0, regmap_write(map, param->from_reg + i, rval[i] + 1)); in cache_drop_all_and_sync_marked_dirty()
1369 KUNIT_EXPECT_EQ(test, 0, regcache_drop_region(map, 0, config.max_register)); in cache_drop_all_and_sync_marked_dirty()
1376 KUNIT_EXPECT_EQ(test, 0, regcache_sync(map)); in cache_drop_all_and_sync_marked_dirty()
1378 KUNIT_EXPECT_FALSE(test, data->written[i]); in cache_drop_all_and_sync_marked_dirty()
1381 static void cache_drop_all_and_sync_no_defaults(struct kunit *test) in cache_drop_all_and_sync_no_defaults() argument
1383 const struct regmap_test_param *param = test->param_value; in cache_drop_all_and_sync_no_defaults()
1392 map = gen_regmap(test, &config, &data); in cache_drop_all_and_sync_no_defaults()
1393 KUNIT_ASSERT_FALSE(test, IS_ERR(map)); in cache_drop_all_and_sync_no_defaults()
1400 KUNIT_EXPECT_EQ(test, 0, regmap_bulk_read(map, param->from_reg, rval, in cache_drop_all_and_sync_no_defaults()
1402 KUNIT_EXPECT_MEMEQ(test, &data->vals[param->from_reg], rval, sizeof(rval)); in cache_drop_all_and_sync_no_defaults()
1406 KUNIT_EXPECT_EQ(test, 0, regmap_write(map, param->from_reg + i, rval[i] + 1)); in cache_drop_all_and_sync_no_defaults()
1409 KUNIT_EXPECT_EQ(test, 0, regcache_drop_region(map, 0, config.max_register)); in cache_drop_all_and_sync_no_defaults()
1418 KUNIT_EXPECT_EQ(test, 0, regcache_sync(map)); in cache_drop_all_and_sync_no_defaults()
1420 KUNIT_EXPECT_FALSE(test, data->written[i]); in cache_drop_all_and_sync_no_defaults()
1423 static void cache_drop_all_and_sync_has_defaults(struct kunit *test) in cache_drop_all_and_sync_has_defaults() argument
1425 const struct regmap_test_param *param = test->param_value; in cache_drop_all_and_sync_has_defaults()
1435 map = gen_regmap(test, &config, &data); in cache_drop_all_and_sync_has_defaults()
1436 KUNIT_ASSERT_FALSE(test, IS_ERR(map)); in cache_drop_all_and_sync_has_defaults()
1443 KUNIT_EXPECT_EQ(test, 0, regmap_bulk_read(map, param->from_reg, rval, in cache_drop_all_and_sync_has_defaults()
1445 KUNIT_EXPECT_MEMEQ(test, &data->vals[param->from_reg], rval, sizeof(rval)); in cache_drop_all_and_sync_has_defaults()
1449 KUNIT_EXPECT_EQ(test, 0, regmap_write(map, param->from_reg + i, rval[i] + 1)); in cache_drop_all_and_sync_has_defaults()
1452 KUNIT_EXPECT_EQ(test, 0, regcache_drop_region(map, 0, config.max_register)); in cache_drop_all_and_sync_has_defaults()
1461 KUNIT_EXPECT_EQ(test, 0, regcache_sync(map)); in cache_drop_all_and_sync_has_defaults()
1463 KUNIT_EXPECT_FALSE(test, data->written[i]); in cache_drop_all_and_sync_has_defaults()
1466 static void cache_present(struct kunit *test) in cache_present() argument
1468 const struct regmap_test_param *param = test->param_value; in cache_present()
1477 map = gen_regmap(test, &config, &data); in cache_present()
1478 KUNIT_ASSERT_FALSE(test, IS_ERR(map)); in cache_present()
1487 KUNIT_ASSERT_FALSE(test, regcache_reg_cached(map, param->from_reg + i)); in cache_present()
1491 KUNIT_ASSERT_FALSE(test, data->read[param->from_reg + i]); in cache_present()
1495 KUNIT_EXPECT_EQ(test, 0, regmap_read(map, param->from_reg + i, &val)); in cache_present()
1499 KUNIT_ASSERT_TRUE(test, regcache_reg_cached(map, param->from_reg + i)); in cache_present()
1502 static void cache_write_zero(struct kunit *test) in cache_write_zero() argument
1504 const struct regmap_test_param *param = test->param_value; in cache_write_zero()
1513 map = gen_regmap(test, &config, &data); in cache_write_zero()
1514 KUNIT_ASSERT_FALSE(test, IS_ERR(map)); in cache_write_zero()
1523 KUNIT_ASSERT_FALSE(test, regcache_reg_cached(map, param->from_reg + i)); in cache_write_zero()
1527 KUNIT_ASSERT_FALSE(test, data->read[param->from_reg + i]); in cache_write_zero()
1530 KUNIT_EXPECT_EQ(test, 0, regmap_write(map, 1, 0)); in cache_write_zero()
1533 KUNIT_EXPECT_EQ(test, 0, regmap_read(map, 1, &val)); in cache_write_zero()
1534 KUNIT_EXPECT_EQ(test, 0, val); in cache_write_zero()
1537 KUNIT_ASSERT_TRUE(test, regcache_reg_cached(map, 1)); in cache_write_zero()
1540 KUNIT_EXPECT_EQ(test, 0, regcache_drop_region(map, 1, 1)); in cache_write_zero()
1541 KUNIT_ASSERT_FALSE(test, regcache_reg_cached(map, 1)); in cache_write_zero()
1545 static void cache_range_window_reg(struct kunit *test) in cache_range_window_reg() argument
1559 map = gen_regmap(test, &config, &data); in cache_range_window_reg()
1560 KUNIT_ASSERT_FALSE(test, IS_ERR(map)); in cache_range_window_reg()
1566 KUNIT_ASSERT_EQ(test, 0, regmap_write(map, i, 0)); in cache_range_window_reg()
1569 KUNIT_ASSERT_EQ(test, val, 2); in cache_range_window_reg()
1572 KUNIT_ASSERT_EQ(test, 0, regmap_write(map, test_range.range_min, 0)); in cache_range_window_reg()
1574 KUNIT_ASSERT_EQ(test, val, 0); in cache_range_window_reg()
1578 KUNIT_ASSERT_EQ(test, 0, regcache_sync(map)); in cache_range_window_reg()
1581 KUNIT_ASSERT_EQ(test, 0, regmap_write(map, test_range.range_min, 0)); in cache_range_window_reg()
1583 KUNIT_ASSERT_EQ(test, val, 0); in cache_range_window_reg()
1587 KUNIT_ASSERT_EQ(test, 0, regcache_sync(map)); in cache_range_window_reg()
1590 KUNIT_ASSERT_EQ(test, 0, regmap_write(map, test_range.range_max, 0)); in cache_range_window_reg()
1592 KUNIT_ASSERT_EQ(test, val, 2); in cache_range_window_reg()
1627 static struct regmap *gen_raw_regmap(struct kunit *test, in gen_raw_regmap() argument
1631 struct regmap_test_priv *priv = test->priv; in gen_raw_regmap()
1632 const struct regmap_test_param *param = test->param_value; in gen_raw_regmap()
1657 defaults = kunit_kcalloc(test, in gen_raw_regmap()
1692 error = kunit_add_action_or_reset(test, regmap_exit_action, ret); in gen_raw_regmap()
1705 static void raw_read_defaults_single(struct kunit *test) in raw_read_defaults_single() argument
1715 map = gen_raw_regmap(test, &config, &data); in raw_read_defaults_single()
1716 KUNIT_ASSERT_FALSE(test, IS_ERR(map)); in raw_read_defaults_single()
1722 KUNIT_EXPECT_EQ(test, 0, regmap_read(map, i, &rval)); in raw_read_defaults_single()
1723 KUNIT_EXPECT_EQ(test, config.reg_defaults[i].def, rval); in raw_read_defaults_single()
1727 static void raw_read_defaults(struct kunit *test) in raw_read_defaults() argument
1739 map = gen_raw_regmap(test, &config, &data); in raw_read_defaults()
1740 KUNIT_ASSERT_FALSE(test, IS_ERR(map)); in raw_read_defaults()
1745 rval = kunit_kmalloc(test, val_len, GFP_KERNEL); in raw_read_defaults()
1746 KUNIT_ASSERT_TRUE(test, rval != NULL); in raw_read_defaults()
1751 KUNIT_EXPECT_EQ(test, 0, regmap_raw_read(map, 0, rval, val_len)); in raw_read_defaults()
1755 KUNIT_EXPECT_EQ(test, def, be16_to_cpu((__force __be16)rval[i])); in raw_read_defaults()
1757 KUNIT_EXPECT_EQ(test, def, le16_to_cpu((__force __le16)rval[i])); in raw_read_defaults()
1762 static void raw_write_read_single(struct kunit *test) in raw_write_read_single() argument
1772 map = gen_raw_regmap(test, &config, &data); in raw_write_read_single()
1773 KUNIT_ASSERT_FALSE(test, IS_ERR(map)); in raw_write_read_single()
1780 KUNIT_EXPECT_EQ(test, 0, regmap_write(map, 0, val)); in raw_write_read_single()
1781 KUNIT_EXPECT_EQ(test, 0, regmap_read(map, 0, &rval)); in raw_write_read_single()
1782 KUNIT_EXPECT_EQ(test, val, rval); in raw_write_read_single()
1785 static void raw_write(struct kunit *test) in raw_write() argument
1797 map = gen_raw_regmap(test, &config, &data); in raw_write()
1798 KUNIT_ASSERT_FALSE(test, IS_ERR(map)); in raw_write()
1807 KUNIT_EXPECT_EQ(test, 0, regmap_raw_write(map, 2, val, sizeof(val))); in raw_write()
1811 KUNIT_EXPECT_EQ(test, 0, regmap_read(map, i, &rval)); in raw_write()
1817 KUNIT_EXPECT_EQ(test, rval, in raw_write()
1820 KUNIT_EXPECT_EQ(test, rval, in raw_write()
1825 KUNIT_EXPECT_EQ(test, config.reg_defaults[i].def, rval); in raw_write()
1831 KUNIT_EXPECT_MEMEQ(test, &hw_buf[2], val, sizeof(val)); in raw_write()
1844 static void raw_noinc_write(struct kunit *test) in raw_noinc_write() argument
1858 map = gen_raw_regmap(test, &config, &data); in raw_noinc_write()
1859 KUNIT_ASSERT_FALSE(test, IS_ERR(map)); in raw_noinc_write()
1876 KUNIT_EXPECT_EQ(test, 0, regmap_write(map, 1, val_test)); in raw_noinc_write()
1879 KUNIT_EXPECT_EQ(test, 0, regmap_noinc_write(map, 0, val_array, in raw_noinc_write()
1883 KUNIT_EXPECT_EQ(test, 0, regmap_read(map, 0, &val)); in raw_noinc_write()
1884 KUNIT_ASSERT_EQ(test, val_last, val); in raw_noinc_write()
1887 KUNIT_EXPECT_EQ(test, 0, regmap_read(map, 1, &val)); in raw_noinc_write()
1888 KUNIT_ASSERT_EQ(test, val_test, val); in raw_noinc_write()
1891 static void raw_sync(struct kunit *test) in raw_sync() argument
1903 map = gen_raw_regmap(test, &config, &data); in raw_sync()
1904 KUNIT_ASSERT_FALSE(test, IS_ERR(map)); in raw_sync()
1914 KUNIT_EXPECT_EQ(test, 0, regmap_raw_write(map, 2, val, in raw_sync()
1916 KUNIT_EXPECT_EQ(test, 0, regmap_write(map, 4, val[2])); in raw_sync()
1920 KUNIT_EXPECT_EQ(test, 0, regmap_read(map, i, &rval)); in raw_sync()
1926 KUNIT_EXPECT_EQ(test, rval, in raw_sync()
1929 KUNIT_EXPECT_EQ(test, rval, in raw_sync()
1934 KUNIT_EXPECT_EQ(test, rval, val[i - 2]); in raw_sync()
1937 KUNIT_EXPECT_EQ(test, config.reg_defaults[i].def, rval); in raw_sync()
1952 KUNIT_EXPECT_MEMNEQ(test, &hw_buf[2], &val[0], sizeof(val)); in raw_sync()
1960 KUNIT_EXPECT_EQ(test, 0, regcache_sync(map)); in raw_sync()
1963 KUNIT_EXPECT_MEMEQ(test, &hw_buf[2], &val[0], sizeof(val)); in raw_sync()
1966 static void raw_ranges(struct kunit *test) in raw_ranges() argument
1980 map = gen_raw_regmap(test, &config, &data); in raw_ranges()
1981 KUNIT_ASSERT_FALSE(test, IS_ERR(map)); in raw_ranges()
1986 KUNIT_EXPECT_EQ(test, 0, regmap_write(map, test_range.selector_reg, in raw_ranges()
1992 KUNIT_EXPECT_EQ(test, 0, regmap_write(map, test_range.range_min, 0)); in raw_ranges()
1993 KUNIT_EXPECT_TRUE(test, data->written[test_range.selector_reg]); in raw_ranges()
1994 KUNIT_EXPECT_TRUE(test, data->written[test_range.window_start]); in raw_ranges()
1998 KUNIT_EXPECT_EQ(test, 0, regmap_write(map, in raw_ranges()
2002 KUNIT_EXPECT_TRUE(test, data->written[test_range.selector_reg]); in raw_ranges()
2003 KUNIT_EXPECT_TRUE(test, data->written[test_range.window_start]); in raw_ranges()
2008 KUNIT_EXPECT_EQ(test, 0, regmap_read(map, test_range.range_min, &val)); in raw_ranges()
2009 KUNIT_EXPECT_TRUE(test, data->written[test_range.selector_reg]); in raw_ranges()
2010 KUNIT_EXPECT_TRUE(test, data->read[test_range.window_start]); in raw_ranges()
2014 KUNIT_EXPECT_EQ(test, 0, regmap_read(map, in raw_ranges()
2018 KUNIT_EXPECT_TRUE(test, data->written[test_range.selector_reg]); in raw_ranges()
2019 KUNIT_EXPECT_TRUE(test, data->read[test_range.window_start]); in raw_ranges()
2023 KUNIT_EXPECT_FALSE(test, data->read[i]); in raw_ranges()
2024 KUNIT_EXPECT_FALSE(test, data->written[i]); in raw_ranges()
2070 static int regmap_test_init(struct kunit *test) in regmap_test_init() argument
2075 priv = kunit_kzalloc(test, sizeof(*priv), GFP_KERNEL); in regmap_test_init()
2079 test->priv = priv; in regmap_test_init()
2081 dev = kunit_device_register(test, "regmap_test"); in regmap_test_init()
2086 dev_set_drvdata(dev, test); in regmap_test_init()
2091 static void regmap_test_exit(struct kunit *test) in regmap_test_exit() argument
2093 struct regmap_test_priv *priv = test->priv; in regmap_test_exit()