Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
1728d005
Commit
1728d005
authored
Oct 08, 2003
by
Benjamin Herrenschmidt
Committed by
Linus Torvalds
Oct 08, 2003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PATCH] add insert_resource() helper function
This allows PPC to insert resource descriptors later on after boot.
parent
0ac8d0f1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
0 deletions
+62
-0
include/linux/ioport.h
include/linux/ioport.h
+1
-0
kernel/resource.c
kernel/resource.c
+61
-0
No files found.
include/linux/ioport.h
View file @
1728d005
...
...
@@ -90,6 +90,7 @@ extern int get_resource_list(struct resource *, char *buf, int size);
extern
int
request_resource
(
struct
resource
*
root
,
struct
resource
*
new
);
extern
int
release_resource
(
struct
resource
*
new
);
extern
int
insert_resource
(
struct
resource
*
parent
,
struct
resource
*
new
);
extern
int
allocate_resource
(
struct
resource
*
root
,
struct
resource
*
new
,
unsigned
long
size
,
unsigned
long
min
,
unsigned
long
max
,
...
...
kernel/resource.c
View file @
1728d005
...
...
@@ -279,6 +279,67 @@ int allocate_resource(struct resource *root, struct resource *new,
EXPORT_SYMBOL
(
allocate_resource
);
/**
* 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.
*
* This function is equivalent of request_resource 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 childs of the new resource.
*/
int
insert_resource
(
struct
resource
*
parent
,
struct
resource
*
new
)
{
int
result
=
0
;
struct
resource
*
first
,
*
next
;
write_lock
(
&
resource_lock
);
first
=
__request_resource
(
parent
,
new
);
if
(
!
first
)
goto
out
;
result
=
-
EBUSY
;
if
(
first
==
parent
)
goto
out
;
for
(
next
=
first
;
next
->
sibling
;
next
=
next
->
sibling
)
if
(
next
->
sibling
->
start
>
new
->
end
)
break
;
/* existing resource overlaps end of new resource */
if
(
next
->
end
>
new
->
end
)
goto
out
;
result
=
0
;
new
->
parent
=
parent
;
new
->
sibling
=
next
->
sibling
;
new
->
child
=
first
;
next
->
sibling
=
NULL
;
for
(
next
=
first
;
next
;
next
=
next
->
sibling
)
next
->
parent
=
new
;
if
(
parent
->
child
==
first
)
{
parent
->
child
=
new
;
}
else
{
next
=
parent
->
child
;
while
(
next
->
sibling
!=
first
)
next
=
next
->
sibling
;
next
->
sibling
=
new
;
}
out:
write_unlock
(
&
resource_lock
);
return
result
;
}
EXPORT_SYMBOL
(
insert_resource
);
/*
* This is compatibility stuff for IO resources.
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment