Lines Matching +full:render +full:- +full:max

1 // SPDX-License-Identifier: GPL-2.0
3 // Register cache access API - maple tree based cache
19 struct maple_tree *mt = map->cache; in regcache_maple_read()
28 return -ENOENT; in regcache_maple_read()
31 *value = entry[reg - mas.index]; in regcache_maple_read()
41 struct maple_tree *mt = map->cache; in regcache_maple_write()
52 entry[reg - mas.index] = val; in regcache_maple_write()
58 mas_set_range(&mas, reg - 1, reg + 1); in regcache_maple_write()
62 lower = mas_find(&mas, reg - 1); in regcache_maple_write()
65 lower_sz = (mas.last - mas.index + 1) * sizeof(unsigned long); in regcache_maple_write()
71 upper_sz = (mas.last - mas.index + 1) * sizeof(unsigned long); in regcache_maple_write()
76 entry = kmalloc_array(last - index + 1, sizeof(*entry), map->alloc_flags); in regcache_maple_write()
78 return -ENOMEM; in regcache_maple_write()
82 entry[reg - index] = val; in regcache_maple_write()
84 memcpy(&entry[reg - index + 1], upper, upper_sz); in regcache_maple_write()
94 ret = mas_store_gfp(&mas, entry, map->alloc_flags); in regcache_maple_write()
107 unsigned int max) in regcache_maple_drop() argument
109 struct maple_tree *mt = map->cache; in regcache_maple_drop()
110 MA_STATE(mas, mt, min, max); in regcache_maple_drop()
112 /* initialized to work around false-positive -Wuninitialized warning */ in regcache_maple_drop()
122 mas_for_each(&mas, entry, max) { in regcache_maple_drop()
133 lower_last = min -1; in regcache_maple_drop()
136 min - mas.index, sizeof(*lower), in regcache_maple_drop()
137 map->alloc_flags); in regcache_maple_drop()
139 ret = -ENOMEM; in regcache_maple_drop()
144 if (mas.last > max) { in regcache_maple_drop()
145 upper_index = max + 1; in regcache_maple_drop()
148 upper = kmemdup_array(&entry[max - mas.index + 1], in regcache_maple_drop()
149 mas.last - max, sizeof(*upper), in regcache_maple_drop()
150 map->alloc_flags); in regcache_maple_drop()
152 ret = -ENOMEM; in regcache_maple_drop()
164 ret = mas_store_gfp(&mas, lower, map->alloc_flags); in regcache_maple_drop()
172 ret = mas_store_gfp(&mas, upper, map->alloc_flags); in regcache_maple_drop()
190 unsigned int min, unsigned int max) in regcache_maple_sync_block() argument
194 size_t val_bytes = map->format.val_bytes; in regcache_maple_sync_block()
205 if (max - min > 1 && regmap_can_raw_write(map)) { in regcache_maple_sync_block()
206 buf = kmalloc_array(max - min, val_bytes, map->alloc_flags); in regcache_maple_sync_block()
208 ret = -ENOMEM; in regcache_maple_sync_block()
212 /* Render the data for a raw write */ in regcache_maple_sync_block()
213 for (r = min; r < max; r++) { in regcache_maple_sync_block()
214 regcache_set_val(map, buf, r - min, in regcache_maple_sync_block()
215 entry[r - mas->index]); in regcache_maple_sync_block()
218 ret = _regmap_raw_write(map, min, buf, (max - min) * val_bytes, in regcache_maple_sync_block()
223 for (r = min; r < max; r++) { in regcache_maple_sync_block()
225 entry[r - mas->index]); in regcache_maple_sync_block()
238 unsigned int max) in regcache_maple_sync() argument
240 struct maple_tree *mt = map->cache; in regcache_maple_sync()
242 MA_STATE(mas, mt, min, max); in regcache_maple_sync()
244 unsigned long lmax = max; in regcache_maple_sync()
249 map->cache_bypass = true; in regcache_maple_sync()
253 mas_for_each(&mas, entry, max) { in regcache_maple_sync()
254 for (r = max(mas.index, lmin); r <= min(mas.last, lmax); r++) { in regcache_maple_sync()
255 v = entry[r - mas.index]; in regcache_maple_sync()
287 map->cache_bypass = false; in regcache_maple_sync()
294 struct maple_tree *mt = map->cache; in regcache_maple_exit()
309 map->cache = NULL; in regcache_maple_exit()
317 struct maple_tree *mt = map->cache; in regcache_maple_insert_block()
322 entry = kmalloc_array(last - first + 1, sizeof(*entry), map->alloc_flags); in regcache_maple_insert_block()
324 return -ENOMEM; in regcache_maple_insert_block()
326 for (i = 0; i < last - first + 1; i++) in regcache_maple_insert_block()
327 entry[i] = map->reg_defaults[first + i].def; in regcache_maple_insert_block()
331 mas_set_range(&mas, map->reg_defaults[first].reg, in regcache_maple_insert_block()
332 map->reg_defaults[last].reg); in regcache_maple_insert_block()
333 ret = mas_store_gfp(&mas, entry, map->alloc_flags); in regcache_maple_insert_block()
350 mt = kmalloc(sizeof(*mt), map->alloc_flags); in regcache_maple_init()
352 return -ENOMEM; in regcache_maple_init()
353 map->cache = mt; in regcache_maple_init()
357 if (!mt_external_lock(mt) && map->lock_key) in regcache_maple_init()
358 lockdep_set_class_and_subclass(&mt->ma_lock, map->lock_key, 1); in regcache_maple_init()
360 if (!map->num_reg_defaults) in regcache_maple_init()
366 for (i = 1; i < map->num_reg_defaults; i++) { in regcache_maple_init()
367 if (map->reg_defaults[i].reg != in regcache_maple_init()
368 map->reg_defaults[i - 1].reg + 1) { in regcache_maple_init()
370 i - 1); in regcache_maple_init()
380 map->num_reg_defaults - 1); in regcache_maple_init()