diff options
author | Toshi Kani <toshi.kani@hp.com> | 2013-04-29 18:08:17 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-04-29 18:54:37 -0400 |
commit | ae8e3a915aef5af5ace5936c56f05f0b1502ded1 (patch) | |
tree | 379207c57c1773d77b5796e95ac7d7f5445b9271 /kernel/resource.c | |
parent | c73e5c9c59a0f7ba30b3e5f7bd2d8097d4c89c6d (diff) |
resource: add __adjust_resource() for internal use
Add __adjust_resource(), which is called by adjust_resource() internally
after the resource_lock is held. There is no interface change to
adjust_resource(). This change allows other functions to call
__adjust_resource() internally while the resource_lock is held.
Signed-off-by: Toshi Kani <toshi.kani@hp.com>
Reviewed-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Acked-by: David Rientjes <rientjes@google.com>
Cc: Ram Pai <linuxram@us.ibm.com>
Cc: T Makphaibulchoke <tmac@hp.com>
Cc: Wen Congyang <wency@cn.fujitsu.com>
Cc: Tang Chen <tangchen@cn.fujitsu.com>
Cc: Jiang Liu <jiang.liu@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/resource.c')
-rw-r--r-- | kernel/resource.c | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/kernel/resource.c b/kernel/resource.c index 73f35d4b30b9..ae246f97c5d3 100644 --- a/kernel/resource.c +++ b/kernel/resource.c | |||
@@ -706,24 +706,13 @@ void insert_resource_expand_to_fit(struct resource *root, struct resource *new) | |||
706 | write_unlock(&resource_lock); | 706 | write_unlock(&resource_lock); |
707 | } | 707 | } |
708 | 708 | ||
709 | /** | 709 | static int __adjust_resource(struct resource *res, resource_size_t start, |
710 | * adjust_resource - modify a resource's start and size | 710 | resource_size_t size) |
711 | * @res: resource to modify | ||
712 | * @start: new start value | ||
713 | * @size: new size | ||
714 | * | ||
715 | * Given an existing resource, change its start and size to match the | ||
716 | * arguments. Returns 0 on success, -EBUSY if it can't fit. | ||
717 | * Existing children of the resource are assumed to be immutable. | ||
718 | */ | ||
719 | int adjust_resource(struct resource *res, resource_size_t start, resource_size_t size) | ||
720 | { | 711 | { |
721 | struct resource *tmp, *parent = res->parent; | 712 | struct resource *tmp, *parent = res->parent; |
722 | resource_size_t end = start + size - 1; | 713 | resource_size_t end = start + size - 1; |
723 | int result = -EBUSY; | 714 | int result = -EBUSY; |
724 | 715 | ||
725 | write_lock(&resource_lock); | ||
726 | |||
727 | if (!parent) | 716 | if (!parent) |
728 | goto skip; | 717 | goto skip; |
729 | 718 | ||
@@ -751,6 +740,26 @@ skip: | |||
751 | result = 0; | 740 | result = 0; |
752 | 741 | ||
753 | out: | 742 | out: |
743 | return result; | ||
744 | } | ||
745 | |||
746 | /** | ||
747 | * adjust_resource - modify a resource's start and size | ||
748 | * @res: resource to modify | ||
749 | * @start: new start value | ||
750 | * @size: new size | ||
751 | * | ||
752 | * Given an existing resource, change its start and size to match the | ||
753 | * arguments. Returns 0 on success, -EBUSY if it can't fit. | ||
754 | * Existing children of the resource are assumed to be immutable. | ||
755 | */ | ||
756 | int adjust_resource(struct resource *res, resource_size_t start, | ||
757 | resource_size_t size) | ||
758 | { | ||
759 | int result; | ||
760 | |||
761 | write_lock(&resource_lock); | ||
762 | result = __adjust_resource(res, start, size); | ||
754 | write_unlock(&resource_lock); | 763 | write_unlock(&resource_lock); |
755 | return result; | 764 | return result; |
756 | } | 765 | } |