Lines Matching refs:mem_rngs

46 static inline size_t get_mem_rngs_size(struct crash_mem *mem_rngs)  in get_mem_rngs_size()  argument
50 if (!mem_rngs) in get_mem_rngs_size()
54 (mem_rngs->max_nr_ranges * sizeof(struct crash_mem_range))); in get_mem_rngs_size()
75 struct crash_mem *mem_rngs = *mem_ranges; in __add_mem_range() local
77 if (!mem_rngs || (mem_rngs->nr_ranges == mem_rngs->max_nr_ranges)) { in __add_mem_range()
78 mem_rngs = realloc_mem_ranges(mem_ranges); in __add_mem_range()
79 if (!mem_rngs) in __add_mem_range()
83 mem_rngs->ranges[mem_rngs->nr_ranges].start = base; in __add_mem_range()
84 mem_rngs->ranges[mem_rngs->nr_ranges].end = base + size - 1; in __add_mem_range()
86 base, base + size - 1, mem_rngs->nr_ranges); in __add_mem_range()
87 mem_rngs->nr_ranges++; in __add_mem_range()
99 static void __merge_memory_ranges(struct crash_mem *mem_rngs) in __merge_memory_ranges() argument
104 if (!mem_rngs) in __merge_memory_ranges()
108 ranges = &(mem_rngs->ranges[0]); in __merge_memory_ranges()
109 for (i = 1; i < mem_rngs->nr_ranges; i++) { in __merge_memory_ranges()
120 mem_rngs->nr_ranges = idx + 1; in __merge_memory_ranges()
142 void sort_memory_ranges(struct crash_mem *mem_rngs, bool merge) in sort_memory_ranges() argument
146 if (!mem_rngs) in sort_memory_ranges()
150 sort(&(mem_rngs->ranges[0]), mem_rngs->nr_ranges, in sort_memory_ranges()
151 sizeof(mem_rngs->ranges[0]), rngcmp, NULL); in sort_memory_ranges()
154 __merge_memory_ranges(mem_rngs); in sort_memory_ranges()
158 for (i = 0; i < mem_rngs->nr_ranges; i++) { in sort_memory_ranges()
160 mem_rngs->ranges[i].start, in sort_memory_ranges()
161 mem_rngs->ranges[i].end); in sort_memory_ranges()
175 struct crash_mem *mem_rngs = *mem_ranges; in realloc_mem_ranges() local
179 size = get_mem_rngs_size(mem_rngs); in realloc_mem_ranges()
180 nr_ranges = mem_rngs ? mem_rngs->nr_ranges : 0; in realloc_mem_ranges()
183 mem_rngs = krealloc(*mem_ranges, size, GFP_KERNEL); in realloc_mem_ranges()
184 if (!mem_rngs) { in realloc_mem_ranges()
190 mem_rngs->nr_ranges = nr_ranges; in realloc_mem_ranges()
191 mem_rngs->max_nr_ranges = get_max_nr_ranges(size); in realloc_mem_ranges()
192 *mem_ranges = mem_rngs; in realloc_mem_ranges()
194 return mem_rngs; in realloc_mem_ranges()
210 struct crash_mem *mem_rngs = *mem_ranges; in add_mem_range() local
219 if (!mem_rngs || !(mem_rngs->nr_ranges)) in add_mem_range()
222 for (i = 0; i < mem_rngs->nr_ranges; i++) { in add_mem_range()
223 mstart = mem_rngs->ranges[i].start; in add_mem_range()
224 mend = mem_rngs->ranges[i].end; in add_mem_range()
227 mem_rngs->ranges[i].start = base; in add_mem_range()
229 mem_rngs->ranges[i].end = end; in add_mem_range()