Re: [PATCH 3/6] regmap: Add the rbtree cache support

Lars-Peter Clausen
2011-09-05T16:15:59Z

On 09/05/2011 03:50 PM, Dimitris Papastamos wrote:
> [...]
> +
> +static int regcache_rbtree_init(struct regmap *map)
> +{
> + struct regcache_rbtree_ctx *rbtree_ctx;
> + int i;
> + int ret;
> +
> + map->cache = kmalloc(sizeof *rbtree_ctx, GFP_KERNEL);
> + if (!map->cache)
> + return -ENOMEM;
> +
> + rbtree_ctx = map->cache;
> + rbtree_ctx->root = RB_ROOT;
> + rbtree_ctx->cached_rbnode = NULL;
> +
> + for (i = 0; i < map->num_cache_defaults; i++) {
> + ret = regcache_rbtree_write(map,
> + map->cache_defaults[ret].reg,
> + map->cache_defaults[ret].def);

map->cache_defaults[i]

> + if (ret)
> + goto err;
> + }
> +
> + return 0;
> +
> +err:
> + regcache_exit(map);
> + return ret;
> +}
> …