aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/of.h
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-11-04 08:03:59 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-11-04 15:58:23 -0500
commit8a0662d9ed2968e1186208336a8e1fab3fdfea63 (patch)
tree2109aed71b5279750754f1417e9b0ba0c519caa7 /include/linux/of.h
parent633a21d80b4a2cd648aa2dacdb22494ffb2f28f0 (diff)
Driver core: Unified interface for firmware node properties
Add new generic routines are provided for retrieving properties from device description objects in the platform firmware in case there are no struct device objects for them (either those objects have not been created yet or they do not exist at all). The following functions are provided: fwnode_property_present() fwnode_property_read_u8() fwnode_property_read_u16() fwnode_property_read_u32() fwnode_property_read_u64() fwnode_property_read_string() fwnode_property_read_u8_array() fwnode_property_read_u16_array() fwnode_property_read_u32_array() fwnode_property_read_u64_array() fwnode_property_read_string_array() in analogy with the corresponding functions for struct device added previously. For all of them, the first argument is a pointer to struct fwnode_handle (new type) that allows a device description object (depending on what platform firmware interface is in use) to be obtained. Add a new macro device_for_each_child_node() for iterating over the children of the device description object associated with a given device and a new function device_get_child_node_count() returning the number of a given device's child nodes. The interface covers both ACPI and Device Trees. Suggested-by: Grant Likely <grant.likely@linaro.org> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Acked-by: Grant Likely <grant.likely@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'include/linux/of.h')
-rw-r--r--include/linux/of.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/include/linux/of.h b/include/linux/of.h
index ce9f6a2b3532..cf79be1441d2 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -50,6 +50,7 @@ struct device_node {
50 const char *type; 50 const char *type;
51 phandle phandle; 51 phandle phandle;
52 const char *full_name; 52 const char *full_name;
53 struct fwnode_handle fwnode;
53 54
54 struct property *properties; 55 struct property *properties;
55 struct property *deadprops; /* removed properties */ 56 struct property *deadprops; /* removed properties */
@@ -80,6 +81,7 @@ extern struct kobj_type of_node_ktype;
80static inline void of_node_init(struct device_node *node) 81static inline void of_node_init(struct device_node *node)
81{ 82{
82 kobject_init(&node->kobj, &of_node_ktype); 83 kobject_init(&node->kobj, &of_node_ktype);
84 node->fwnode.type = FWNODE_OF;
83} 85}
84 86
85/* true when node is initialized */ 87/* true when node is initialized */
@@ -115,6 +117,16 @@ extern struct device_node *of_aliases;
115extern struct device_node *of_stdout; 117extern struct device_node *of_stdout;
116extern raw_spinlock_t devtree_lock; 118extern raw_spinlock_t devtree_lock;
117 119
120static inline bool is_of_node(struct fwnode_handle *fwnode)
121{
122 return fwnode && fwnode->type == FWNODE_OF;
123}
124
125static inline struct device_node *of_node(struct fwnode_handle *fwnode)
126{
127 return fwnode ? container_of(fwnode, struct device_node, fwnode) : NULL;
128}
129
118static inline bool of_have_populated_dt(void) 130static inline bool of_have_populated_dt(void)
119{ 131{
120 return of_allnodes != NULL; 132 return of_allnodes != NULL;
@@ -360,6 +372,16 @@ bool of_console_check(struct device_node *dn, char *name, int index);
360 372
361#else /* CONFIG_OF */ 373#else /* CONFIG_OF */
362 374
375static inline bool is_of_node(struct fwnode_handle *fwnode)
376{
377 return false;
378}
379
380static inline struct device_node *of_node(struct fwnode_handle *fwnode)
381{
382 return NULL;
383}
384
363static inline const char* of_node_full_name(const struct device_node *np) 385static inline const char* of_node_full_name(const struct device_node *np)
364{ 386{
365 return "<no-node>"; 387 return "<no-node>";