Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ae8e3a91 authored by Toshi Kani's avatar Toshi Kani Committed by Linus Torvalds
Browse files

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: default avatarToshi Kani <toshi.kani@hp.com>
Reviewed-by: default avatarYasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Acked-by: default avatarDavid 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: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent c73e5c9c
Loading
Loading
Loading
Loading
+22 −13
Original line number Original line Diff line number Diff line
@@ -706,24 +706,13 @@ void insert_resource_expand_to_fit(struct resource *root, struct resource *new)
	write_unlock(&resource_lock);
	write_unlock(&resource_lock);
}
}


/**
static int __adjust_resource(struct resource *res, resource_size_t start,
 * adjust_resource - modify a resource's start and size
				resource_size_t size)
 * @res: resource to modify
 * @start: new start value
 * @size: new size
 *
 * Given an existing resource, change its start and size to match the
 * arguments.  Returns 0 on success, -EBUSY if it can't fit.
 * Existing children of the resource are assumed to be immutable.
 */
int adjust_resource(struct resource *res, resource_size_t start, resource_size_t size)
{
{
	struct resource *tmp, *parent = res->parent;
	struct resource *tmp, *parent = res->parent;
	resource_size_t end = start + size - 1;
	resource_size_t end = start + size - 1;
	int result = -EBUSY;
	int result = -EBUSY;


	write_lock(&resource_lock);

	if (!parent)
	if (!parent)
		goto skip;
		goto skip;


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


 out:
 out:
	return result;
}

/**
 * adjust_resource - modify a resource's start and size
 * @res: resource to modify
 * @start: new start value
 * @size: new size
 *
 * Given an existing resource, change its start and size to match the
 * arguments.  Returns 0 on success, -EBUSY if it can't fit.
 * Existing children of the resource are assumed to be immutable.
 */
int adjust_resource(struct resource *res, resource_size_t start,
			resource_size_t size)
{
	int result;

	write_lock(&resource_lock);
	result = __adjust_resource(res, start, size);
	write_unlock(&resource_lock);
	write_unlock(&resource_lock);
	return result;
	return result;
}
}