diff options
Diffstat (limited to 'kernel/resource.c')
-rw-r--r-- | kernel/resource.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/kernel/resource.c b/kernel/resource.c index 9bd14fd3e6d..a358142ff48 100644 --- a/kernel/resource.c +++ b/kernel/resource.c | |||
@@ -234,7 +234,7 @@ EXPORT_SYMBOL(release_resource); | |||
234 | * the caller must specify res->start, res->end, res->flags. | 234 | * the caller must specify res->start, res->end, res->flags. |
235 | * If found, returns 0, res is overwritten, if not found, returns -1. | 235 | * If found, returns 0, res is overwritten, if not found, returns -1. |
236 | */ | 236 | */ |
237 | int find_next_system_ram(struct resource *res) | 237 | static int find_next_system_ram(struct resource *res) |
238 | { | 238 | { |
239 | resource_size_t start, end; | 239 | resource_size_t start, end; |
240 | struct resource *p; | 240 | struct resource *p; |
@@ -267,6 +267,30 @@ int find_next_system_ram(struct resource *res) | |||
267 | res->end = p->end; | 267 | res->end = p->end; |
268 | return 0; | 268 | return 0; |
269 | } | 269 | } |
270 | int | ||
271 | walk_memory_resource(unsigned long start_pfn, unsigned long nr_pages, void *arg, | ||
272 | int (*func)(unsigned long, unsigned long, void *)) | ||
273 | { | ||
274 | struct resource res; | ||
275 | unsigned long pfn, len; | ||
276 | u64 orig_end; | ||
277 | int ret = -1; | ||
278 | res.start = (u64) start_pfn << PAGE_SHIFT; | ||
279 | res.end = ((u64)(start_pfn + nr_pages) << PAGE_SHIFT) - 1; | ||
280 | res.flags = IORESOURCE_MEM; | ||
281 | orig_end = res.end; | ||
282 | while ((res.start < res.end) && (find_next_system_ram(&res) >= 0)) { | ||
283 | pfn = (unsigned long)(res.start >> PAGE_SHIFT); | ||
284 | len = (unsigned long)((res.end + 1 - res.start) >> PAGE_SHIFT); | ||
285 | ret = (*func)(pfn, len, arg); | ||
286 | if (ret) | ||
287 | break; | ||
288 | res.start = res.end + 1; | ||
289 | res.end = orig_end; | ||
290 | } | ||
291 | return ret; | ||
292 | } | ||
293 | |||
270 | #endif | 294 | #endif |
271 | 295 | ||
272 | /* | 296 | /* |