diff options
| author | Yinghai Lu <yinghai@kernel.org> | 2009-12-22 18:02:22 -0500 |
|---|---|---|
| committer | Jesse Barnes <jbarnes@virtuousgeek.org> | 2010-02-22 19:17:00 -0500 |
| commit | 5eeec0ec931a01e85b3701ce121b7d8a1800ec60 (patch) | |
| tree | 2efe474832b68a97c0460fc7f5e58a488f977dbb /kernel | |
| parent | 7cc5997d1dada3bdeed95a59c2f4f6c66cbb0767 (diff) | |
resource: add release_child_resources
Useful for freeing a portion of the resource tree, e.g. when trying to
reallocate resources more efficiently.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/resource.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/kernel/resource.c b/kernel/resource.c index 7fd123ad00aa..24e9e60c1459 100644 --- a/kernel/resource.c +++ b/kernel/resource.c | |||
| @@ -188,6 +188,36 @@ static int __release_resource(struct resource *old) | |||
| 188 | return -EINVAL; | 188 | return -EINVAL; |
| 189 | } | 189 | } |
| 190 | 190 | ||
| 191 | static void __release_child_resources(struct resource *r) | ||
| 192 | { | ||
| 193 | struct resource *tmp, *p; | ||
| 194 | resource_size_t size; | ||
| 195 | |||
| 196 | p = r->child; | ||
| 197 | r->child = NULL; | ||
| 198 | while (p) { | ||
| 199 | tmp = p; | ||
| 200 | p = p->sibling; | ||
| 201 | |||
| 202 | tmp->parent = NULL; | ||
| 203 | tmp->sibling = NULL; | ||
| 204 | __release_child_resources(tmp); | ||
| 205 | |||
| 206 | printk(KERN_DEBUG "release child resource %pR\n", tmp); | ||
| 207 | /* need to restore size, and keep flags */ | ||
| 208 | size = resource_size(tmp); | ||
| 209 | tmp->start = 0; | ||
| 210 | tmp->end = size - 1; | ||
| 211 | } | ||
| 212 | } | ||
| 213 | |||
| 214 | void release_child_resources(struct resource *r) | ||
| 215 | { | ||
| 216 | write_lock(&resource_lock); | ||
| 217 | __release_child_resources(r); | ||
| 218 | write_unlock(&resource_lock); | ||
| 219 | } | ||
| 220 | |||
| 191 | /** | 221 | /** |
| 192 | * request_resource - request and reserve an I/O or memory resource | 222 | * request_resource - request and reserve an I/O or memory resource |
| 193 | * @root: root resource descriptor | 223 | * @root: root resource descriptor |
