aboutsummaryrefslogtreecommitdiff
path: root/include/dm
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.masahiro@socionext.com>2017-12-30 02:00:05 +0900
committerJaehoon Chung <jh80.chung@samsung.com>2018-01-22 14:11:58 +0900
commit3ab48f62230b6753bf5535655c40e3b975825bd9 (patch)
tree25dcc283624d0cf8ecc1f44ba789f83fbbffd7e1 /include/dm
parent557767ed29968af0294e3aae48433e5d5a298e0b (diff)
downloadu-boot-3ab48f62230b6753bf5535655c40e3b975825bd9.zip
u-boot-3ab48f62230b6753bf5535655c40e3b975825bd9.tar.gz
u-boot-3ab48f62230b6753bf5535655c40e3b975825bd9.tar.bz2
dm: add dev_read_u32()
dev_read_u32_default() always returns something even when the property is missing. So, it is impossible to do nothing in the case. One solution is to use ofnode_read_u32() instead, but adding dev_read_u32() will be helpful. BTW, Linux has an equvalent function, device_property_read_u32(); it is clearer that it reads a property. I cannot understand the behavior of dev_read_u32() from its name. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Diffstat (limited to 'include/dm')
-rw-r--r--include/dm/read.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/include/dm/read.h b/include/dm/read.h
index 8114037..5cacec8 100644
--- a/include/dm/read.h
+++ b/include/dm/read.h
@@ -46,6 +46,16 @@ static inline bool dev_of_valid(struct udevice *dev)
#ifndef CONFIG_DM_DEV_READ_INLINE
/**
+ * dev_read_u32() - read a 32-bit integer from a device's DT property
+ *
+ * @dev: device to read DT property from
+ * @propname: name of the property to read from
+ * @outp: place to put value (if found)
+ * @return 0 if OK, -ve on error
+ */
+int dev_read_u32(struct udevice *dev, const char *propname, u32 *outp);
+
+/**
* dev_read_u32_default() - read a 32-bit integer from a device's DT property
*
* @dev: device to read DT property from
@@ -412,6 +422,12 @@ int dev_read_resource_byname(struct udevice *dev, const char *name,
#else /* CONFIG_DM_DEV_READ_INLINE is enabled */
+static inline int dev_read_u32(struct udevice *dev,
+ const char *propname, u32 *outp)
+{
+ return ofnode_read_u32(dev_ofnode(dev), propname, outp);
+}
+
static inline int dev_read_u32_default(struct udevice *dev,
const char *propname, int def)
{