aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/resource.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/resource.c')
-rw-r--r--kernel/resource.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/kernel/resource.c b/kernel/resource.c
index cc73029088a7..bf1130d81b7f 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -230,6 +230,44 @@ int release_resource(struct resource *old)
230 230
231EXPORT_SYMBOL(release_resource); 231EXPORT_SYMBOL(release_resource);
232 232
233#ifdef CONFIG_MEMORY_HOTPLUG
234/*
235 * Finds the lowest memory reosurce exists within [res->start.res->end)
236 * the caller must specify res->start, res->end, res->flags.
237 * If found, returns 0, res is overwritten, if not found, returns -1.
238 */
239int find_next_system_ram(struct resource *res)
240{
241 resource_size_t start, end;
242 struct resource *p;
243
244 BUG_ON(!res);
245
246 start = res->start;
247 end = res->end;
248
249 read_lock(&resource_lock);
250 for (p = iomem_resource.child; p ; p = p->sibling) {
251 /* system ram is just marked as IORESOURCE_MEM */
252 if (p->flags != res->flags)
253 continue;
254 if (p->start > end) {
255 p = NULL;
256 break;
257 }
258 if (p->start >= start)
259 break;
260 }
261 read_unlock(&resource_lock);
262 if (!p)
263 return -1;
264 /* copy data */
265 res->start = p->start;
266 res->end = p->end;
267 return 0;
268}
269#endif
270
233/* 271/*
234 * Find empty slot in the resource tree given range and alignment. 272 * Find empty slot in the resource tree given range and alignment.
235 */ 273 */