@@ -126,7 +126,7 @@ static const struct regmap_test_param real_cache_types_list[] = {
126126 { .cache = REGCACHE_RBTREE , .from_reg = 0x2003 },
127127 { .cache = REGCACHE_RBTREE , .from_reg = 0x2004 },
128128 { .cache = REGCACHE_MAPLE , .from_reg = 0 },
129- { .cache = REGCACHE_RBTREE , .from_reg = 0 , .fast_io = true },
129+ { .cache = REGCACHE_MAPLE , .from_reg = 0 , .fast_io = true },
130130 { .cache = REGCACHE_MAPLE , .from_reg = 0x2001 },
131131 { .cache = REGCACHE_MAPLE , .from_reg = 0x2002 },
132132 { .cache = REGCACHE_MAPLE , .from_reg = 0x2003 },
@@ -1499,6 +1499,48 @@ static void cache_present(struct kunit *test)
14991499 KUNIT_ASSERT_TRUE (test , regcache_reg_cached (map , param -> from_reg + i ));
15001500}
15011501
1502+ static void cache_write_zero (struct kunit * test )
1503+ {
1504+ const struct regmap_test_param * param = test -> param_value ;
1505+ struct regmap * map ;
1506+ struct regmap_config config ;
1507+ struct regmap_ram_data * data ;
1508+ unsigned int val ;
1509+ int i ;
1510+
1511+ config = test_regmap_config ;
1512+
1513+ map = gen_regmap (test , & config , & data );
1514+ KUNIT_ASSERT_FALSE (test , IS_ERR (map ));
1515+ if (IS_ERR (map ))
1516+ return ;
1517+
1518+ for (i = 0 ; i < BLOCK_TEST_SIZE ; i ++ )
1519+ data -> read [param -> from_reg + i ] = false;
1520+
1521+ /* No defaults so no registers cached. */
1522+ for (i = 0 ; i < BLOCK_TEST_SIZE ; i ++ )
1523+ KUNIT_ASSERT_FALSE (test , regcache_reg_cached (map , param -> from_reg + i ));
1524+
1525+ /* We didn't trigger any reads */
1526+ for (i = 0 ; i < BLOCK_TEST_SIZE ; i ++ )
1527+ KUNIT_ASSERT_FALSE (test , data -> read [param -> from_reg + i ]);
1528+
1529+ /* Write a zero value */
1530+ KUNIT_EXPECT_EQ (test , 0 , regmap_write (map , 1 , 0 ));
1531+
1532+ /* Read that zero value back */
1533+ KUNIT_EXPECT_EQ (test , 0 , regmap_read (map , 1 , & val ));
1534+ KUNIT_EXPECT_EQ (test , 0 , val );
1535+
1536+ /* From the cache? */
1537+ KUNIT_ASSERT_TRUE (test , regcache_reg_cached (map , 1 ));
1538+
1539+ /* Try to throw it away */
1540+ KUNIT_EXPECT_EQ (test , 0 , regcache_drop_region (map , 1 , 1 ));
1541+ KUNIT_ASSERT_FALSE (test , regcache_reg_cached (map , 1 ));
1542+ }
1543+
15021544/* Check that caching the window register works with sync */
15031545static void cache_range_window_reg (struct kunit * test )
15041546{
@@ -2012,6 +2054,7 @@ static struct kunit_case regmap_test_cases[] = {
20122054 KUNIT_CASE_PARAM (cache_drop_all_and_sync_no_defaults , sparse_cache_types_gen_params ),
20132055 KUNIT_CASE_PARAM (cache_drop_all_and_sync_has_defaults , sparse_cache_types_gen_params ),
20142056 KUNIT_CASE_PARAM (cache_present , sparse_cache_types_gen_params ),
2057+ KUNIT_CASE_PARAM (cache_write_zero , sparse_cache_types_gen_params ),
20152058 KUNIT_CASE_PARAM (cache_range_window_reg , real_cache_types_only_gen_params ),
20162059
20172060 KUNIT_CASE_PARAM (raw_read_defaults_single , raw_test_types_gen_params ),
0 commit comments