diff options
author | Hauke Mehrtens <hauke@hauke-m.de> | 2014-02-22 23:37:46 +0100 |
---|---|---|
committer | Hauke Mehrtens <hauke@hauke-m.de> | 2014-02-24 00:13:55 +0100 |
commit | dafdf13f253449a3f7806f7ba78aaf832a9aec0b (patch) | |
tree | 1a25de30fcc29e33b0d50f2bf208ec66f001f35f /backport/backport-include | |
parent | f8571d676ffc154da75d235d8498f574c061a55d (diff) |
backports: add of_property_count_u32_elems()
This is needed by drivers/regulator/gpio-regulator.c
This also adds of_property_count_elems_of_size()
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Diffstat (limited to 'backport/backport-include')
-rw-r--r-- | backport/backport-include/linux/of.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/backport/backport-include/linux/of.h b/backport/backport-include/linux/of.h index a4189bb6..10a3d11a 100644 --- a/backport/backport-include/linux/of.h +++ b/backport/backport-include/linux/of.h @@ -46,4 +46,39 @@ static inline int of_property_read_u8_array(const struct device_node *np, #endif /* CONFIG_OF */ #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0) */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0) +#define of_property_count_elems_of_size LINUX_BACKPORT(of_property_count_elems_of_size) +#ifdef CONFIG_OF +extern int of_property_count_elems_of_size(const struct device_node *np, + const char *propname, int elem_size); +#else +static inline int of_property_count_elems_of_size(const struct device_node *np, + const char *propname, int elem_size) +{ + return -ENOSYS; +} +#endif /* CONFIG_OF */ +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0) */ + + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0) +/** + * of_property_count_u32_elems - Count the number of u32 elements in a property + * + * @np: device node from which the property value is to be read. + * @propname: name of the property to be searched. + * + * Search for a property in a device node and count the number of u32 elements + * in it. Returns number of elements on sucess, -EINVAL if the property does + * not exist or its length does not match a multiple of u32 and -ENODATA if the + * property does not have a value. + */ +#define of_property_count_u32_elems LINUX_BACKPORT(of_property_count_u32_elems) +static inline int of_property_count_u32_elems(const struct device_node *np, + const char *propname) +{ + return of_property_count_elems_of_size(np, propname, sizeof(u32)); +} +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0) */ + #endif /* _COMPAT_LINUX_OF_H */ |