diff options
Diffstat (limited to 'drivers/base/regmap/regcache-rbtree.c')
-rw-r--r-- | drivers/base/regmap/regcache-rbtree.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/drivers/base/regmap/regcache-rbtree.c b/drivers/base/regmap/regcache-rbtree.c index 861ad2c81dff..8d51916a283d 100644 --- a/drivers/base/regmap/regcache-rbtree.c +++ b/drivers/base/regmap/regcache-rbtree.c | |||
@@ -357,7 +357,8 @@ static int regcache_rbtree_write(struct regmap *map, unsigned int reg, | |||
357 | return 0; | 357 | return 0; |
358 | } | 358 | } |
359 | 359 | ||
360 | static int regcache_rbtree_sync(struct regmap *map) | 360 | static int regcache_rbtree_sync(struct regmap *map, unsigned int min, |
361 | unsigned int max) | ||
361 | { | 362 | { |
362 | struct regcache_rbtree_ctx *rbtree_ctx; | 363 | struct regcache_rbtree_ctx *rbtree_ctx; |
363 | struct rb_node *node; | 364 | struct rb_node *node; |
@@ -365,12 +366,30 @@ static int regcache_rbtree_sync(struct regmap *map) | |||
365 | unsigned int regtmp; | 366 | unsigned int regtmp; |
366 | unsigned int val; | 367 | unsigned int val; |
367 | int ret; | 368 | int ret; |
368 | int i; | 369 | int i, base, end; |
369 | 370 | ||
370 | rbtree_ctx = map->cache; | 371 | rbtree_ctx = map->cache; |
371 | for (node = rb_first(&rbtree_ctx->root); node; node = rb_next(node)) { | 372 | for (node = rb_first(&rbtree_ctx->root); node; node = rb_next(node)) { |
372 | rbnode = rb_entry(node, struct regcache_rbtree_node, node); | 373 | rbnode = rb_entry(node, struct regcache_rbtree_node, node); |
373 | for (i = 0; i < rbnode->blklen; i++) { | 374 | |
375 | if (rbnode->base_reg < min) | ||
376 | continue; | ||
377 | if (rbnode->base_reg > max) | ||
378 | break; | ||
379 | if (rbnode->base_reg + rbnode->blklen < min) | ||
380 | continue; | ||
381 | |||
382 | if (min > rbnode->base_reg) | ||
383 | base = min - rbnode->base_reg; | ||
384 | else | ||
385 | base = 0; | ||
386 | |||
387 | if (max < rbnode->base_reg + rbnode->blklen) | ||
388 | end = rbnode->base_reg + rbnode->blklen - max; | ||
389 | else | ||
390 | end = rbnode->blklen; | ||
391 | |||
392 | for (i = base; i < end; i++) { | ||
374 | regtmp = rbnode->base_reg + i; | 393 | regtmp = rbnode->base_reg + i; |
375 | val = regcache_rbtree_get_register(rbnode, i, | 394 | val = regcache_rbtree_get_register(rbnode, i, |
376 | map->cache_word_size); | 395 | map->cache_word_size); |