Skip to content

Commit ae8e3a9

Browse files
Toshi Kanitorvalds
authored andcommitted
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>
1 parent c73e5c9 commit ae8e3a9

1 file changed

Lines changed: 22 additions & 13 deletions

File tree

‎kernel/resource.c‎

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -706,24 +706,13 @@ void insert_resource_expand_to_fit(struct resource *root, struct resource *new)
706706
write_unlock(&resource_lock);
707707
}
708708

709-
/**
710-
* adjust_resource - modify a resource's start and 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)
709+
static int __adjust_resource(struct resource *res, resource_size_t start,
710+
resource_size_t size)
720711
{
721712
struct resource *tmp, *parent = res->parent;
722713
resource_size_t end = start + size - 1;
723714
int result = -EBUSY;
724715

725-
write_lock(&resource_lock);
726-
727716
if (!parent)
728717
goto skip;
729718

@@ -751,6 +740,26 @@ int adjust_resource(struct resource *res, resource_size_t start, resource_size_t
751740
result = 0;
752741

753742
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);
754763
write_unlock(&resource_lock);
755764
return result;
756765
}

0 commit comments

Comments
 (0)