Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 189116
b: refs/heads/master
c: 66f1207
h: refs/heads/master
v: v3
  • Loading branch information
Bjorn Helgaas authored and Jesse Barnes committed Mar 23, 2010
1 parent a0a9dc7 commit 2c9f249
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 7c9e2b1c4784c6e574f69dbd904b2822f2e04d6e
refs/heads/master: 66f1207bce10fd80ee8ce99b67d617644612f05e
2 changes: 2 additions & 0 deletions trunk/include/linux/ioport.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,14 @@ struct resource_list {
extern struct resource ioport_resource;
extern struct resource iomem_resource;

extern struct resource *request_resource_conflict(struct resource *root, struct resource *new);
extern int request_resource(struct resource *root, struct resource *new);
extern int release_resource(struct resource *new);
void release_child_resources(struct resource *new);
extern void reserve_region_with_split(struct resource *root,
resource_size_t start, resource_size_t end,
const char *name);
extern struct resource *insert_resource_conflict(struct resource *parent, struct resource *new);
extern int insert_resource(struct resource *parent, struct resource *new);
extern void insert_resource_expand_to_fit(struct resource *root, struct resource *new);
extern int allocate_resource(struct resource *root, struct resource *new,
Expand Down
44 changes: 37 additions & 7 deletions trunk/kernel/resource.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,19 +219,34 @@ void release_child_resources(struct resource *r)
}

/**
* request_resource - request and reserve an I/O or memory resource
* request_resource_conflict - request and reserve an I/O or memory resource
* @root: root resource descriptor
* @new: resource descriptor desired by caller
*
* Returns 0 for success, negative error code on error.
* Returns 0 for success, conflict resource on error.
*/
int request_resource(struct resource *root, struct resource *new)
struct resource *request_resource_conflict(struct resource *root, struct resource *new)
{
struct resource *conflict;

write_lock(&resource_lock);
conflict = __request_resource(root, new);
write_unlock(&resource_lock);
return conflict;
}

/**
* request_resource - request and reserve an I/O or memory resource
* @root: root resource descriptor
* @new: resource descriptor desired by caller
*
* Returns 0 for success, negative error code on error.
*/
int request_resource(struct resource *root, struct resource *new)
{
struct resource *conflict;

conflict = request_resource_conflict(root, new);
return conflict ? -EBUSY : 0;
}

Expand Down Expand Up @@ -474,25 +489,40 @@ static struct resource * __insert_resource(struct resource *parent, struct resou
}

/**
* insert_resource - Inserts a resource in the resource tree
* insert_resource_conflict - Inserts resource in the resource tree
* @parent: parent of the new resource
* @new: new resource to insert
*
* Returns 0 on success, -EBUSY if the resource can't be inserted.
* Returns 0 on success, conflict resource if the resource can't be inserted.
*
* This function is equivalent to request_resource when no conflict
* This function is equivalent to request_resource_conflict when no conflict
* happens. If a conflict happens, and the conflicting resources
* entirely fit within the range of the new resource, then the new
* resource is inserted and the conflicting resources become children of
* the new resource.
*/
int insert_resource(struct resource *parent, struct resource *new)
struct resource *insert_resource_conflict(struct resource *parent, struct resource *new)
{
struct resource *conflict;

write_lock(&resource_lock);
conflict = __insert_resource(parent, new);
write_unlock(&resource_lock);
return conflict;
}

/**
* insert_resource - Inserts a resource in the resource tree
* @parent: parent of the new resource
* @new: new resource to insert
*
* Returns 0 on success, -EBUSY if the resource can't be inserted.
*/
int insert_resource(struct resource *parent, struct resource *new)
{
struct resource *conflict;

conflict = insert_resource_conflict(parent, new);
return conflict ? -EBUSY : 0;
}

Expand Down

0 comments on commit 2c9f249

Please sign in to comment.