mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-06-13 15:03:58 +03:00
dm: core: Add a function to read into a unsigned int
The current dev_read...() functions use s32 and u32 which are convenient for device tree but not so useful for normal code, which often wants to use normal integers for values. Add a helper which supports returning an unsigned int. Also add signed versions of the unsigned readers. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -21,6 +21,29 @@ int dev_read_u32_default(struct udevice *dev, const char *propname, int def)
|
||||
return ofnode_read_u32_default(dev_ofnode(dev), propname, def);
|
||||
}
|
||||
|
||||
int dev_read_s32(struct udevice *dev, const char *propname, s32 *outp)
|
||||
{
|
||||
return ofnode_read_u32(dev_ofnode(dev), propname, (u32 *)outp);
|
||||
}
|
||||
|
||||
int dev_read_s32_default(struct udevice *dev, const char *propname, int def)
|
||||
{
|
||||
return ofnode_read_u32_default(dev_ofnode(dev), propname, def);
|
||||
}
|
||||
|
||||
int dev_read_u32u(struct udevice *dev, const char *propname, uint *outp)
|
||||
{
|
||||
u32 val;
|
||||
int ret;
|
||||
|
||||
ret = ofnode_read_u32(dev_ofnode(dev), propname, &val);
|
||||
if (ret)
|
||||
return ret;
|
||||
*outp = val;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *dev_read_string(struct udevice *dev, const char *propname)
|
||||
{
|
||||
return ofnode_read_string(dev_ofnode(dev), propname);
|
||||
|
||||
Reference in New Issue
Block a user