aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/of.h
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2012-11-19 23:45:19 -0500
committerRob Herring <rob.herring@calxeda.com>2012-11-20 23:58:55 -0500
commitbe193249b4178158c0f697cb452b2bbf0cb16361 (patch)
tree4278eba967e625f0cdb6de865a83038243c51e80 /include/linux/of.h
parent9846210b1ec9bbaa30022d6d8af7e55ef67ccb45 (diff)
dt: add helper function to read u8 & u16 variables & arrays
This adds following helper routines: - of_property_read_u8_array() - of_property_read_u16_array() - of_property_read_u8() - of_property_read_u16() This expects arrays from DT to be passed as: - u8 array: property = /bits/ 8 <0x50 0x60 0x70>; - u16 array: property = /bits/ 16 <0x5000 0x6000 0x7000>; Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Rob Herring <rob.herring@calxeda.com>
Diffstat (limited to 'include/linux/of.h')
-rw-r--r--include/linux/of.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/include/linux/of.h b/include/linux/of.h
index 857dde984a6e..ab1af0e14659 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -223,6 +223,10 @@ extern struct device_node *of_find_node_with_property(
223extern struct property *of_find_property(const struct device_node *np, 223extern struct property *of_find_property(const struct device_node *np,
224 const char *name, 224 const char *name,
225 int *lenp); 225 int *lenp);
226extern int of_property_read_u8_array(const struct device_node *np,
227 const char *propname, u8 *out_values, size_t sz);
228extern int of_property_read_u16_array(const struct device_node *np,
229 const char *propname, u16 *out_values, size_t sz);
226extern int of_property_read_u32_array(const struct device_node *np, 230extern int of_property_read_u32_array(const struct device_node *np,
227 const char *propname, 231 const char *propname,
228 u32 *out_values, 232 u32 *out_values,
@@ -364,6 +368,18 @@ static inline struct device_node *of_find_compatible_node(
364 return NULL; 368 return NULL;
365} 369}
366 370
371static inline int of_property_read_u8_array(const struct device_node *np,
372 const char *propname, u8 *out_values, size_t sz)
373{
374 return -ENOSYS;
375}
376
377static inline int of_property_read_u16_array(const struct device_node *np,
378 const char *propname, u16 *out_values, size_t sz)
379{
380 return -ENOSYS;
381}
382
367static inline int of_property_read_u32_array(const struct device_node *np, 383static inline int of_property_read_u32_array(const struct device_node *np,
368 const char *propname, 384 const char *propname,
369 u32 *out_values, size_t sz) 385 u32 *out_values, size_t sz)
@@ -470,6 +486,20 @@ static inline bool of_property_read_bool(const struct device_node *np,
470 return prop ? true : false; 486 return prop ? true : false;
471} 487}
472 488
489static inline int of_property_read_u8(const struct device_node *np,
490 const char *propname,
491 u8 *out_value)
492{
493 return of_property_read_u8_array(np, propname, out_value, 1);
494}
495
496static inline int of_property_read_u16(const struct device_node *np,
497 const char *propname,
498 u16 *out_value)
499{
500 return of_property_read_u16_array(np, propname, out_value, 1);
501}
502
473static inline int of_property_read_u32(const struct device_node *np, 503static inline int of_property_read_u32(const struct device_node *np,
474 const char *propname, 504 const char *propname,
475 u32 *out_value) 505 u32 *out_value)