Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
linux-davinci
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
linux
linux-davinci
Commits
2c299e37
Commit
2c299e37
authored
Aug 14, 2009
by
Thomas Gleixner
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'rt/powerpc' into rt/base
parents
41010809
a87f354d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
102 additions
and
41 deletions
+102
-41
drivers/of/base.c
drivers/of/base.c
+102
-41
No files found.
drivers/of/base.c
View file @
2c299e37
...
@@ -59,16 +59,14 @@ int of_n_size_cells(struct device_node *np)
...
@@ -59,16 +59,14 @@ int of_n_size_cells(struct device_node *np)
}
}
EXPORT_SYMBOL
(
of_n_size_cells
);
EXPORT_SYMBOL
(
of_n_size_cells
);
struct
property
*
of_find_property
(
const
struct
device_node
*
np
,
static
struct
property
*
__of_find_property
(
const
struct
device_node
*
np
,
const
char
*
name
,
const
char
*
name
,
int
*
lenp
)
int
*
lenp
)
{
{
struct
property
*
pp
;
struct
property
*
pp
;
if
(
!
np
)
if
(
!
np
)
return
NULL
;
return
NULL
;
atomic_spin_lock
(
&
devtree_lock
);
for
(
pp
=
np
->
properties
;
pp
!=
0
;
pp
=
pp
->
next
)
{
for
(
pp
=
np
->
properties
;
pp
!=
0
;
pp
=
pp
->
next
)
{
if
(
of_prop_cmp
(
pp
->
name
,
name
)
==
0
)
{
if
(
of_prop_cmp
(
pp
->
name
,
name
)
==
0
)
{
if
(
lenp
!=
0
)
if
(
lenp
!=
0
)
...
@@ -76,12 +74,37 @@ struct property *of_find_property(const struct device_node *np,
...
@@ -76,12 +74,37 @@ struct property *of_find_property(const struct device_node *np,
break
;
break
;
}
}
}
}
atomic_spin_unlock
(
&
devtree_lock
);
return
pp
;
}
struct
property
*
of_find_property
(
const
struct
device_node
*
np
,
const
char
*
name
,
int
*
lenp
)
{
struct
property
*
pp
;
unsigned
long
flags
;
atomic_spin_lock_irqsave
(
&
devtree_lock
,
flags
);
pp
=
__of_find_property
(
np
,
name
,
lenp
);
atomic_spin_unlock_irqrestore
(
&
devtree_lock
,
flags
);
return
pp
;
return
pp
;
}
}
EXPORT_SYMBOL
(
of_find_property
);
EXPORT_SYMBOL
(
of_find_property
);
/*
* Find a property with a given name for a given node
* and return the value.
*/
static
const
void
*
__of_get_property
(
const
struct
device_node
*
np
,
const
char
*
name
,
int
*
lenp
)
{
struct
property
*
pp
=
__of_find_property
(
np
,
name
,
lenp
);
return
pp
?
pp
->
value
:
NULL
;
}
/*
/*
* Find a property with a given name for a given node
* Find a property with a given name for a given node
* and return the value.
* and return the value.
...
@@ -98,13 +121,13 @@ EXPORT_SYMBOL(of_get_property);
...
@@ -98,13 +121,13 @@ EXPORT_SYMBOL(of_get_property);
/** Checks if the given "compat" string matches one of the strings in
/** Checks if the given "compat" string matches one of the strings in
* the device's "compatible" property
* the device's "compatible" property
*/
*/
int
of_device_is_compatible
(
const
struct
device_node
*
device
,
static
int
__
of_device_is_compatible
(
const
struct
device_node
*
device
,
const
char
*
compat
)
const
char
*
compat
)
{
{
const
char
*
cp
;
const
char
*
cp
;
int
cplen
,
l
;
int
uninitialized_var
(
cplen
)
,
l
;
cp
=
of_get_property
(
device
,
"compatible"
,
&
cplen
);
cp
=
__
of_get_property
(
device
,
"compatible"
,
&
cplen
);
if
(
cp
==
NULL
)
if
(
cp
==
NULL
)
return
0
;
return
0
;
while
(
cplen
>
0
)
{
while
(
cplen
>
0
)
{
...
@@ -117,6 +140,21 @@ int of_device_is_compatible(const struct device_node *device,
...
@@ -117,6 +140,21 @@ int of_device_is_compatible(const struct device_node *device,
return
0
;
return
0
;
}
}
/** Checks if the given "compat" string matches one of the strings in
* the device's "compatible" property
*/
int
of_device_is_compatible
(
const
struct
device_node
*
device
,
const
char
*
compat
)
{
unsigned
long
flags
;
int
res
;
atomic_spin_lock_irqsave
(
&
devtree_lock
,
flags
);
res
=
__of_device_is_compatible
(
device
,
compat
);
atomic_spin_unlock_irqrestore
(
&
devtree_lock
,
flags
);
return
res
;
}
EXPORT_SYMBOL
(
of_device_is_compatible
);
EXPORT_SYMBOL
(
of_device_is_compatible
);
/**
/**
...
@@ -155,13 +193,14 @@ EXPORT_SYMBOL(of_device_is_available);
...
@@ -155,13 +193,14 @@ EXPORT_SYMBOL(of_device_is_available);
struct
device_node
*
of_get_parent
(
const
struct
device_node
*
node
)
struct
device_node
*
of_get_parent
(
const
struct
device_node
*
node
)
{
{
struct
device_node
*
np
;
struct
device_node
*
np
;
unsigned
long
flags
;
if
(
!
node
)
if
(
!
node
)
return
NULL
;
return
NULL
;
atomic_spin_lock
(
&
devtree_lock
);
atomic_spin_lock
_irqsave
(
&
devtree_lock
,
flags
);
np
=
of_node_get
(
node
->
parent
);
np
=
of_node_get
(
node
->
parent
);
atomic_spin_unlock
(
&
devtree_lock
);
atomic_spin_unlock
_irqrestore
(
&
devtree_lock
,
flags
);
return
np
;
return
np
;
}
}
EXPORT_SYMBOL
(
of_get_parent
);
EXPORT_SYMBOL
(
of_get_parent
);
...
@@ -180,14 +219,15 @@ EXPORT_SYMBOL(of_get_parent);
...
@@ -180,14 +219,15 @@ EXPORT_SYMBOL(of_get_parent);
struct
device_node
*
of_get_next_parent
(
struct
device_node
*
node
)
struct
device_node
*
of_get_next_parent
(
struct
device_node
*
node
)
{
{
struct
device_node
*
parent
;
struct
device_node
*
parent
;
unsigned
long
flags
;
if
(
!
node
)
if
(
!
node
)
return
NULL
;
return
NULL
;
atomic_spin_lock
(
&
devtree_lock
);
atomic_spin_lock
_irqsave
(
&
devtree_lock
,
flags
);
parent
=
of_node_get
(
node
->
parent
);
parent
=
of_node_get
(
node
->
parent
);
of_node_put
(
node
);
of_node_put
(
node
);
atomic_spin_unlock
(
&
devtree_lock
);
atomic_spin_unlock
_irqrestore
(
&
devtree_lock
,
flags
);
return
parent
;
return
parent
;
}
}
...
@@ -203,14 +243,15 @@ struct device_node *of_get_next_child(const struct device_node *node,
...
@@ -203,14 +243,15 @@ struct device_node *of_get_next_child(const struct device_node *node,
struct
device_node
*
prev
)
struct
device_node
*
prev
)
{
{
struct
device_node
*
next
;
struct
device_node
*
next
;
unsigned
long
flags
;
atomic_spin_lock
(
&
devtree_lock
);
atomic_spin_lock
_irqsave
(
&
devtree_lock
,
flags
);
next
=
prev
?
prev
->
sibling
:
node
->
child
;
next
=
prev
?
prev
->
sibling
:
node
->
child
;
for
(;
next
;
next
=
next
->
sibling
)
for
(;
next
;
next
=
next
->
sibling
)
if
(
of_node_get
(
next
))
if
(
of_node_get
(
next
))
break
;
break
;
of_node_put
(
prev
);
of_node_put
(
prev
);
atomic_spin_unlock
(
&
devtree_lock
);
atomic_spin_unlock
_irqrestore
(
&
devtree_lock
,
flags
);
return
next
;
return
next
;
}
}
EXPORT_SYMBOL
(
of_get_next_child
);
EXPORT_SYMBOL
(
of_get_next_child
);
...
@@ -225,14 +266,15 @@ EXPORT_SYMBOL(of_get_next_child);
...
@@ -225,14 +266,15 @@ EXPORT_SYMBOL(of_get_next_child);
struct
device_node
*
of_find_node_by_path
(
const
char
*
path
)
struct
device_node
*
of_find_node_by_path
(
const
char
*
path
)
{
{
struct
device_node
*
np
=
allnodes
;
struct
device_node
*
np
=
allnodes
;
unsigned
long
flags
;
atomic_spin_lock
(
&
devtree_lock
);
atomic_spin_lock
_irqsave
(
&
devtree_lock
,
flags
);
for
(;
np
;
np
=
np
->
allnext
)
{
for
(;
np
;
np
=
np
->
allnext
)
{
if
(
np
->
full_name
&&
(
of_node_cmp
(
np
->
full_name
,
path
)
==
0
)
if
(
np
->
full_name
&&
(
of_node_cmp
(
np
->
full_name
,
path
)
==
0
)
&&
of_node_get
(
np
))
&&
of_node_get
(
np
))
break
;
break
;
}
}
atomic_spin_unlock
(
&
devtree_lock
);
atomic_spin_unlock
_irqrestore
(
&
devtree_lock
,
flags
);
return
np
;
return
np
;
}
}
EXPORT_SYMBOL
(
of_find_node_by_path
);
EXPORT_SYMBOL
(
of_find_node_by_path
);
...
@@ -252,15 +294,16 @@ struct device_node *of_find_node_by_name(struct device_node *from,
...
@@ -252,15 +294,16 @@ struct device_node *of_find_node_by_name(struct device_node *from,
const
char
*
name
)
const
char
*
name
)
{
{
struct
device_node
*
np
;
struct
device_node
*
np
;
unsigned
long
flags
;
atomic_spin_lock
(
&
devtree_lock
);
atomic_spin_lock
_irqsave
(
&
devtree_lock
,
flags
);
np
=
from
?
from
->
allnext
:
allnodes
;
np
=
from
?
from
->
allnext
:
allnodes
;
for
(;
np
;
np
=
np
->
allnext
)
for
(;
np
;
np
=
np
->
allnext
)
if
(
np
->
name
&&
(
of_node_cmp
(
np
->
name
,
name
)
==
0
)
if
(
np
->
name
&&
(
of_node_cmp
(
np
->
name
,
name
)
==
0
)
&&
of_node_get
(
np
))
&&
of_node_get
(
np
))
break
;
break
;
of_node_put
(
from
);
of_node_put
(
from
);
atomic_spin_unlock
(
&
devtree_lock
);
atomic_spin_unlock
_irqrestore
(
&
devtree_lock
,
flags
);
return
np
;
return
np
;
}
}
EXPORT_SYMBOL
(
of_find_node_by_name
);
EXPORT_SYMBOL
(
of_find_node_by_name
);
...
@@ -281,15 +324,16 @@ struct device_node *of_find_node_by_type(struct device_node *from,
...
@@ -281,15 +324,16 @@ struct device_node *of_find_node_by_type(struct device_node *from,
const
char
*
type
)
const
char
*
type
)
{
{
struct
device_node
*
np
;
struct
device_node
*
np
;
unsigned
long
flags
;
atomic_spin_lock
(
&
devtree_lock
);
atomic_spin_lock
_irqsave
(
&
devtree_lock
,
flags
);
np
=
from
?
from
->
allnext
:
allnodes
;
np
=
from
?
from
->
allnext
:
allnodes
;
for
(;
np
;
np
=
np
->
allnext
)
for
(;
np
;
np
=
np
->
allnext
)
if
(
np
->
type
&&
(
of_node_cmp
(
np
->
type
,
type
)
==
0
)
if
(
np
->
type
&&
(
of_node_cmp
(
np
->
type
,
type
)
==
0
)
&&
of_node_get
(
np
))
&&
of_node_get
(
np
))
break
;
break
;
of_node_put
(
from
);
of_node_put
(
from
);
atomic_spin_unlock
(
&
devtree_lock
);
atomic_spin_unlock
_irqrestore
(
&
devtree_lock
,
flags
);
return
np
;
return
np
;
}
}
EXPORT_SYMBOL
(
of_find_node_by_type
);
EXPORT_SYMBOL
(
of_find_node_by_type
);
...
@@ -312,18 +356,20 @@ struct device_node *of_find_compatible_node(struct device_node *from,
...
@@ -312,18 +356,20 @@ struct device_node *of_find_compatible_node(struct device_node *from,
const
char
*
type
,
const
char
*
compatible
)
const
char
*
type
,
const
char
*
compatible
)
{
{
struct
device_node
*
np
;
struct
device_node
*
np
;
unsigned
long
flags
;
atomic_spin_lock
(
&
devtree_lock
);
atomic_spin_lock
_irqsave
(
&
devtree_lock
,
flags
);
np
=
from
?
from
->
allnext
:
allnodes
;
np
=
from
?
from
->
allnext
:
allnodes
;
for
(;
np
;
np
=
np
->
allnext
)
{
for
(;
np
;
np
=
np
->
allnext
)
{
if
(
type
if
(
type
&&
!
(
np
->
type
&&
(
of_node_cmp
(
np
->
type
,
type
)
==
0
)))
&&
!
(
np
->
type
&&
(
of_node_cmp
(
np
->
type
,
type
)
==
0
)))
continue
;
continue
;
if
(
of_device_is_compatible
(
np
,
compatible
)
&&
of_node_get
(
np
))
if
(
__of_device_is_compatible
(
np
,
compatible
)
&&
of_node_get
(
np
))
break
;
break
;
}
}
of_node_put
(
from
);
of_node_put
(
from
);
atomic_spin_unlock
(
&
devtree_lock
);
atomic_spin_unlock
_irqrestore
(
&
devtree_lock
,
flags
);
return
np
;
return
np
;
}
}
EXPORT_SYMBOL
(
of_find_compatible_node
);
EXPORT_SYMBOL
(
of_find_compatible_node
);
...
@@ -345,8 +391,9 @@ struct device_node *of_find_node_with_property(struct device_node *from,
...
@@ -345,8 +391,9 @@ struct device_node *of_find_node_with_property(struct device_node *from,
{
{
struct
device_node
*
np
;
struct
device_node
*
np
;
struct
property
*
pp
;
struct
property
*
pp
;
unsigned
long
flags
;
atomic_spin_lock
(
&
devtree_lock
);
atomic_spin_lock
_irqsave
(
&
devtree_lock
,
flags
);
np
=
from
?
from
->
allnext
:
allnodes
;
np
=
from
?
from
->
allnext
:
allnodes
;
for
(;
np
;
np
=
np
->
allnext
)
{
for
(;
np
;
np
=
np
->
allnext
)
{
for
(
pp
=
np
->
properties
;
pp
!=
0
;
pp
=
pp
->
next
)
{
for
(
pp
=
np
->
properties
;
pp
!=
0
;
pp
=
pp
->
next
)
{
...
@@ -358,19 +405,13 @@ struct device_node *of_find_node_with_property(struct device_node *from,
...
@@ -358,19 +405,13 @@ struct device_node *of_find_node_with_property(struct device_node *from,
}
}
out:
out:
of_node_put
(
from
);
of_node_put
(
from
);
atomic_spin_unlock
(
&
devtree_lock
);
atomic_spin_unlock
_irqrestore
(
&
devtree_lock
,
flags
);
return
np
;
return
np
;
}
}
EXPORT_SYMBOL
(
of_find_node_with_property
);
EXPORT_SYMBOL
(
of_find_node_with_property
);
/**
static
const
struct
of_device_id
*
* of_match_node - Tell if an device_node has a matching of_match structure
__of_match_node
(
const
struct
of_device_id
*
matches
,
* @matches: array of of device match structures to search in
* @node: the of device structure to match against
*
* Low level utility function used by device matching.
*/
const
struct
of_device_id
*
of_match_node
(
const
struct
of_device_id
*
matches
,
const
struct
device_node
*
node
)
const
struct
device_node
*
node
)
{
{
while
(
matches
->
name
[
0
]
||
matches
->
type
[
0
]
||
matches
->
compatible
[
0
])
{
while
(
matches
->
name
[
0
]
||
matches
->
type
[
0
]
||
matches
->
compatible
[
0
])
{
...
@@ -382,7 +423,7 @@ const struct of_device_id *of_match_node(const struct of_device_id *matches,
...
@@ -382,7 +423,7 @@ const struct of_device_id *of_match_node(const struct of_device_id *matches,
match
&=
node
->
type
match
&=
node
->
type
&&
!
strcmp
(
matches
->
type
,
node
->
type
);
&&
!
strcmp
(
matches
->
type
,
node
->
type
);
if
(
matches
->
compatible
[
0
])
if
(
matches
->
compatible
[
0
])
match
&=
of_device_is_compatible
(
node
,
match
&=
__
of_device_is_compatible
(
node
,
matches
->
compatible
);
matches
->
compatible
);
if
(
match
)
if
(
match
)
return
matches
;
return
matches
;
...
@@ -390,6 +431,25 @@ const struct of_device_id *of_match_node(const struct of_device_id *matches,
...
@@ -390,6 +431,25 @@ const struct of_device_id *of_match_node(const struct of_device_id *matches,
}
}
return
NULL
;
return
NULL
;
}
}
/**
* of_match_node - Tell if an device_node has a matching of_match structure
* @matches: array of of device match structures to search in
* @node: the of device structure to match against
*
* Low level utility function used by device matching.
*/
const
struct
of_device_id
*
of_match_node
(
const
struct
of_device_id
*
matches
,
const
struct
device_node
*
node
)
{
const
struct
of_device_id
*
match
;
unsigned
long
flags
;
atomic_spin_lock_irqsave
(
&
devtree_lock
,
flags
);
match
=
__of_match_node
(
matches
,
node
);
atomic_spin_unlock_irqrestore
(
&
devtree_lock
,
flags
);
return
match
;
}
EXPORT_SYMBOL
(
of_match_node
);
EXPORT_SYMBOL
(
of_match_node
);
/**
/**
...
@@ -408,15 +468,16 @@ struct device_node *of_find_matching_node(struct device_node *from,
...
@@ -408,15 +468,16 @@ struct device_node *of_find_matching_node(struct device_node *from,
const
struct
of_device_id
*
matches
)
const
struct
of_device_id
*
matches
)
{
{
struct
device_node
*
np
;
struct
device_node
*
np
;
unsigned
long
flags
;
atomic_spin_lock
(
&
devtree_lock
);
atomic_spin_lock
_irqsave
(
&
devtree_lock
,
flags
);
np
=
from
?
from
->
allnext
:
allnodes
;
np
=
from
?
from
->
allnext
:
allnodes
;
for
(;
np
;
np
=
np
->
allnext
)
{
for
(;
np
;
np
=
np
->
allnext
)
{
if
(
of_match_node
(
matches
,
np
)
&&
of_node_get
(
np
))
if
(
__
of_match_node
(
matches
,
np
)
&&
of_node_get
(
np
))
break
;
break
;
}
}
of_node_put
(
from
);
of_node_put
(
from
);
atomic_spin_unlock
(
&
devtree_lock
);
atomic_spin_unlock
_irqrestore
(
&
devtree_lock
,
flags
);
return
np
;
return
np
;
}
}
EXPORT_SYMBOL
(
of_find_matching_node
);
EXPORT_SYMBOL
(
of_find_matching_node
);
...
...
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